Repository navigation
130 lines (119 loc) · 4.33 KB
/
Copy pathci_mypy_primer_run.yml
File metadata and controls
130 lines (119 loc) · 4.33 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: "CI: mypy primer run"
on:
# Only run on PR, since we diff against master
pull_request:
paths:
- 'pyrefly/lib/**'
- 'pyrefly/third_party/**'
- '.github/workflows/ci_mypy_primer_run.yml'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
mypy_primer:
name: Run mypy_primer
runs-on: ubuntu-latest
strategy:
matrix:
shard-index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
fail-fast: false
timeout-minutes: 150
env:
PYREFLY_SCRIPTS_DIR: ${{ github.workspace }}/pyrefly_to_test/scripts
steps:
- uses: actions/checkout@v6
with:
path: pyrefly_to_test
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install -U pip
pip install git+https://github.com/hauntsaninja/mypy_primer.git
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt
- name: Run mypy_primer
shell: bash
run: |
cd pyrefly_to_test
echo "new commit"
git rev-list --format=%s --max-count=1 $GITHUB_SHA
MERGE_BASE=$(git merge-base $GITHUB_SHA origin/$GITHUB_BASE_REF)
git checkout -b base_commit $MERGE_BASE
echo "base commit"
git rev-list --format=%s --max-count=1 base_commit
echo ''
cd ..
BASE_DIR=$(pwd)/primer_base
mkdir -p $BASE_DIR
# Build pyrefly for "new" commit and install wrapper
NEW_DIR=$BASE_DIR/pyrefly_new
mkdir -p $NEW_DIR
cd pyrefly_to_test && git checkout $GITHUB_SHA
CARGO_TARGET_DIR=$NEW_DIR/target cargo build --release --manifest-path pyrefly/Cargo.toml
BINARY_DIR=$NEW_DIR/target/release
mv $BINARY_DIR/pyrefly $BINARY_DIR/pyrefly-real
cp scripts/pyrefly_primer_wrapper.sh $BINARY_DIR/pyrefly
chmod +x $BINARY_DIR/pyrefly
# Build pyrefly for "old" commit and install wrapper
OLD_DIR=$BASE_DIR/pyrefly_old
mkdir -p $OLD_DIR
git checkout base_commit
CARGO_TARGET_DIR=$OLD_DIR/target cargo build --release --manifest-path pyrefly/Cargo.toml
BINARY_DIR=$OLD_DIR/target/release
mv $BINARY_DIR/pyrefly $BINARY_DIR/pyrefly-real
# Use the wrapper from the new commit (old commit may not have it)
git checkout $GITHUB_SHA -- scripts/pyrefly_primer_wrapper.sh
cp scripts/pyrefly_primer_wrapper.sh $BINARY_DIR/pyrefly
chmod +x $BINARY_DIR/pyrefly
cd ..
# fail action if exit code isn't zero or one
(
MYPY_PRIMER_NO_REBUILD=1 mypy_primer \
--repo pyrefly_to_test \
--base-dir $BASE_DIR \
--cargo-profile release \
--new $GITHUB_SHA --old base_commit \
--num-shards 15 --shard-index ${{ matrix.shard-index }} \
--debug \
--project-selector '^(?!.*(python/cpython|sympy/sympy))' \
--type-checker pyrefly \
--output concise \
| tee diff_${{ matrix.shard-index }}.txt
) || [ $? -eq 1 ]
- if: ${{ matrix.shard-index == 0 }}
name: Save PR number
run: |
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
- name: Upload mypy_primer diff + PR number
uses: actions/upload-artifact@v6
if: ${{ matrix.shard-index == 0 }}
with:
name: mypy_primer_diffs-${{ matrix.shard-index }}
path: |
diff_${{ matrix.shard-index }}.txt
pr_number.txt
- name: Upload mypy_primer diff
uses: actions/upload-artifact@v6
if: ${{ matrix.shard-index != 0 }}
with:
name: mypy_primer_diffs-${{ matrix.shard-index }}
path: diff_${{ matrix.shard-index }}.txt
join_artifacts:
name: Join artifacts
runs-on: ubuntu-latest
needs: [mypy_primer]
steps:
- name: Merge artifacts
uses: actions/upload-artifact/merge@v4
with:
name: mypy_primer_diffs
pattern: mypy_primer_diffs-*
delete-merged: true