-
Notifications
You must be signed in to change notification settings - Fork 21
209 lines (194 loc) · 6.87 KB
/
build.yml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: Build wheels
on: [push, pull_request, workflow_dispatch]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
generate_wheels_matrix:
name: Generate wheels matrix
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v4
- name: Checkout mypy
shell: bash
# use a commit hash checked into a file to get the mypy revision to build.
# submodules prove problematic since .git is outside cibuildwheel's manylinux container
run: |
git clone https://github.com/python/mypy.git --recurse-submodules
git -C mypy checkout $(cat mypy_commit)
- name: Install cibuildwheel and pypyp
run: |
pipx install cibuildwheel==2.19.2
pipx install pypyp==1
- id: set-matrix
run: |
MATRIX=$(
{
cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform linux mypy \
| pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \
&& cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform macos mypy \
| pyp 'json.dumps({"only": x, "os": "macos-14"})' \
&& cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform windows mypy \
| pyp 'json.dumps({"only": x, "os": "windows-latest"})'
} | pyp 'json.dumps(list(map(json.loads, lines)))'
)
echo "include=$MATRIX" | tee -a $GITHUB_OUTPUT
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ARCHS_WINDOWS: AMD64
build_wheels:
name: Build ${{ matrix.only }}
needs: generate_wheels_matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate_wheels_matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- name: Checkout mypy
shell: bash
# use a commit hash checked into a file to get the mypy revision to build.
# submodules prove problematic since .git is outside cibuildwheel's manylinux container
run: |
git clone https://github.com/python/mypy.git --recurse-submodules
git -C mypy checkout $(cat mypy_commit)
- uses: pypa/cibuildwheel@v2.19.2
with:
config-file: cibuildwheel.toml
package-dir: mypy
only: ${{ matrix.only }}
- uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.only }}
path: ./wheelhouse/*.whl
overwrite: true
build_sdist_python_wheel:
name: sdist and python wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.9"
- name: Checkout mypy
shell: bash
run: |
COMMIT=$(cat mypy_commit)
git clone https://github.com/python/mypy.git
cd mypy
git checkout $COMMIT
git submodule update --init --recursive
- name: Run check-manifest
run: |
cd mypy
pip install check-manifest
check-manifest -v
- name: Build sdist and wheel
run: |
cd mypy
pip install --upgrade setuptools build
python -m build
- uses: actions/upload-artifact@v4
with:
name: dist-sdist_python_wheel
path: |
mypy/dist/*.whl
mypy/dist/*.tar.gz
overwrite: true
build_wasm_wheel:
name: WASM wheel for 3.10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.10"
- uses: actions/setup-node@v4
with:
node-version: 18.5.0 # pyodide tests with this version
- name: Install emscripten
id: install_emsdk
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
# Version of Emscripten pyodide 0.21.0 uses.
./emsdk install 3.1.14
./emsdk activate 3.1.14
# We need the location of emscripten when we use pyodide-build
echo "EMSCRIPTEN_DIR=$(pwd)" >> $GITHUB_OUTPUT
- name: Checkout mypy
shell: bash
run: |
COMMIT=$(cat mypy_commit)
git clone https://github.com/python/mypy.git
cd mypy
git checkout $COMMIT
git submodule update --init --recursive
- name: Install pyodide-build
run: |
python -m pip install "pyodide-build==0.21.0"
- name: Build wasm wheels
env:
MYPY_USE_MYPYC: "1"
MYPYC_OPT_LEVEL: "3"
EMSCRIPTEN_DIR: ${{ steps.install_emsdk.outputs.EMSCRIPTEN_DIR }}
run: |
cd mypy
source $EMSCRIPTEN_DIR/emsdk_env.sh
pyodide build --exports pyinit
- name: Install pyodide for WASM test
run: |
npm install pyodide@0.21.3
- name: Run WASM smoke test
run: |
node wasm_test.js
- uses: actions/upload-artifact@v4
with:
name: dist-wasm_wheel
path: |
mypy/dist/*.whl
overwrite: true
release:
name: create release
needs: [build_wheels, build_sdist_python_wheel, build_wasm_wheel]
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Release
if: ${{ github.event_name != 'pull_request' }}
# https://github.com/actions/upload-release-asset/issues/47
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log('environment', process.versions);
console.log({ owner, repo, sha });
const release = await github.rest.repos.createRelease({
owner, repo,
// if GITHUB_REF just appears to be a branch, use tag-{commit} as the tag
tag_name: process.env.GITHUB_REF.includes("refs/heads/") ? "tag-" + sha : process.env.GITHUB_REF.split("/").pop(),
target_commitish: sha
});
console.log('created release', { release });
for (let file of await fs.readdir('dist')) {
console.log('uploading', file);
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./dist/${file}`)
});
}