ci: share one uv sync across jobs, gate tests on lint+type-check, sync tag/version on release tags
CI / Setup environment (push) Failing after 2m28s
CI / Sync project version with tag (push) Has been skipped
CI / Lint (ruff check) (push) Has been skipped
CI / Format (ruff format) (push) Has been skipped
CI / Type check (ty) (push) Has been skipped
CI / Tests (push) Has been skipped
CI / Setup environment (pull_request) Failing after 2m27s
CI / Sync project version with tag (pull_request) Has been skipped
CI / Lint (ruff check) (pull_request) Has been skipped
CI / Format (ruff format) (pull_request) Has been skipped
CI / Type check (ty) (pull_request) Has been skipped
CI / Tests (pull_request) Has been skipped

Uploads the synced .venv as an artifact from a single setup job instead of
re-running uv sync (and re-downloading torch) in every job. Drops the
build/publish job in favor of a lighter job that, on a pushed tag, checks the
tag against the uv project version and — if they differ — bumps the version,
commits it to master, and recreates the tag on the new commit.
This commit is contained in:
2026-07-27 14:00:59 +02:00
parent b8a4dc7d63
commit 08c76a9614
+57 -23
View File
@@ -3,12 +3,13 @@ name: CI
"on":
push:
branches: ["**"]
tags: ["**"]
pull_request:
branches: [master]
jobs:
ruff-check:
name: Lint (ruff check)
setup:
name: Setup environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -16,63 +17,96 @@ jobs:
with:
enable-cache: true
- run: uv sync --extra cpu --extra dev
- run: tar -czf venv.tar.gz .venv
- uses: actions/upload-artifact@v4
with:
name: venv
path: venv.tar.gz
ruff-check:
name: Lint (ruff check)
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- uses: actions/download-artifact@v4
with:
name: venv
- run: tar -xzf venv.tar.gz
- run: uv run ruff check .
ruff-format:
name: Format (ruff format)
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- run: uv sync --extra cpu --extra dev
- uses: actions/download-artifact@v4
with:
name: venv
- run: tar -xzf venv.tar.gz
- run: uv run ruff format --check .
type-check:
name: Type check (ty)
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- run: uv sync --extra cpu --extra dev
- uses: actions/download-artifact@v4
with:
name: venv
- run: tar -xzf venv.tar.gz
- run: uv run ty check .
test:
name: Tests
needs: [setup, ruff-check, type-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- run: uv sync --extra cpu --extra dev
- uses: actions/download-artifact@v4
with:
name: venv
- run: tar -xzf venv.tar.gz
- run: uv run pytest
build:
name: Bump version, build & publish wheel
needs: [ruff-check, ruff-format, type-check, test]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
sync-version-on-tag:
name: Sync project version with tag
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.CI_TOKEN }}
- uses: astral-sh/setup-uv@v5
- name: Bump patch version
- name: Check tag against project version, update if they differ
run: |
git config user.name "gitea-actions"
git config user.email "actions@git.larsbogner.de"
uv version --bump patch --no-sync
NEW_VERSION=$(uv version --short)
git add pyproject.toml uv.lock
git commit -m "chore: bump version to ${NEW_VERSION} [skip ci]"
git push
- run: uv build
- name: Publish to Gitea package registry
env:
TWINE_USERNAME: ${{ secrets.PACKAGE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.CI_TOKEN }}
run: uvx twine upload --repository-url https://git.larsbogner.de/api/packages/lars/pypi dist/*
TAG_VERSION="${GITHUB_REF_NAME#v}"
CURRENT_VERSION=$(uv version --short)
if [ "$TAG_VERSION" != "$CURRENT_VERSION" ]; then
echo "Tag version ($TAG_VERSION) != project version ($CURRENT_VERSION); updating pyproject.toml"
uv version "$TAG_VERSION" --no-sync
git config user.name "gitea-actions"
git config user.email "actions@git.larsbogner.de"
git add pyproject.toml uv.lock
git commit -m "chore: sync project version to tag ${GITHUB_REF_NAME} [skip ci]"
git push origin HEAD:master
git push origin ":refs/tags/${GITHUB_REF_NAME}"
git tag -f "${GITHUB_REF_NAME}" HEAD
git push origin "refs/tags/${GITHUB_REF_NAME}"
else
echo "Tag version matches project version ($CURRENT_VERSION)"
fi