From b61340012222dd63540e29845d75eb0dd9686b63 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sat, 26 Sep 2026 17:01:27 +0200 Subject: [PATCH] Cut CI wall-clock: uv installs, xdist tests, pre-commit split 3 ways The slowest workflow took ~75 s: pip installs (~20 s each), a serial 1764-test pytest run (43 s), and one pre-commit job running mypy and pylint back to back (49 s). - Tests: setup-uv with a cached wheel store, pytest -n auto. - pre-commit: mypy / pylint / everything else as three parallel matrix jobs, each with its own hook-env cache; installs only pre-commit plus the two imports the system hooks need instead of all of requirements.txt. No check was removed from CI. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PhzaTAWtRfJk8gre6NLSka --- .github/workflows/pre-commit.yml | 40 +++++++++++++++++++++++++++--- .github/workflows/python-tests.yml | 17 ++++++++++--- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 965fb60..7534623 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -7,8 +7,25 @@ on: branches: [main] jobs: + # mypy and pylint check the whole repo and dominated a single ~50 s job, so + # each gets its own runner and the other hooks share a third; the workflow + # takes as long as the slowest group rather than the sum. pre-commit: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - group: mypy + hooks: mypy + skip: "" + - group: pylint + hooks: pylint + skip: "" + - group: rest + hooks: "" + skip: mypy,pylint + name: pre-commit (${{ matrix.group }}) steps: - uses: actions/checkout@v4 @@ -25,6 +42,23 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.x" - - name: Install dependencies - run: pip install -r requirements.txt - - uses: pre-commit/action@v3.0.1 + - uses: astral-sh/setup-uv@v10 + + # Every hook brings its own environment except the language: system + # ones; of those only dependency-freshness imports third-party code + # (pyyaml, packaging). The whole requirements.txt used to be installed + # here for nothing. + - name: Install pre-commit and the system hooks' imports + run: uv pip install --system pre-commit pyyaml packaging + + # One cache per group: a shared key would hold whichever group saved + # first, and the others would rebuild their hook envs on every run. + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ matrix.group }}-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: pre-commit run (${{ matrix.group }}) + env: + SKIP: ${{ matrix.skip }} + run: pre-commit run ${{ matrix.hooks }} --all-files --show-diff-on-failure --color=always diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 54d29d8..5d8b02d 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -18,16 +18,27 @@ jobs: with: python-version: "3.x" - - name: Install dependencies - run: pip install -r requirements.txt + # uv with a cached wheel store installs requirements.txt in seconds; + # plain pip took ~20 s of a ~70 s run. + - uses: astral-sh/setup-uv@v10 + with: + enable-cache: true + cache-dependency-glob: requirements.txt + - name: Install dependencies + run: uv pip install --system -r requirements.txt + + # -n auto spreads the suite over every runner core (pytest-xdist is in + # requirements.txt); pytest-cov merges the workers' coverage. - name: Run tests with coverage run: | python -m pytest steam_backlog_enforcer/tests/ \ + -n auto \ + -p no:sugar \ --cov=steam_backlog_enforcer \ --cov-branch \ --cov-fail-under=100 \ - -v + -q # vitest's 100% bar used to run only in the local pre-push hook, which # became a 1-second stamp check on 2026-09-20 (pre-commit's manual stage