From cc45b78e5d37e69845c7cb08c7a26740ae3e6dcc Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Wed, 2 Dec 2026 22:34:16 +0100 Subject: [PATCH 1/5] Rename the CI job and add a timeout The version in the name broke the required status check when 3.14 became the `MAIN_PYTHON`. The timeout ensures the CI server stays ready even when something goes badly wrong. --- .forgejo/workflows/ci.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 4a9cb6e..18fb9d4 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -14,9 +14,12 @@ defaults: jobs: checks: - name: Checks (Python 3.14) + name: Checks 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: -- 2.47.3 From 49276bb9cfb1c9004d362bc3f88fd98f1be26e20 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Wed, 2 Dec 2026 22:41:16 +0100 Subject: [PATCH 2/5] Pull the CI setup into a composite action The upcoming parallel jobs share it. --- .forgejo/actions/setup/action.yaml | 30 ++++++++++++++++++++++++++++++ .forgejo/workflows/ci.yaml | 19 +------------------ 2 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 .forgejo/actions/setup/action.yaml diff --git a/.forgejo/actions/setup/action.yaml b/.forgejo/actions/setup/action.yaml new file mode 100644 index 0000000..e63ab23 --- /dev/null +++ b/.forgejo/actions/setup/action.yaml @@ -0,0 +1,30 @@ +name: Set up `velofy` +description: Install R, `uv`, and `velofy` with its dependencies + + +runs: + using: composite + + steps: + + - name: Install R via system packages + shell: bash + 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.14` + shell: bash + 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.14 + + - name: Install `velofy` and its dependencies + shell: bash + run: '"$HOME/.local/bin/uv" sync --locked' diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 18fb9d4..485e4ed 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -53,24 +53,7 @@ jobs: 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.14` - 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.14 - - - name: Install `velofy` and its dependencies - run: uv sync --locked + - uses: ./.forgejo/actions/setup - name: Ensure `nox -s format` changes nothing run: uv run nox -s format && git diff --exit-code -- 2.47.3 From e1cdac4cfa3649234deed4fabf2c2612548878f7 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Wed, 2 Dec 2026 23:45:45 +0100 Subject: [PATCH 3/5] 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`. --- .forgejo/actions/setup/action.yaml | 7 ++-- .forgejo/workflows/ci.yaml | 60 +++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/.forgejo/actions/setup/action.yaml b/.forgejo/actions/setup/action.yaml index e63ab23..d7c6e93 100644 --- a/.forgejo/actions/setup/action.yaml +++ b/.forgejo/actions/setup/action.yaml @@ -17,13 +17,14 @@ runs: r-cran-zoo \ -y - # Same `uv` version as pinned in pyproject.toml - - name: Install `uv` and `python3.14` + # All `SUPPORTED_PYTHONS` from the "classifiers" in pyproject.toml + # => `nox` would otherwise pick the system's Python without headers + - name: Install `uv` and all supported Python versions shell: bash 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.14 + "$HOME/.local/bin/uv" python install $(grep -oP 'Programming Language :: Python :: \K3\.\d+' pyproject.toml) - name: Install `velofy` and its dependencies shell: bash diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 485e4ed..6dc4777 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -12,16 +12,25 @@ defaults: 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: - checks: - name: Checks + + 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: + services: &database postgres: image: postgres:17 env: @@ -35,14 +44,6 @@ jobs: --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 @@ -61,16 +62,41 @@ jobs: - name: Lint the source files run: uv run nox -s lint - - name: Run the test suite - run: uv run nox -s test - - name: Test the code snippets in the docstrings with `xdoctest` run: uv run nox -s test-docstrings - - 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-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 + + # 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 }} -- 2.47.3 From 53746966acfa03ba85e8c8d20c99147a6b0b9c5e Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Thu, 3 Dec 2026 00:19:16 +0100 Subject: [PATCH 4/5] Cache `uv` between CI runs All jobs restore built wheels (e.g., `rpy2`) and the Python versions instead of building or fetching them again. Only the "lint" job saves the cache, pruned to what is expensive to rebuild, and only when its key changed; so, five jobs do not compress the same archive in parallel, and unchanged runs skip the 15s of packing. --- .forgejo/actions/setup/action.yaml | 20 ++++++++++++++++++++ .forgejo/workflows/ci.yaml | 15 +++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/.forgejo/actions/setup/action.yaml b/.forgejo/actions/setup/action.yaml index d7c6e93..c982842 100644 --- a/.forgejo/actions/setup/action.yaml +++ b/.forgejo/actions/setup/action.yaml @@ -17,6 +17,26 @@ runs: r-cran-zoo \ -y + # Built wheels (e.g., `rpy2`) and Python versions + # => A new key whenever the pinned dependencies or Python versions change + # => Only the "lint" job in ci.yaml saves the cache + - name: Restore the `uv` cache + id: uv-cache + uses: actions/cache/restore@v4 + with: + path: | + ~/.cache/uv + ~/.local/share/uv/python + key: uv-${{ runner.os }}-${{ hashFiles('uv.lock', 'pyproject.toml') }} + restore-keys: uv-${{ runner.os }}- + + # Tell the "lint" job in ci.yaml the key and if it must save the cache + - name: Remember the `uv` cache key and if it was restored exactly + shell: bash + run: | + echo "UV_CACHE_KEY=${{ steps.uv-cache.outputs.cache-primary-key }}" >> "$FORGEJO_ENV" + echo "UV_CACHE_HIT=${{ steps.uv-cache.outputs.cache-hit }}" >> "$FORGEJO_ENV" + # All `SUPPORTED_PYTHONS` from the "classifiers" in pyproject.toml # => `nox` would otherwise pick the system's Python without headers - name: Install `uv` and all supported Python versions diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 6dc4777..15b23d0 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -70,6 +70,21 @@ jobs: env: SKIP: local-format,local-lint,local-test,local-test-docstrings,local-test-types,no-commit-to-branch + # 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 }} + tests: name: Tests (${{ matrix.session }}) -- 2.47.3 From 8b5e66d70b546523077e6c60711d136eef46f990 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Thu, 3 Dec 2026 00:40:02 +0100 Subject: [PATCH 5/5] Install only `nox` and `pre-commit` in CI The `nox` sessions install `velofy` and its dependencies themselves; so, a full `uv sync` only duplicated that work. --- .forgejo/actions/setup/action.yaml | 8 +++++--- .forgejo/workflows/ci.yaml | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.forgejo/actions/setup/action.yaml b/.forgejo/actions/setup/action.yaml index c982842..ab6de4b 100644 --- a/.forgejo/actions/setup/action.yaml +++ b/.forgejo/actions/setup/action.yaml @@ -1,5 +1,5 @@ name: Set up `velofy` -description: Install R, `uv`, and `velofy` with its dependencies +description: Install R, `uv`, `nox`, and `pre-commit` runs: @@ -46,6 +46,8 @@ runs: echo "$HOME/.local/bin" >> "$FORGEJO_PATH" "$HOME/.local/bin/uv" python install $(grep -oP 'Programming Language :: Python :: \K3\.\d+' pyproject.toml) - - name: Install `velofy` and its dependencies + # The jobs only use `nox` and `pre-commit` from the develop environment + # => The `nox` sessions install `velofy` and its dependencies themselves + - name: Install `nox` and `pre-commit` shell: bash - run: '"$HOME/.local/bin/uv" sync --locked' + run: '"$HOME/.local/bin/uv" sync --locked --only-group dev' diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 15b23d0..4aca194 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -17,6 +17,7 @@ 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_NO_SYNC: "1" # Keep `uv run` from installing all groups (see the setup action) UV_PYTHON_PREFERENCE: only-managed # Only uv's Python has the headers to build `rpy2` -- 2.47.3