@@ -16,11 +16,16 @@ jobs:
1616 import-profile :
1717 runs-on : ubuntu-latest
1818 timeout-minutes : 60
19+ strategy :
20+ fail-fast : false
21+ matrix :
22+ shard : [0, 1, 2, 3, 4, 5, 6, 7] # 8 parallel shards
23+ name : import-profile (Shard ${{ matrix.shard }})
1924 steps :
2025 - name : Checkout
2126 uses : actions/checkout@v6
2227 with :
23- fetch-depth : 2
28+ fetch-depth : 0 # Fetch git history to find changed packages
2429 - name : Setup Python
2530 uses : actions/setup-python@v6
2631 with :
3439 PY_VERSION : " 3.15"
3540 # Workaround: Allows libcst to compile on Python 3.15+ while PyO3 catches up
3641 PYO3_USE_ABI3_FORWARD_COMPATIBILITY : " 1"
42+ SHARD_INDEX : ${{ matrix.shard }}
43+ TOTAL_SHARDS : 8
3744 run : |
38- ci/run_conditional_tests.sh
45+ TARGET_BRANCH=${TARGET_BRANCH:-main}
46+ git fetch origin "${TARGET_BRANCH}" --deepen=200 || true
47+
48+ # Get unique list of modified packages under packages/
49+ modified_packages=$(git diff --name-only origin/"${TARGET_BRANCH}"... | grep '^packages/' | cut -d/ -f1,2 | sort -u)
50+
51+ # Filter out packages incompatible with Python 3.15
52+ compatible_packages=""
53+ for pkg in $modified_packages; do
54+ if [ -d "$pkg" ]; then
55+ if pip install --no-deps --dry-run -e "$pkg" >/dev/null 2>&1; then
56+ compatible_packages="$compatible_packages $pkg"
57+ else
58+ echo "Skipping $pkg: Incompatible with Python 3.15 constraints"
59+ fi
60+ fi
61+ done
62+
63+ # Filter packages assigned to this specific shard index
64+ idx=0
65+ packages_to_test=""
66+ for pkg in $compatible_packages; do
67+ if [ $((idx % TOTAL_SHARDS)) -eq SHARD_INDEX ]; then
68+ packages_to_test="$packages_to_test $pkg"
69+ fi
70+ idx=$((idx + 1))
71+ done
72+
73+ # Run tests on the assigned packages
74+ if [ -n "$packages_to_test" ]; then
75+ echo "Shard ${{ matrix.shard }} running packages: $packages_to_test"
76+ PACKAGE_LIST="$packages_to_test" ci/run_conditional_tests.sh
77+ else
78+ echo "No packages assigned to Shard ${{ matrix.shard }}."
79+ fi
80+
81+ all-import-profiles :
82+ needs : import-profile
83+ if : always()
84+ runs-on : ubuntu-latest
85+ steps :
86+ - name : Check import profile results
87+ run : |
88+ if [[ "${{ needs.import-profile.result }}" != "success" && "${{ needs.import-profile.result }}" != "skipped" ]]; then
89+ echo "Import profiles failed"
90+ exit 1
91+ fi
92+ echo "All import profiles passed or were skipped"
0 commit comments