Feature/cd workflow #5
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: Build | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [3.13] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Install development dependencies | |
| run: | | |
| pip install flake8 black isort | |
| - name: Check code style with Black | |
| run: | | |
| black --check --diff . | |
| - name: Check imports with isort | |
| run: | | |
| isort --check-only --diff --profile black . | |
| - name: Lint with flake8 | |
| run: | | |
| # Stop the build if there are Python syntax errors or undefined names | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # Exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Validate Django migrations | |
| run: | | |
| python manage.py makemigrations --check --dry-run | |
| env: | |
| SECRET_KEY: 'test-secret-key-for-ci' | |
| DEBUG: 'True' | |
| DB_NAME: ':memory:' | |
| ALLOWED_HOSTS: 'localhost,127.0.0.1' | |
| - name: Check Django models and migrations | |
| run: | | |
| python manage.py check --tag models | |
| env: | |
| SECRET_KEY: 'test-secret-key-for-ci' | |
| DEBUG: 'True' | |
| DB_NAME: ':memory:' | |
| ALLOWED_HOSTS: 'localhost,127.0.0.1' | |
| - name: Validate DRF API schema | |
| run: | | |
| python manage.py spectacular --color --file schema_test.yml | |
| env: | |
| SECRET_KEY: 'test-secret-key-for-ci' | |
| DEBUG: 'True' | |
| DB_NAME: ':memory:' | |
| ALLOWED_HOSTS: 'localhost,127.0.0.1' | |
| - name: Run unit tests | |
| run: | | |
| python manage.py test --verbosity=2 | |
| env: | |
| SECRET_KEY: 'test-secret-key-for-ci' | |
| DEBUG: 'True' | |
| DB_NAME: ':memory:' | |
| DB_USER: 'test_user' | |
| DB_PASSWORD: 'test_password' | |
| DB_HOST: 'localhost' | |
| DB_PORT: '5432' | |
| ALLOWED_HOSTS: 'localhost,127.0.0.1' |