@@ -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 packages assigned to this specific shard index
52+ idx=0
53+ packages_to_test=""
54+ for pkg in $modified_packages; do
55+ if [ -d "$pkg" ]; then
56+ if [ $((idx % TOTAL_SHARDS)) -eq SHARD_INDEX ]; then
57+ packages_to_test="$packages_to_test $pkg"
58+ fi
59+ idx=$((idx + 1))
60+ fi
61+ done
62+
63+ # Run tests on the assigned packages
64+ if [ -n "$packages_to_test" ]; then
65+ echo "Shard ${{ matrix.shard }} running packages: $packages_to_test"
66+ PACKAGE_LIST="$packages_to_test" ci/run_conditional_tests.sh
67+ else
68+ echo "No packages assigned to Shard ${{ matrix.shard }}."
69+ fi
70+
71+ all-import-profiles :
72+ needs : import-profile
73+ if : always()
74+ runs-on : ubuntu-latest
75+ steps :
76+ - name : Check import profile results
77+ run : |
78+ if [[ "${{ needs.import-profile.result }}" != "success" && "${{ needs.import-profile.result }}" != "skipped" ]]; then
79+ echo "Import profiles failed"
80+ exit 1
81+ fi
82+ echo "All import profiles passed or were skipped"
0 commit comments