Skip to content

Fix CSP configuration for django-csp 4 #4334

Fix CSP configuration for django-csp 4

Fix CSP configuration for django-csp 4 #4334

Workflow file for this run

name: Backend
on:
push:
branches:
- main
paths:
- docker/**
- pontoon/**
- requirements/**
- .github/workflows/backend.yml
pull_request:
branches:
- main
paths:
- docker/**
- pontoon/**
- requirements/**
- .github/workflows/backend.yml
workflow_dispatch:
permissions: {}
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 -U pontoon"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.13'
- name: Set up uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
enable-cache: true
cache-dependency-glob: |
**/requirements/*.txt
# Version should match the one used in docker/Dockerfile*
version: "0.11.32"
- name: Install requirements
run: uv pip install -r requirements/dev.txt
- name: Install pip-licenses
run: uv pip install 'pip-licenses==5.0.0'
- name: Check licenses
run: |
pip-licenses
pip-licenses --fail-on="GNU General Public License (GPL)" --ignore-packages text-unidecode translate-toolkit
# 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
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with: { node-version: '24' }
- run: npm install
working-directory: pontoon
- run: mkdir -p translate/dist translate/public
- run: zensical build -f documentation/zensical.toml
- run: python manage.py collectstatic
# Check if there are missing migrations
- name: Verify missing migrations
run: python manage.py makemigrations --check
# Confirm that requirements have been correctly compiled.
# Ignore comments and empty lines.
- name: Check compiled requirements
run: |
bash docker/compile_requirements.sh
for file in requirements/*.txt; do
if ! diff <(grep -vE '^\s*#|^\s*$' "$file") <(git show HEAD:"$file" | grep -vE '^\s*#|^\s*$'); then
echo "Error: $file is not up to date. Please run 'make requirements' and commit the changes."
exit 1
fi
done
- name: Run tests
env:
COVERAGE_CORE: sysmon
run: pytest -n auto --cov-report=xml:pontoon/coverage.xml --cov=.
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
flags: backend
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}