Skip to content

Commit 05070f4

Browse files
brettcannonhugovk
andauthored
GH-115976: Add WASI to CI (GH-116516)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 113053a commit 05070f4

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/build.yml

+10
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,14 @@ jobs:
301301
- name: SSL tests
302302
run: ./python Lib/test/ssltests.py
303303

304+
build_wasi:
305+
name: 'WASI'
306+
needs: check_source
307+
if: needs.check_source.outputs.run_tests == 'true'
308+
uses: ./.github/workflows/reusable-wasi.yml
309+
with:
310+
config_hash: ${{ needs.check_source.outputs.config_hash }}
311+
304312
test_hypothesis:
305313
name: "Hypothesis tests on Ubuntu"
306314
runs-on: ubuntu-20.04
@@ -525,6 +533,7 @@ jobs:
525533
- build_ubuntu
526534
- build_ubuntu_free_threading
527535
- build_ubuntu_ssltests
536+
- build_wasi
528537
- build_windows
529538
- build_windows_free_threading
530539
- test_hypothesis
@@ -558,6 +567,7 @@ jobs:
558567
build_ubuntu,
559568
build_ubuntu_free_threading,
560569
build_ubuntu_ssltests,
570+
build_wasi,
561571
build_windows,
562572
build_windows_free_threading,
563573
build_asan,

.github/workflows/reusable-wasi.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
config_hash:
5+
required: true
6+
type: string
7+
8+
jobs:
9+
build_wasi_reusable:
10+
name: 'build and test'
11+
timeout-minutes: 60
12+
runs-on: ubuntu-20.04
13+
env:
14+
WASMTIME_VERSION: 18.0.2
15+
WASI_SDK_VERSION: 20
16+
WASI_SDK_PATH: /opt/wasi-sdk
17+
CROSS_BUILD_PYTHON: cross-build/build
18+
CROSS_BUILD_WASI: cross-build/wasm32-wasi
19+
steps:
20+
- uses: actions/checkout@v4
21+
# No problem resolver registered as one doesn't currently exist for Clang.
22+
- name: "Install wasmtime"
23+
uses: jcbhmr/setup-wasmtime@v2
24+
with:
25+
wasmtime-version: ${{ env.WASMTIME_VERSION }}
26+
- name: "Restore WASI SDK"
27+
id: cache-wasi-sdk
28+
uses: actions/cache@v4
29+
with:
30+
path: ${{ env.WASI_SDK_PATH }}
31+
key: ${{ runner.os }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}
32+
- name: "Install WASI SDK"
33+
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
34+
run: |
35+
mkdir ${{ env.WASI_SDK_PATH }} && \
36+
curl -s -S --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ env.WASI_SDK_VERSION }}/wasi-sdk-${{ env.WASI_SDK_VERSION }}.0-linux.tar.gz | \
37+
tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
38+
- name: "Configure ccache action"
39+
uses: hendrikmuhs/[email protected]
40+
with:
41+
save: ${{ github.event_name == 'push' }}
42+
max-size: "200M"
43+
- name: "Add ccache to PATH"
44+
run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
45+
- name: "Install Python"
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: '3.x'
49+
- name: "Restore Python build config.cache"
50+
uses: actions/cache@v4
51+
with:
52+
path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
53+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
54+
- name: "Configure build Python"
55+
run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
56+
- name: "Make build Python"
57+
run: python3 Tools/wasm/wasi.py make-build-python
58+
- name: "Restore host config.cache"
59+
uses: actions/cache@v4
60+
with:
61+
path: ${{ env.CROSS_BUILD_WASI }}/config.cache
62+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}-${{ inputs.config_hash }}
63+
- name: "Configure host"
64+
# `--with-pydebug` inferred from configure-build-python
65+
run: python3 Tools/wasm/wasi.py configure-host -- --config-cache
66+
- name: "Make host"
67+
run: python3 Tools/wasm/wasi.py make-host
68+
- name: "Display build info"
69+
run: make --directory ${{ env.CROSS_BUILD_WASI }} pythoninfo
70+
- name: "Test"
71+
run: make --directory ${{ env.CROSS_BUILD_WASI }} test

0 commit comments

Comments
 (0)