name: Test Python (Django) application on: push: branches: [ main ] pull_request: branches: [ main ] jobs: test_django: runs-on: ubuntu-latest # setup the postgres service needed by the webapp services: postgres: image: postgres:17 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: mp ports: - 5432:5432 # needed because the postgres container does not provide a healthcheck options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 solr: image: solr:9 ports: - 8983:8983 volumes: - /var/solr:/var/solr memcached: image: memcached:1.6 ports: - 11211:11211 # setup env for the application env: DJANGO_SETTINGS_MODULE: 'settings' DB_HOST: 127.0.0.1 DB_PASSWORD: postgres DB_NAME: mp DB_USER: postgres SECRET_KEY: thISkEyisUsedForTesting SOLR_URL: http://127.0.0.1:8983/solr/tester SOLR_ADMIN_URL: http://127.0.0.1:8983/solr/admin/cores steps: - uses: actions/checkout@v5 - name: Set up Python 3.13 uses: actions/setup-python@v5 with: python-version: '3.13' - name: Install dependencies run: | cd app python -m pip install --upgrade pip pip install -r requirements.txt pip install codecov - name: Configure solr run: | cd app mkdir -p /var/solr/server/solr/tester/conf python manage.py build_solr_schema --configure-directory=/var/solr/server/solr/tester/conf python manage.py build_solr_schema -r RELOAD_CORE python manage.py rebuild_index --noinput - name: Create and run migrations run: | cd app python manage.py makemigrations --noinput python manage.py migrate --noinput - name: Run collectstatic run: python app/manage.py collectstatic --noinput - name: Run tests run: | cd app coverage run --branch --source=. manage.py test coverage report coverage xml --fail-under=65 - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: fail_ci_if_error: true