@@ -6,27 +6,40 @@ concurrency:
66 cancel-in-progress : true
77
88jobs :
9+ # =========================================================
10+ # 1. DISCOVERY
11+ # =========================================================
912 discover :
1013 runs-on : ubuntu-latest
1114 outputs :
12- packages : ${{ steps.changes .outputs.all_changed_files }}
15+ packages : ${{ steps.parse .outputs.packages }}
1316 steps :
1417 - uses : actions/checkout@v4
1518 - id : changes
1619 uses : tj-actions/changed-files@v44
1720 with :
18- files : packages/**
19- # Output as a space-separated string, NOT a JSON matrix
20- matrix : false
21+ files : packages/**
2122
23+ # Bulletproof directory extraction (ignores file names)
24+ - id : parse
25+ name : Extract Package Directories
26+ env :
27+ ALL_FILES : ${{ steps.changes.outputs.all_changed_files }}
28+ run : |
29+ PKGS=$(echo "$ALL_FILES" | tr ' ' '\n' | cut -d'/' -f1,2 | sort -u | tr '\n' ' ')
30+ echo "packages=$PKGS" >> $GITHUB_OUTPUT
31+
32+ # =========================================================
33+ # 2. EXECUTION (Parallelized internally via xargs)
34+ # =========================================================
2235 unit :
2336 needs : discover
2437 if : ${{ needs.discover.outputs.packages != '' }}
25- # USE YOUR ENTERPRISE RUNNER HERE
26- runs-on : ubuntu-latest-8-cores
38+ runs-on : ubuntu-latest
2739 strategy :
2840 fail-fast : false
2941 matrix :
42+ # Exactly 5 Jobs total. Never violates GitHub limits.
3043 python : ["3.9", "3.10", "3.11", "3.12", "3.14"]
3144
3245 name : Unit (Python ${{ matrix.python }})
@@ -37,15 +50,29 @@ jobs:
3750 python-version : ${{ matrix.python }}
3851 enable-cache : true
3952
40- - name : Run Tests Concurrently on 8 Cores
41- env :
42- NOX_DEFAULT_VENV_BACKEND : uv
53+ - name : Run Tests Concurrently
4354 run : |
44- # xargs -P 8 runs up to 8 package tests at the exact same time
45- echo "${{ needs.discover.outputs.packages }}" | xargs -n 1 -P 8 -I {} sh -c '
46- cd {} &&
47- if [ -f "noxfile.py" ]; then
48- echo "Testing {}..." &&
49- uvx --with "nox[uv]" nox -s "unit-${{ matrix.python }}"
55+ export NOX_DEFAULT_VENV_BACKEND=uv
56+ export UV_PRERELEASE=allow
57+
58+ # We use xargs -P 4 to run tests in parallel on the standard runner.
59+ # We redirect output to a file first so the GitHub UI logs don't interleave and become unreadable.
60+ echo "${{ needs.discover.outputs.packages }}" | tr ' ' '\n' | xargs -n 1 -P 4 -I {} sh -c '
61+ if [ -f "{}/noxfile.py" ]; then
62+ cd {}
63+
64+ # Run test and capture output
65+ uvx --with "nox[uv]" nox -s "unit-${{ matrix.python }}" > nox_output.log 2>&1
66+ STATUS=$?
67+
68+ # Print cleanly to GitHub UI
69+ echo "::group::Testing {}"
70+ cat nox_output.log
71+ echo "::endgroup::"
72+
73+ # If the test failed, exit with failure so GitHub catches it
74+ if [ $STATUS -ne 0 ]; then
75+ exit 255
76+ fi
5077 fi
51- '
78+ '
0 commit comments