Skip to content

Add background tasks for updating Pindora info on failure #2962

Add background tasks for updating Pindora info on failure

Add background tasks for updating Pindora info on failure #2962

Workflow file for this run

name: "Tests"
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
# Cancel a workflow from the same PR, branch or tag when a new workflow is triggered.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: 3.13
jobs:
checks:
name: "Check migrations and translations"
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:13-3.3-alpine
env:
POSTGRES_USER: tvp
POSTGRES_PASSWORD: tvp
POSTGRES_DB: tvp
DEBUG: true
SECRET_KEY: build_secret
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
ports:
- 5432:5432
redis:
image: redis:7-alpine
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 10
ports:
- 6379:6379
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Set up python"
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Install Poetry and project dependencies"
uses: ./.github/actions/poetry
with:
python-version: ${{ steps.setup-python.outputs.python-version }}
- name: "Test for migration issues"
run: poetry run python manage.py makemigrations --check --no-color --no-input --dry-run
env:
DJANGO_SETTINGS_ENVIRONMENT: CI
DATABASE_URL: postgis://tvp:tvp@localhost:5432/tvp
- name: "Test for missing translation"
run: poetry run python -m config.hooks.translations_done
env:
DJANGO_SETTINGS_ENVIRONMENT: CI
DATABASE_URL: postgis://tvp:tvp@localhost:5432/tvp
test:
name: "Run tests (${{ matrix.group }}/12)"
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:13-3.3-alpine
env:
POSTGRES_USER: tvp
POSTGRES_PASSWORD: tvp
POSTGRES_DB: tvp
DEBUG: true
SECRET_KEY: build_secret
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
ports:
- 5432:5432
redis:
image: redis:7-alpine
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 10
ports:
- 6379:6379
strategy:
matrix:
# Length must match "--splits" in test run.
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Set up python"
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Install Poetry and project dependencies"
uses: ./.github/actions/poetry
with:
python-version: ${{ steps.setup-python.outputs.python-version }}
- name: "Run pytest with coverage"
run: poetry run coverage run --branch -m pytest --disable-warnings --splits 12 --splitting-algorithm least_duration --group ${{ matrix.group }}
env:
DJANGO_SETTINGS_ENVIRONMENT: AutomatedTests
COVERAGE_FILE: .coverage.${{ matrix.group }}
- name: "Upload coverage artefact"
uses: actions/upload-artifact@v4
with:
name: cov-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.group }}
path: .coverage.${{ matrix.group }}
if-no-files-found: error
retention-days: 1
include-hidden-files: true
overwrite: true
sonarcloud:
needs: test
name: "SonarCloud scan"
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
# Disable shallow cloning to improve relevancy of reporting in SonarCloud
fetch-depth: 0
- name: "Download coverage artefacts"
uses: actions/download-artifact@v4
with:
pattern: cov-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-*
merge-multiple: true
- name: "Set up python"
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Install coverage"
run: pip install coverage
- name: "Combine coverage reports and generate XML report"
run: |
coverage combine
coverage xml
# # Without this workaround, SonarCloud reports a warning about an incorrect source path
# - name: "Override coverage report source path for SonarCloud"
# run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
- name: "SonarCloud Scan"
uses: SonarSource/sonarqube-scan-action@v4
# Skip analysis for all bots
if: ${{ ! contains(fromJSON(vars.BOTS), github.event.pull_request.user.login) }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}