Merge branch 'master' into dev #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [master, dev] | |
| pull_request: | |
| branches: [master, dev] | |
| jobs: | |
| lint: | |
| runs-on: self-hosted | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install lint dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install mypy | |
| - name: Run mypy | |
| run: mypy --config-file mypy.ini . | |
| tests: | |
| runs-on: self-hosted | |
| services: | |
| mariadb: | |
| image: mariadb:11 | |
| env: | |
| MARIADB_DATABASE: "test_db" | |
| MARIADB_USER: "testuser" | |
| MARIADB_PASSWORD: testpass | |
| MYSQL_RANDOM_ROOT_PASSWORD: yes | |
| ports: | |
| - 3306:3306 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Wait for MariaDB | |
| run: | | |
| for i in {1..60}; do | |
| if mysqladmin ping -h127.0.0.1 -utestuser -ptestpass --silent; then | |
| echo "MariaDB is up!" | |
| exit 0 | |
| fi | |
| echo "Waiting for MariaDB..." | |
| sleep 2 | |
| done | |
| echo "MariaDB did not become available in time." | |
| exit 1 | |
| - name: Set Django DB env | |
| run: | | |
| echo "DB_NAME=db" >> $GITHUB_ENV | |
| echo "DB_USER=testuser" >> $GITHUB_ENV | |
| echo "DB_PASSWORD=testpass" >> $GITHUB_ENV | |
| echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV | |
| echo "DB_PORT=3306" >> $GITHUB_ENV | |
| echo "SECRET_KEY=testsecrret" >> $GITHUB_ENV | |
| - name: Check for missing migrations | |
| env: | |
| DJANGO_DB_NAME: ${{ env.DB_NAME }} | |
| DJANGO_DB_USER: ${{ env.DB_USER }} | |
| DJANGO_DB_PASSWORD: ${{ env.DB_PASSWORD }} | |
| DJANGO_DB_HOST: ${{ env.DB_HOST }} | |
| DJANGO_DB_PORT: ${{ env.DB_PORT }} | |
| run: python manage.py makemigrations --check --dry-run | |
| - name: Run Django tests | |
| env: | |
| DJANGO_DB_NAME: ${{ env.DB_NAME }} | |
| DJANGO_DB_USER: ${{ env.DB_USER }} | |
| DJANGO_DB_PASSWORD: ${{ env.DB_PASSWORD }} | |
| DJANGO_DB_HOST: ${{ env.DB_HOST }} | |
| DJANGO_DB_PORT: ${{ env.DB_PORT }} | |
| run: python manage.py test --no-input | |
| build: | |
| runs-on: self-hosted | |
| needs: | |
| - lint | |
| - tests | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Collect static files | |
| run: python manage.py collectstatic --noinput | |
| deploy: | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
| runs-on: self-hosted | |
| needs: | |
| - build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install docker | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ secrets.REGISTRY_URL }} | |
| username: ${{ secrets.REGISTRY_USERNAME }} | |
| password: ${{ secrets.REGISTRY_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| tags: | | |
| ${{ secrets.REGISTRY_URL }}/bde_utt/bde_utt:${{ github.ref == 'refs/heads/master' && 'prod' || 'dev' }} |