From 08c76a9614a12d01cd1558cb6aa1d6ac17a667cf Mon Sep 17 00:00:00 2001 From: Lars Bogner Date: Mon, 27 Jul 2026 14:00:59 +0200 Subject: [PATCH] ci: share one uv sync across jobs, gate tests on lint+type-check, sync tag/version on release tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .gitea/workflows/ci.yml | 80 +++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index c2c0765..25534bf 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -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