velofy/.forgejo/workflows/ci.yaml

90 lines
2.7 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
jobs:
checks:
name: Checks (Python 3.13)
runs-on: debian-13
# 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
# 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`
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 ."
- name: Install R via system packages
run: |
apt-get update
apt-get install --no-install-recommends \
r-base-dev \
r-cran-forecast \
r-cran-zoo \
-y
# Same `uv` version as pinned in pyproject.toml
- name: Install `uv` and `python3.13`
run: |
curl -LsSf https://astral.sh/uv/0.13.10/install.sh | sh
echo "$HOME/.local/bin" >> "$FORGEJO_PATH"
"$HOME/.local/bin/uv" python install 3.13
- name: Install `velofy` and its dependencies
run: uv sync --locked
- 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: Run the test suite
run: uv run nox -s test
- name: Run the doctests
run: uv run nox -s doctest
- name: Check the type annotations at runtime with `typeguard`
run: uv run nox -s test-types
- 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-doctest,local-test-types,no-commit-to-branch