2026-11-23 16:27:04 +01:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
|
|
|
2026-11-28 01:03:48 +01:00
|
|
|
# Run on every push, which also covers pull requests from this repository
|
2026-11-23 16:27:04 +01:00
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use `bash` instead of the container's default `sh`
|
|
|
|
|
defaults:
|
|
|
|
|
run:
|
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
|
|
|
2026-12-02 23:45:45 +01:00
|
|
|
# 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
|
2026-12-03 00:40:02 +01:00
|
|
|
UV_NO_SYNC: "1" # Keep `uv run` from installing all groups (see the setup action)
|
2026-12-02 23:45:45 +01:00
|
|
|
UV_PYTHON_PREFERENCE: only-managed # Only uv's Python has the headers to build `rpy2`
|
|
|
|
|
|
|
|
|
|
|
2026-11-23 16:27:04 +01:00
|
|
|
jobs:
|
2026-12-02 23:45:45 +01:00
|
|
|
|
|
|
|
|
lint:
|
|
|
|
|
name: Lint
|
2026-11-23 16:27:04 +01:00
|
|
|
runs-on: debian-13
|
|
|
|
|
|
2026-12-02 22:34:16 +01:00
|
|
|
# Stop hanging jobs (e.g., a test waiting for a database lock)
|
|
|
|
|
timeout-minutes: 20
|
|
|
|
|
|
2026-11-23 16:27:04 +01:00
|
|
|
# Throwaway database, reachable from the job as host `postgres`
|
2026-12-02 23:45:45 +01:00
|
|
|
services: &database
|
2026-11-23 16:27:04 +01:00
|
|
|
postgres:
|
|
|
|
|
image: postgres:17
|
|
|
|
|
env:
|
|
|
|
|
POSTGRES_USER: user
|
|
|
|
|
POSTGRES_PASSWORD: password
|
|
|
|
|
POSTGRES_DB: db
|
2026-11-27 13:26:43 +01:00
|
|
|
# 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
|
2026-11-23 16:27:04 +01:00
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
|
2026-11-27 13:32:27 +01:00
|
|
|
- uses: actions/checkout@v6
|
2026-11-28 01:24:44 +01:00
|
|
|
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 ."
|
2026-11-23 16:27:04 +01:00
|
|
|
|
2026-12-02 22:41:16 +01:00
|
|
|
- uses: ./.forgejo/actions/setup
|
2026-11-23 16:27:04 +01:00
|
|
|
|
2026-11-27 13:27:28 +01:00
|
|
|
- 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
|
|
|
|
|
|
2026-12-01 17:14:48 +01:00
|
|
|
- name: Test the code snippets in the docstrings with `xdoctest`
|
|
|
|
|
run: uv run nox -s test-docstrings
|
2026-11-27 15:12:35 +01:00
|
|
|
|
|
|
|
|
- name: Run the `pre-commit` hooks not covered by `nox`
|
|
|
|
|
run: uv run pre-commit run --all-files --show-diff-on-failure
|
|
|
|
|
env:
|
2026-12-01 17:14:48 +01:00
|
|
|
SKIP: local-format,local-lint,local-test,local-test-docstrings,local-test-types,no-commit-to-branch
|
2026-12-02 23:45:45 +01:00
|
|
|
|
2026-12-03 00:19:16 +01:00
|
|
|
# Only this job saves the `uv` cache that ./.forgejo/actions/setup restores
|
|
|
|
|
# => Keep only what is expensive to rebuild, not wheels that are cheap to download
|
|
|
|
|
- name: Shrink the `uv` cache
|
|
|
|
|
if: env.UV_CACHE_HIT != 'true'
|
|
|
|
|
run: uv cache prune --ci
|
|
|
|
|
|
|
|
|
|
- name: Save the `uv` cache
|
|
|
|
|
if: env.UV_CACHE_HIT != 'true'
|
|
|
|
|
uses: actions/cache/save@v4
|
|
|
|
|
with:
|
|
|
|
|
path: |
|
|
|
|
|
~/.cache/uv
|
|
|
|
|
~/.local/share/uv/python
|
|
|
|
|
key: ${{ env.UV_CACHE_KEY }}
|
|
|
|
|
|
2026-12-02 23:45:45 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
# Same database as in the "lint" job
|
|
|
|
|
services: *database
|
|
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
|
|
|
|
|
- uses: actions/checkout@v6
|
|
|
|
|
|
|
|
|
|
- uses: ./.forgejo/actions/setup
|
|
|
|
|
|
|
|
|
|
- name: Run the `nox` session
|
|
|
|
|
run: uv run nox -s ${{ matrix.session }}
|