Skip to content

fix: restructure open-redirect check so CodeQL recognises the sanitizer #793

fix: restructure open-redirect check so CodeQL recognises the sanitizer

fix: restructure open-redirect check so CodeQL recognises the sanitizer #793

Workflow file for this run

name: Run Django tests
on:
push:
branches: [ "main" ]
paths:
- SORT/**
- home/**
- survey/**
- requirements*.txt
pull_request:
branches: [ "main" ]
paths:
- SORT/**
- home/**
- survey/**
- requirements*.txt
permissions:
contents: read
jobs:
django-test:
name: Run Django automated checks and tests
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
# This should match the version used in production
python-version-file: .python-version
cache: "pip"
- name: Install dependencies
run: pip install --requirement requirements.txt --requirement requirements-dev.txt
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Install JavaScript package
run: |
npm ci
npm run build
# https://docs.djangoproject.com/en/5.1/ref/django-admin/#check
- name: Run Django system checks
run: |
export DJANGO_SECRET_KEY="$(python -c "import secrets; print(secrets.token_urlsafe())")"
python manage.py check --fail-level WARNING
# https://docs.djangoproject.com/en/5.1/ref/django-admin/#cmdoption-makemigrations-check
- name: Check for missing migrations
run: |
export DJANGO_SECRET_KEY="$(python -c "import secrets; print(secrets.token_urlsafe())")"
python manage.py makemigrations --check --dry-run
# https://docs.djangoproject.com/en/5.1/topics/testing/
- name: Run Django test suites
run: |
export DJANGO_SECRET_KEY="$(python -c "import secrets; print(secrets.token_urlsafe())")"
# Iterate over Django apps with test directories
for test_dir in **/tests
do
echo "Testing $test_dir"
# https://docs.djangoproject.com/en/5.1/topics/testing/advanced/#integration-with-coverage-py
coverage run --source="home,survey" manage.py test "$test_dir" --verbosity=2 --parallel=auto
done
# Generate coverage report
echo "## Coverage report" >> $GITHUB_STEP_SUMMARY
coverage report --format="markdown" >> $GITHUB_STEP_SUMMARY