velofy/.forgejo/actions/setup/action.yaml
Alexander Hess 53746966ac
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.
2026-12-03 01:12:30 +01:00

51 lines
1.8 KiB
YAML

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
# 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
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 $(grep -oP 'Programming Language :: Python :: \K3\.\d+' pyproject.toml)
- name: Install `velofy` and its dependencies
shell: bash
run: '"$HOME/.local/bin/uv" sync --locked'