name: CI # Forgejo Actions workflow. Forgejo resolves workflows from # .forgejo/workflows/ first (then .gitea/workflows/, then .github/workflows/). # # `runs-on: docker` matches the label exposed by the standard self-hosted # Forgejo runner. Change it if your runner was registered with another label. # # Actions are pinned to node20-compatible releases. Older forgejo-runner # versions (e.g. v6.4.0) reject any action whose action.yml declares # `using: node24` — checkout v4 is the last line that runs on node20. on: push: pull_request: jobs: lint-and-test: runs-on: docker steps: - name: Checkout # v4 runs on node20 (v5+ require node24). uses: https://data.forgejo.org/actions/checkout@v4 - name: Install uv # Installed from the official script rather than a Node action so the # job works on runners that only support node20. run: | curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.local/bin" >> "$GITHUB_PATH" export PATH="$HOME/.local/bin:$PATH" uv python install 3.13 uv --version - name: Lint (ruff) run: uvx --python 3.13 ruff check . - name: Test (pytest) # The suite only needs pytest: cadence.py imports nothing third-party # at module level, so no torch/whisper/ffmpeg is required here. run: uv run --python 3.13 --with pytest pytest -q version-bump: # Only meaningful on pull requests, where there is a base branch to diff # against. On `push` there is nothing to compare, so the job is skipped. if: github.event_name == 'pull_request' runs-on: docker steps: - name: Checkout uses: https://data.forgejo.org/actions/checkout@v4 with: # Full history so the base branch is reachable for the comparison. fetch-depth: 0 - name: Require a version bump shell: bash run: | set -euo pipefail # `github.base_ref` is the GitHub-compatible alias and is understood # by Forgejo; `forgejo.base_ref` is the canonical spelling. BASE="${{ github.base_ref }}" if [ -z "$BASE" ]; then echo "No base ref (not a pull request); skipping version check." exit 0 fi git fetch --no-tags origin "$BASE" if [ ! -f cadence.py ]; then echo "::error::cadence.py is missing from the change." exit 1 fi NEW=$(sed -n 's/^__version__[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' cadence.py | head -n1) if [ -z "$NEW" ]; then echo "::error::No __version__ found in cadence.py" exit 1 fi # The script may be introduced by this very PR: if it does not exist # on the base branch there is no previous version to bump from. if ! git cat-file -e "FETCH_HEAD:cadence.py" 2>/dev/null; then echo "cadence.py is new to '$BASE' (no base version); version check passes." exit 0 fi OLD=$(git show "FETCH_HEAD:cadence.py" | sed -n 's/^__version__[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' | head -n1) echo "base __version__: ${OLD:-} head __version__: $NEW" if [ -z "$OLD" ]; then echo "Could not read a base version; skipping." exit 0 fi # Require NEW to be strictly greater than OLD (version sort). GREATER=$(printf '%s\n%s\n' "$OLD" "$NEW" | sort -V | tail -n1) if [ "$NEW" = "$GREATER" ] && [ "$OLD" != "$NEW" ]; then echo "Version bumped: $OLD -> $NEW" else echo "::error::cadence.py __version__ must be bumped above $OLD (currently $NEW)." exit 1 fi