velofy/.forgejo/workflows/ci.yaml
Alexander Hess 4fd5478916
All checks were successful
CI / Tests (test-with-3.15) (push) Successful in 2m13s
CI / Tests (test-types) (push) Successful in 2m21s
CI / Tests (test) (push) Successful in 2m24s
CI / Tests (test-with-3.13) (push) Successful in 2m31s
CI / Lint (push) Successful in 2m36s
Run the CI checks in parallel jobs
The test sessions run as a matrix, each with its own database.

This also adds the "test-with" sessions to CI;
so, the setup installs all `SUPPORTED_PYTHONS` via `uv`,
as `nox` would otherwise pick the system Python 3.13,
which lacks the headers to build `rpy2`.
2026-12-03 00:02:43 +01:00

114 lines
3.2 KiB
YAML

name: CI
# Run on every push, which also covers pull requests from this repository
on:
push:
# Use `bash` instead of the container's default `sh`
defaults:
run:
shell: bash
# Same variables as in `.env` on `nehemiah`, the main development machine
env:
DATABASE_URI: postgresql://user:password@postgres:5432/db
GOOGLE_MAPS_API_KEY: AIzaDummyKeyForTests # Fake key to mock the Google API
R_LIBS: /usr/lib/R/site-library
UV_PYTHON_PREFERENCE: only-managed # Only uv's Python has the headers to build `rpy2`
jobs:
lint:
name: Lint
runs-on: debian-13
# Stop hanging jobs (e.g., a test waiting for a database lock)
timeout-minutes: 20
# Throwaway database, reachable from the job as host `postgres`
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: db
# Start the steps only once the database accepts connections
options: >-
--health-cmd "pg_isready --username=user --dbname=db"
--health-interval 2s
--health-timeout 5s
--health-retries 15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch all branches with their history for the next step
- name: Ensure feature branches contain no merge commits
if: forgejo.ref_name != 'develop' && forgejo.ref_name != 'main'
run: "! git rev-list --merges origin/develop..HEAD | grep ."
- uses: ./.forgejo/actions/setup
- name: Ensure `nox -s format` changes nothing
run: uv run nox -s format && git diff --exit-code
- name: Lint the source files
run: uv run nox -s lint
- name: Test the code snippets in the docstrings with `xdoctest`
run: uv run nox -s test-docstrings
- name: Run the `pre-commit` hooks not covered by `nox`
run: uv run pre-commit run --all-files --show-diff-on-failure
env:
SKIP: local-format,local-lint,local-test,local-test-docstrings,local-test-types,no-commit-to-branch
tests:
name: Tests (${{ matrix.session }})
runs-on: debian-13
# Stop hanging jobs (e.g., a test waiting for a database lock)
timeout-minutes: 20
# Run the sessions in parallel, each with its own database
strategy:
matrix:
session:
- test
- test-types
# One job per non-main Python version listed in the "classifiers"
# in pyproject.toml => Keep in sync manually
- test-with-3.13
- test-with-3.15
# Throwaway database, reachable from the job as host `postgres`
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: db
# Start the steps only once the database accepts connections
options: >-
--health-cmd "pg_isready --username=user --dbname=db"
--health-interval 2s
--health-timeout 5s
--health-retries 15
steps:
- uses: actions/checkout@v6
- uses: ./.forgejo/actions/setup
- name: Run the `nox` session "${{ matrix.session }}"
run: uv run nox -s ${{ matrix.session }}