-
-
Notifications
You must be signed in to change notification settings - Fork 12.3k
105 lines (96 loc) · 3.65 KB
/
mypy_primer.yml
File metadata and controls
105 lines (96 loc) · 3.65 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
name: Run mypy_primer
on:
# Only run on PR, since we diff against main
pull_request:
paths:
- ".github/workflows/mypy_primer.yml"
- ".github/workflows/mypy_primer_comment.yml"
- "numpy/**/*.pyi"
- "numpy/_typing/*.py"
- "numpy/typing/*.py"
- "!numpy/typing/tests/**"
- "numpy/py.typed"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
mypy_primer:
name: Run
runs-on: ubuntu-latest
strategy:
matrix:
shard-index: [0] # e.g. change this to [0, 1, 2] and --num-shards below to 3
fail-fast: false
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: numpy_to_test
fetch-depth: 0
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
- name: Install dependencies
# To update: replace commit hash (no tags/releases available, use HEAD of master)
run: pip install git+https://github.com/hauntsaninja/mypy_primer.git@05f73ec3d85bb4f55676f3c57f2c3e5136228977 # HEAD of master on 2026-03-04
- name: Run mypy_primer
shell: bash
run: |
cd numpy_to_test
MYPY_VERSION=$(grep mypy== requirements/typing_requirements.txt | sed -n 's/mypy==\([^;]*\).*/\1/p')
echo "new commit"
git checkout $GITHUB_SHA
git rev-list --format=%s --max-count=1 HEAD
MERGE_BASE=$(git merge-base $GITHUB_SHA origin/$GITHUB_BASE_REF)
git worktree add ../numpy_base $MERGE_BASE
cd ../numpy_base
echo "base commit"
git rev-list --format=%s --max-count=1 HEAD
echo ''
cd ..
# fail action if exit code isn't zero or one
# TODO: note that we don't build numpy, so if a project attempts to use the
# numpy mypy plugin, we may see some issues involving version skew.
(
mypy_primer \
--new v${MYPY_VERSION} --old v${MYPY_VERSION} \
--known-dependency-selector numpy \
--old-prepend-path numpy_base --new-prepend-path numpy_to_test \
--num-shards 1 --shard-index ${{ matrix.shard-index }} \
--additional-flags="--python-version=3.12" \
--debug \
--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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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]
permissions:
contents: read
steps:
- name: Merge artifacts
uses: actions/upload-artifact/merge@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: mypy_primer_diffs
pattern: mypy_primer_diffs-*
delete-merged: true