93 lines
3.3 KiB
YAML
93 lines
3.3 KiB
YAML
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.
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
lint-and-test:
|
|
runs-on: docker
|
|
steps:
|
|
- name: Checkout
|
|
# Fully qualified so a changed DEFAULT_ACTIONS_URL can't break the run.
|
|
uses: https://data.forgejo.org/actions/checkout@v6
|
|
|
|
- name: Install uv
|
|
uses: https://data.forgejo.org/astral-sh/setup-uv@v10
|
|
with:
|
|
python-version: "3.13"
|
|
|
|
- name: Lint (ruff)
|
|
run: uvx 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 --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@v6
|
|
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:-<none>} 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
|