-
Notifications
You must be signed in to change notification settings - Fork 1.7k
92 lines (84 loc) · 2.94 KB
/
Copy pathimport-profiler.yml
File metadata and controls
92 lines (84 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: import-profiler
on:
pull_request:
branches:
- main
- preview
# Trigger workflow on GitHub merge queue events
merge_group:
types: [checks_requested]
permissions:
contents: read
jobs:
import-profile:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3, 4, 5, 6, 7] # 8 parallel shards
name: import-profile (Shard ${{ matrix.shard }})
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch git history to find changed packages
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.15"
allow-prereleases: true
- name: Run import profiler
env:
BUILD_TYPE: presubmit
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
TEST_TYPE: import_profile
PY_VERSION: "3.15"
# Workaround: Allows libcst to compile on Python 3.15+ while PyO3 catches up
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
SHARD_INDEX: ${{ matrix.shard }}
TOTAL_SHARDS: 8
run: |
TARGET_BRANCH=${TARGET_BRANCH:-main}
git fetch origin "${TARGET_BRANCH}" --deepen=200 || true
# Get unique list of modified packages under packages/
modified_packages=$(git diff --name-only origin/"${TARGET_BRANCH}"... | grep '^packages/' | cut -d/ -f1,2 | sort -u)
# Filter out packages incompatible with Python 3.15
compatible_packages=""
for pkg in $modified_packages; do
if [ -d "$pkg" ]; then
if pip install --no-deps --dry-run -e "$pkg" >/dev/null 2>&1; then
compatible_packages="$compatible_packages $pkg"
else
echo "Skipping $pkg: Incompatible with Python 3.15 constraints"
fi
fi
done
# Filter packages assigned to this specific shard index
idx=0
packages_to_test=""
for pkg in $compatible_packages; do
if [ $((idx % TOTAL_SHARDS)) -eq SHARD_INDEX ]; then
packages_to_test="$packages_to_test $pkg"
fi
idx=$((idx + 1))
done
# Run tests on the assigned packages
if [ -n "$packages_to_test" ]; then
echo "Shard ${{ matrix.shard }} running packages: $packages_to_test"
PACKAGE_LIST="$packages_to_test" ci/run_conditional_tests.sh
else
echo "No packages assigned to Shard ${{ matrix.shard }}."
fi
all-import-profiles:
needs: import-profile
if: always()
runs-on: ubuntu-latest
steps:
- name: Check import profile results
run: |
if [[ "${{ needs.import-profile.result }}" != "success" && "${{ needs.import-profile.result }}" != "skipped" ]]; then
echo "Import profiles failed"
exit 1
fi
echo "All import profiles passed or were skipped"