[pre-commit.ci] pre-commit autoupdate #3446
Workflow file for this run
This file contains 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: Backend CI | |
on: | |
workflow_dispatch: | |
inputs: | |
run-tests: | |
description: 'Run all backend tests' | |
required: false | |
default: true | |
type: boolean | |
generate-emails: | |
description: 'Generate downloadable test e-mails' | |
required: false | |
default: false | |
type: boolean | |
pull_request: | |
push: | |
branches: [main] | |
paths: | |
- 'backend/**' | |
- '.github/workflows/backend.yml' | |
jobs: | |
backend-test: | |
name: Backend tests | |
runs-on: ubuntu-latest | |
continue-on-error: ${{ matrix.experimental }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- python-version: '3.12' | |
experimental: false | |
defaults: | |
run: | |
working-directory: backend | |
env: | |
DJANGO_SETTINGS_MODULE: core.settings.ci | |
services: | |
postgres: | |
image: postgres:17 | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: github_actions | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
redis: | |
image: redis:7 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 6379:6379 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
run: pipx install poetry | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'poetry' | |
cache-dependency-path: backend/poetry.lock | |
- name: Install dependencies | |
run: poetry install --with ci | |
- name: Check for model changes without migration | |
run: poetry run python manage.py makemigrations --check | |
- name: Synchronize database state and collect static files | |
run: | | |
poetry run python manage.py migrate --no-input | |
poetry run python manage.py collectstatic --no-input --clear --link | |
- name: Run tests | |
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.run-tests == 'true' }} | |
run: poetry run pytest | |
- name: Upload coverage to Codecov | |
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.run-tests == 'true' }} | |
uses: codecov/codecov-action@v4.6.0 | |
with: | |
directory: backend/ | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
- name: Archive code coverage results | |
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.run-tests == 'true' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code-coverage-report | |
path: backend/htmlcov/ | |
- name: Generate e-mail artifacts | |
if: ${{ github.event.inputs.generate-emails == 'true' }} | |
env: | |
BASE_URL_DOMAIN: felkeres.bsstudio.hu | |
EMAIL_FILE: True | |
run: poetry run python manage.py test tests.email_sending_tests | |
- name: Archive sent e-mails | |
if: ${{ github.event.inputs.generate-emails == 'true' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: emails | |
path: backend/logs/emails/ |