Skip to content

Commit 31f6f46

Browse files
perf(ci): PR-only slim matrix to cut PR wall-clock ~50%
Dynamic test matrix via set-matrix job: - pull_request: 1 combo (ubuntu-latest × 3.10, matches Codecov upload combo) - push / release / workflow_dispatch: full 10-combo matrix unchanged PR CI was ~44 min wall-clock on the slowest Windows shard. Push-to-main still runs all 10 shards before any release, so Windows parity and cross-version regressions stay covered. Fully reversible. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7d65682 commit 31f6f46

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,36 @@ env:
2828
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
2929

3030
jobs:
31+
# Decide the test matrix based on trigger:
32+
# - pull_request: 1 combo (ubuntu-latest × 3.10) — fast PR feedback, keeps Codecov upload
33+
# - push / release / workflow_dispatch: full 10-combo matrix
34+
# Rationale: PR CI was ~44 min wall-clock on the slowest Windows shard; a PR
35+
# rarely needs all 10 shards to catch regressions, and push-to-main still runs
36+
# the full matrix before any release. Fully reversible: delete set-matrix and
37+
# inline the old matrix block to restore.
38+
set-matrix:
39+
runs-on: ubuntu-latest
40+
outputs:
41+
matrix: ${{ steps.compute.outputs.matrix }}
42+
env:
43+
EVENT_NAME: ${{ github.event_name }}
44+
steps:
45+
- id: compute
46+
shell: bash
47+
run: |
48+
if [ "$EVENT_NAME" = "pull_request" ]; then
49+
# Match the Codecov upload combo (ubuntu-latest × 3.10) so PR runs still publish coverage.
50+
echo 'matrix={"include":[{"os":"ubuntu-latest","python-version":"3.10"}]}' >> "$GITHUB_OUTPUT"
51+
else
52+
echo 'matrix={"include":[{"os":"ubuntu-latest","python-version":"3.9"},{"os":"ubuntu-latest","python-version":"3.10"},{"os":"ubuntu-latest","python-version":"3.11"},{"os":"ubuntu-latest","python-version":"3.12"},{"os":"windows-latest","python-version":"3.10"},{"os":"windows-latest","python-version":"3.11"},{"os":"windows-latest","python-version":"3.12"},{"os":"macos-latest","python-version":"3.10"},{"os":"macos-latest","python-version":"3.11"},{"os":"macos-latest","python-version":"3.12"}]}' >> "$GITHUB_OUTPUT"
53+
fi
54+
3155
test:
56+
needs: set-matrix
3257
runs-on: ${{ matrix.os }}
3358
strategy:
3459
fail-fast: false
35-
matrix:
36-
os: [ubuntu-latest, windows-latest, macos-latest]
37-
python-version: ['3.9', '3.10', '3.11', '3.12']
38-
exclude:
39-
# 减少矩阵大小,只在 Ubuntu 上测试所有 Python 版本
40-
- os: windows-latest
41-
python-version: '3.9'
42-
- os: macos-latest
43-
python-version: '3.9'
60+
matrix: ${{ fromJSON(needs.set-matrix.outputs.matrix) }}
4461

4562
steps:
4663
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)