-
Notifications
You must be signed in to change notification settings - Fork 30
372 lines (321 loc) · 12.9 KB
/
Copy pathmain.yml
File metadata and controls
372 lines (321 loc) · 12.9 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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
name: CI
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, labeled]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 3
# Increase this value to reset cache if emscripten_version has not changed
EMSDK_CACHE_FOLDER: "emsdk-cache"
EMSDK_CACHE_NUMBER: 0
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
# include tags so that hatch-vcs can infer the version
fetch-depth: 0
# switch to fetch-tags: true when the following is fixed
# see https://github.com/actions/checkout/issues/2041
# fetch-tags: true
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[resolve]" --group test
- name: Run tests
if: runner.os != 'Windows'
run: |
pytest \
--junitxml=test-results/junit.xml \
--cov=pyodide-build \
pyodide_build \
-m "not integration"
# The rest of the suite has never been run on Windows, so for now this
# is scoped to the tests that are specifically about Windows behaviour.
- name: Run tests marked with windows
if: runner.os == 'Windows'
run: pytest pyodide_build/tests/test_venv.py -m windows
- name: Upload coverage
# the Windows leg runs too little of the suite to be worth measuring
if: runner.os != 'Windows'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-no-integration-${{ matrix.os }}
path: .coverage
if-no-files-found: error
include-hidden-files: true
windows-integration-test:
runs-on: windows-latest
needs: [check-integration-test-trigger]
if: needs.check-integration-test-trigger.outputs.run-integration-test
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
- name: Install package
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Install xbuildenv and emscripten
run: |
pyodide xbuildenv install
pyodide xbuildenv install-emscripten
- name: Test emcc
run: |
$EMSDK_DIR = pyodide config get emsdk_dir
. "$EMSDK_DIR\emsdk_env.ps1"
$code = @"
#include <stdio.h>
int main() {
printf("emcc works\n");
return 0;
}
"@
$code | Out-File test.c
emcc test.c -o test.js
node test.js
check-integration-test-trigger:
name: test-integration-test-trigger
runs-on: ubuntu-latest
outputs:
run-integration-test: ${{ steps.check-integration-test-trigger.outputs.trigger }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- id: check-integration-test-trigger
name: Check integration test trigger
shell: bash
run: |
set -e -x
COMMIT_MSG=$(git log --no-merges -1 --oneline)
# The integration tests will be triggered on push or on pull_request, when:
# the commit message contains "[integration]", or
# if it is pushed to main branch, or
# if the PR has the "integration" label.
if [[ "$GITHUB_EVENT_NAME" == push && "$GITHUB_REF" == refs/heads/main ||
"$COMMIT_MSG" =~ \[integration\] ||
"${{ contains(github.event.pull_request.labels.*.name, 'integration') }}" == "true" ]]; then
echo "trigger=true" >> "$GITHUB_OUTPUT"
fi
integration-test:
name: integration-test (${{ matrix.task.name }}, ${{ matrix.task.installer }}, ${{ matrix.pyodide-version }}-pyodide, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [check-integration-test-trigger]
strategy:
fail-fast: false
matrix:
task: [
{ name: test-recipe, installer: pip },
{ name: test-src, installer: pip },
{ name: test-recipe, installer: uv },
{ name: test-src, installer: uv },
{ name: test-integration-marker, installer: pip }, # installer doesn't matter
]
# os: [ubuntu-latest, macos-latest] # FIXME: https://github.com/oracle/graal/issues/11855
os: [ubuntu-latest]
pyodide-version: [stable]
include:
# Run no-isolation tests and Pyodide minimum version testing only
# for the pip installer and on Linux
- task: {name: test-src-no-isolation, installer: pip} # installer doesn't matter
os: ubuntu-latest
pyodide-version: stable
- task: { name: test-recipe, installer: pip }
os: ubuntu-latest
pyodide-version: minimum
- task: { name: test-src, installer: pip }
os: ubuntu-latest
pyodide-version: minimum
- task: { name: test-src, installer: pip }
os: ubuntu-latest
pyodide-version: stable-debug
python-version: "3.14"
if: needs.check-integration-test-trigger.outputs.run-integration-test
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
# include tags so that hatch-vcs can infer the version
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version || '3.13' }}
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
- name: Install the package
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[uv]" --group test
- name: Install xbuildenv
run: |
if [[ "${{ matrix.pyodide-version }}" == "minimum" ]]; then
MIN_VERSION=$(pyodide xbuildenv search --json | jq -r '.environments | sort_by(.version) | .[0].version')
echo "Installing Pyodide xbuildenv version: $MIN_VERSION"
pyodide xbuildenv install $MIN_VERSION
elif [[ "${{ matrix.pyodide-version }}" == "stable-debug" ]]; then
pyodide xbuildenv install --debug
else
pyodide xbuildenv install
fi
echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
- name: Get number of cores on the runner
id: get-cores
run: echo "CORES=$(nproc)" >> $GITHUB_OUTPUT
- name: Run tests marked with integration
if: matrix.task.name == 'test-integration-marker'
run: |
pytest --junitxml=test-results/junit.xml --cov=pyodide-build pyodide_build -m "integration"
- name: Run the recipe integration tests (${{ matrix.task.name }})
if: matrix.task.name != 'test-integration-marker'
env:
PYODIDE_JOBS: ${{ steps.get-cores.outputs.CORES }}
working-directory: integration_tests
run: |
# https://github.com/pyodide/pyodide-build/issues/147
# disable package with scikit-build-core
if [[ ${{ matrix.os }} == "macos-latest" ]]; then
export RECIPE_BUILD_TARGET="*,!boost-histogram"
fi
if [[ "${{ matrix.task.installer }}" == "uv" ]]; then
export UV_RUN_PREFIX="uv run"
fi
make ${{ matrix.task.name }}
- name: Upload coverage for tests marked with integration
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: matrix.task.name == 'test-integration-marker'
with:
name: coverage-from-integration-${{ matrix.os }}
path: .coverage
if-no-files-found: error
include-hidden-files: true
test-venv:
name: test-venv (${{ matrix.os }}, ${{ matrix.python-source }})
runs-on: ${{ matrix.os }}
needs: [check-integration-test-trigger]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-source: [gha-python, uv-managed]
if: needs.check-integration-test-trigger.outputs.run-integration-test
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Setup Python
if: matrix.python-source == 'gha-python'
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: Set up uv
if: matrix.python-source == 'uv-managed'
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Set up a uv-managed Python
if: matrix.python-source == 'uv-managed'
shell: bash
env:
# never fall back to a system Python
UV_PYTHON_PREFERENCE: only-managed
run: |
set -ex
uv python install 3.13
# log the interpreter path, which on macOS is under Application Support
uv python find 3.13
# --seed gives us pip, which the steps below and the venv test need
uv venv --seed --python 3.13 .venv-uv-host
if [ "$RUNNER_OS" == "Windows" ]; then
echo "$GITHUB_WORKSPACE/.venv-uv-host/Scripts" >> "$GITHUB_PATH"
else
echo "$GITHUB_WORKSPACE/.venv-uv-host/bin" >> "$GITHUB_PATH"
fi
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"
- name: Install the package
run: |
python -m pip install --upgrade pip
python -m pip install -e . --group test
- name: Install xbuildenv
run: pyodide xbuildenv install
- name: Run venv test
working-directory: integration_tests
shell: bash -l {0}
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cmd //c scripts\\pyodide_venv_test.bat
else
./scripts/pyodide_venv_test.sh
fi
# Pyodide's python.exe launcher mangles the path to python.bat when it
# holds a space, so for now this runs somewhere without one.
# TODO: move this back to "C:\Program Files\pyodide venv test" when
# https://github.com/pyodide/pyodide/pull/6381 is released.
- name: Create a venv outside the workspace
if: runner.os == 'Windows'
shell: pwsh
run: |
$root = "C:\pyodide-venv-test"
New-Item -ItemType Directory -Force -Path $root | Out-Null
Set-Location $root
pyodide venv .venv-pyodide
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
.\.venv-pyodide\Scripts\pip.bat install pygments
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Get-ChildItem .\.venv-pyodide\Scripts
$script = Get-ChildItem .\.venv-pyodide\Scripts -Filter "pygmentize*" |
Select-Object -First 1
if (-not $script) { throw "pygmentize console script was not created" }
& $script.FullName -V
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
coverage:
name: Collect and upload coverage
runs-on: ubuntu-latest
needs: [test, integration-test]
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: coverage_files
pattern: coverage-*
merge-multiple: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: Combine coverage files
run: pipx install coverage && coverage combine --append coverage_files/**/.coverage
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
fail_ci_if_error: false
files: .coverage