Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 115 additions & 109 deletions .github/workflows/backend_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,100 @@ name: Backend Check
on:
push:
branches:
- '*'
- 'main'
- "*"
- "main"
paths:
- 'backend/**.py'
- 'backend/requirements*.*'
- 'backend/pyproject.toml'
- 'Dockerfile*'
- 'docker-compose*.yml'
- '.github/workflows/backend_check.yml'
- "backend/**.py"
- "backend/uv.lock"
- "backend/pyproject.toml"
- "Dockerfile*"
- "docker-compose*.yml"
- ".github/workflows/backend_check.yml"
pull_request:
branches:
- 'main'
- "main"
paths:
- 'backend/**.py'
- 'backend/requirements*.*'
- 'backend/pyproject.toml'
- 'Dockerfile*'
- 'docker-compose*.yml'
- '.github/workflows/backend_check.yml'
- "backend/**.py"
- "backend/uv.lock"
- "backend/pyproject.toml"
- "Dockerfile*"
- "docker-compose*.yml"
- ".github/workflows/backend_check.yml"

jobs:

formatting_with_black:
static_analysis:
name: Run Black formatting check
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Check out Git repository
uses: actions/checkout@v5

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
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.12
uses: actions/setup-python@v5
with:
python-version: 3.12
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
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
working-directory: ./backend
python-version: "3.13"
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock

- name: Install Ruff with uv
working-directory: ./backend
run: |
uv sync --only-group ruff

- name: Check formatting with Ruff
working-directory: ./backend
run: |
uv run ruff format --check .

- name: Check linting using Ruff
working-directory: ./backend
run: |
uv run ruff check --select I .

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.12
uses: actions/setup-python@v5
with:
python-version: 3.12
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
- name: Check out Git repository
uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
working-directory: ./backend
python-version: "3.13"
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock

- name: Install dependencies
working-directory: ./backend
run: |
uv sync

- name: Check for migrations
working-directory: ./backend
env:
SECRET_KEY: "dummy_secret_key"
ENCRYPT_KEY: "this-key-should-be-exactly-32-ch"
run: |
set -a
uv run ./manage.py makemigrations --check --dry-run
set +a

tests:
name: Run backend tests
name: Run backend tests on Python ${{ matrix.python }}
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
python: [ "3.13", "3.14" ]

services:
postgres:
Expand All @@ -110,37 +109,44 @@ jobs:
- 5432:5432

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
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: 127.0.0.1
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
- name: Check out Git repository
uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
working-directory: ./backend
python-version: "${{ matrix.python }}"
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock

- name: Create test environment file
run: |
cp .env.example .env.test

- name: Install dependencies
working-directory: ./backend
env:
ENV_FILE_NAME: .env.test
run: |
uv sync
sudo apt-get update
sudo apt-get install gettext
uv run ./manage.py compilemessages

- name: Run tests
working-directory: ./backend
env:
ENV_FILE_NAME: .env.test
DATABASE_NAME: redirect
DATABASE_USER: user
DATABASE_PASSWORD: password
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: 5432
run: |
uv run ./manage.py wait_for_db
uv run pytest -Wd --cov --cov-report=xml --cov-report=term-missing --cov-fail-under=60 -n auto

codeql_analysis:
name: Analyze code using CodeQL
Expand All @@ -149,16 +155,16 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
language: [ "python", "javascript" ]

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
languages: "${{ matrix.language }}"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4
14 changes: 7 additions & 7 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
on:
push:
branches:
- 'main'
- 'refactor/frontend'
- 'feature/multi-forms/main'
- "main"
- "refactor/frontend"
- "feature/multi-forms/main"
tags:
- 'v*'
- "v*"
paths:
- 'backend/**'
- 'docker/**'
- '.github/workflows/build-image.yml'
- "backend/**"
- "docker/**"
- ".github/workflows/build-image.yml"

name: Build Docker image

Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/frontend_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Frontend Check

on:
push:
branches:
- "*"
- 'main'
paths:
- 'backend/assets/**'
- 'backend/static_extras/**'
- 'backend/templates/**'
- 'backend/package*.json'
- 'backend/.nvmrc'
- 'backend/postcss.config.js'
- 'backend/vite.config.js'
- 'Dockerfile*'
- 'docker-compose*.yml'
- '.github/workflows/frontend_check.yml'
pull_request:
branches:
- 'main'
paths:
- 'backend/assets/**'
- 'backend/static_extras/**'
- 'backend/templates/**'
- 'backend/package*.json'
- 'backend/.nvmrc'
- 'backend/postcss.config.js'
- 'backend/vite.config.js'
- 'Dockerfile*'
- 'docker-compose*.yml'
- '.github/workflows/frontend_check.yml'

jobs:

npm_prod:
name: Run `npm run build` in production mode for Node.js ${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
node: [ "22.21.0", "24" ]

steps:
- name: Check out Git repository
uses: actions/checkout@v5

- name: Set-up Node.js environment
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: 'npm'
cache-dependency-path: backend/package-lock.json

- name: Install dependencies
working-directory: ./backend
run: |
npm ci

- name: Build frontend
working-directory: ./backend
run: |
npm run build
Loading