Skip to content

Specify coverage file for back-end workflow (Python) #1853

Specify coverage file for back-end workflow (Python)

Specify coverage file for back-end workflow (Python) #1853

Workflow file for this run

name: Backend
on:
push:
branches:
- main
paths:
- requirements/**
- docker/config/server.env.template
- pontoon/**
- .github/workflows/backend.yml
pull_request:
branches:
- main
paths:
- requirements/**
- docker/config/server.env.template
- pontoon/**
- .github/workflows/backend.yml
workflow_dispatch:
jobs:
test:
name: pytest
env:
UV_SYSTEM_PYTHON: 1
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: pontoon
POSTGRES_PASSWORD: pontoon
POSTGRES_DB: pontoon
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
version: "0.4.13"
- run: >
uv pip install
-r requirements/default.txt
-r requirements/dev.txt
-r requirements/test.txt
-r requirements/lint.txt
# Set environment variables
- run: uv pip install pytest-dotenv
- run: >
sed
-e 's#^DATABASE_URL=.*#DATABASE_URL=postgres://pontoon:pontoon@localhost/pontoon#'
-e '/^SITE_URL=/d'
docker/config/server.env.template > .env
# Run collectstatic with minimal dependencies, skipping the actual front-end build
- run: npm install
working-directory: pontoon
- run: mkdir -p tag-admin/dist translate/dist translate/public
- run: python manage.py collectstatic
- run: pytest --cov-report=xml:pontoon/coverage.xml
- uses: codecov/codecov-action@v4
with:
flags: backend
files: pontoon/coverage.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}