Large tech debt payment #625
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Backend Check | |
on: | |
push: | |
branches: | |
- '*' | |
- 'main' | |
paths: | |
- 'backend/**.py' | |
- 'backend/requirements*.*' | |
- 'backend/pyproject.toml' | |
- 'Dockerfile*' | |
- 'docker-compose*.yml' | |
- '.github/workflows/backend_check.yml' | |
pull_request: | |
branches: | |
- 'main' | |
paths: | |
- 'backend/**.py' | |
- 'backend/requirements*.*' | |
- 'backend/pyproject.toml' | |
- 'Dockerfile*' | |
- 'docker-compose*.yml' | |
- '.github/workflows/backend_check.yml' | |
jobs: | |
formatting_with_black: | |
name: Run Black formatting check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
cache: 'pip' | |
- name: Install Black with latest pip | |
run: | | |
cat ./backend/requirements-dev.txt | grep black== | cut -d' ' -f1 | xargs pip install | |
- name: Check formatting with Black | |
run: | | |
black --check ./backend | |
linting_with_ruff: | |
name: Run Ruff linting check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
cache: 'pip' | |
- name: Install Black & Ruff with latest pip | |
run: | | |
cat ./backend/requirements-dev.txt | grep ruff== | cut -d' ' -f1 | xargs pip install | |
- name: Lint files using Ruff | |
run: | | |
ruff check ./backend | |
checking_migrations: | |
name: Check for migrations | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
pip install -r ./backend/requirements-dev.txt | |
- name: Check for migrations | |
run: | | |
set -a | |
. ./.env.example | |
python ./backend/manage.py makemigrations --check --dry-run | |
set +a | |
tests: | |
name: Run backend tests | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:16.1 | |
env: | |
POSTGRES_DB: redirect | |
POSTGRES_USER: user | |
POSTGRES_PASSWORD: password | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
cache: 'pip' | |
- name: Install dependencies | |
env: | |
ENV_FILE_NAME: .env.test | |
run: | | |
cp ./.env.example ./.env.test | |
python -m pip install --upgrade pip | |
pip install -r ./backend/requirements-dev.txt | |
sudo apt-get install gettext | |
./backend/manage.py compilemessages | |
- name: Run tests | |
env: | |
ENV_FILE_NAME: .env.test | |
DATABASE_NAME: redirect | |
DATABASE_USER: user | |
DATABASE_PASSWORD: password | |
DATABASE_HOST: postgres | |
DATABASE_PORT: 5432 | |
run: | | |
cd ./backend | |
python3 manage.py wait_for_db | |
pytest -Wd --cov --cov-report=xml --cov-report=term-missing --cov-fail-under=60 -n auto | |
codeql_analysis: | |
name: Analyze code using CodeQL | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
language: [ 'python' ] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: ${{ matrix.language }} | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 |