1+ name : Next-Gen CI Prototype
2+
3+ on :
4+ pull_request :
5+ branches : [ main ]
6+
7+ # 1. CONCURRENCY: Stop burning money on abandoned commits
8+ concurrency :
9+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10+ cancel-in-progress : true
11+
12+ jobs :
13+ # 2. DISCOVERY: Find exactly what changed and output JSON
14+ discover :
15+ runs-on : ubuntu-latest
16+ outputs :
17+ packages : ${{ steps.set-matrix.outputs.packages }}
18+ steps :
19+ - uses : actions/checkout@v4
20+ with :
21+ fetch-depth : 0 # Needed to diff against main
22+
23+ - name : Calculate Changed Packages
24+ id : set-matrix
25+ run : |
26+ # Find all modified directories inside packages/
27+ CHANGED=$(git diff --name-only origin/main...HEAD | grep "^packages/" | cut -d/ -f2 | sort -u || true)
28+
29+ if [ -z "$CHANGED" ]; then
30+ echo "packages=[]" >> $GITHUB_OUTPUT
31+ exit 0
32+ fi
33+
34+ # Convert bash list to JSON array using jq
35+ JSON_ARRAY=$(jq -R -s -c 'split("\n")[:-1]' <<< "$CHANGED")
36+ echo "Discovered packages: $JSON_ARRAY"
37+ echo "packages=$JSON_ARRAY" >> $GITHUB_OUTPUT
38+
39+ # 3. EXECUTION: Native Fan-out Matrix
40+ unit-test :
41+ needs : discover
42+ if : ${{ needs.discover.outputs.packages != '[]' }}
43+ runs-on : ubuntu-latest
44+ strategy :
45+ fail-fast : false # Don't kill the whole matrix if one package fails
46+ matrix :
47+ package : ${{ fromJSON(needs.discover.outputs.packages) }}
48+ # Risk-Tiering: Smoke test on presubmit to save money
49+ python : ["3.11"]
50+
51+ steps :
52+ - uses : actions/checkout@v4
53+
54+ # 4. THE ENGINE SWAP: Rust-based uv instead of setup-python + pip
55+ - name : Install uv and Python
56+ uses : astral-sh/setup-uv@v5
57+ with :
58+ python-version : ${{ matrix.python }}
59+ enable-cache : true
60+ cache-dependency-glob : " packages/${{ matrix.package }}/setup.py"
61+
62+ - name : Execute Tests (High-Density)
63+ # uvx downloads and runs nox in milliseconds without a global pip install
64+ run : |
65+ cd packages/${{ matrix.package }}
66+
67+ # Force nox to use uv as its backend for lightning-fast venv creation
68+ export VIRTUALENV_CREATOR=uv
69+
70+ echo "Running targeted tests for ${{ matrix.package }} on Python ${{ matrix.python }}"
71+ uvx nox -s unit-${{ matrix.python }}
0 commit comments