Skip to content

Commit 7561a70

Browse files
authored
Test 3.11, run test with -u all, improve WASI runner script (#80)
* Run test with -u all, improve WASI runner script * Build on Python 3.11, too * Create sentinel for getpath.py * Set date in env
1 parent 107ab35 commit 7561a70

File tree

4 files changed

+59
-36
lines changed

4 files changed

+59
-36
lines changed

.github/actions/prepare/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ runs:
1111
id: get-date
1212
shell: bash
1313
run: |
14-
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
14+
echo "TODAY=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_ENV
1515
- name: Get container cache
1616
id: container-cache
1717
uses: actions/cache@v1
1818
with:
1919
path: /tmp/container-cache
20-
key: image-cache-${{ steps.get-date.outputs.date }}
20+
key: image-cache-${{ env.TODAY }}
2121
- name: "Pull build image"
2222
if: ${{ steps.container-cache.outputs.cache-hit != 'true' }}
2323
shell: bash

.github/workflows/ci.yml

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,22 @@ on:
1717
required: false
1818

1919
jobs:
20+
pull-buildcontainer:
21+
name: "Pull & cache build container"
22+
runs-on: "ubuntu-latest"
23+
steps:
24+
- name: "checkout python-wasm"
25+
uses: "actions/checkout@v2"
26+
- name: "Common prepare step"
27+
uses: ./.github/actions/prepare
2028
build-python:
21-
name: "Build build Python"
29+
name: "Build build Python ${{ matrix.pythonbranch }}"
2230
runs-on: "ubuntu-latest"
31+
needs: pull-buildcontainer
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
pythonbranch: [main, 3.11]
2336
steps:
2437
- name: "checkout python-wasm"
2538
uses: "actions/checkout@v2"
@@ -28,7 +41,7 @@ jobs:
2841
with:
2942
repository: python/cpython
3043
path: cpython
31-
ref: main
44+
ref: ${{ matrix.pythonbranch }}
3245
- name: "Verify checkout"
3346
shell: bash
3447
run: |
@@ -42,25 +55,29 @@ jobs:
4255
uses: actions/cache@v2
4356
with:
4457
path: cpython
45-
key: cpython-${{ runner.os }}-${{ github.sha }}
58+
key: cpython-${{ matrix.pythonbranch }}-${{ runner.os }}-${{ env.TODAY }}-${{ github.sha }}
4659
emscripte-node:
47-
name: "Build Emscripten node"
60+
name: "Build Emscripten node ${{ matrix.pythonbranch }}"
4861
runs-on: "ubuntu-latest"
4962
needs: build-python
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
pythonbranch: [main, 3.11]
5067
steps:
5168
- name: "checkout python-wasm"
5269
uses: "actions/checkout@v2"
70+
- name: "Common prepare step"
71+
uses: ./.github/actions/prepare
5372
- name: "Fetch cached build Python"
5473
uses: actions/cache@v2
5574
with:
5675
path: cpython
57-
key: cpython-${{ runner.os }}-${{ github.sha }}
76+
key: cpython-${{ matrix.pythonbranch }}-${{ runner.os }}-${{ env.TODAY }}-${{ github.sha }}
5877
- name: "Check build Python"
5978
run: |
6079
test -e cpython/builddir/build/python || exit 1
6180
test -e cpython/configure || exit 2
62-
- name: "Common prepare step"
63-
uses: ./.github/actions/prepare
6481
- name: "Build emscripten Python for node"
6582
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./build-python-emscripten-node.sh
6683
- name: "Check artifacts"
@@ -70,11 +87,11 @@ jobs:
7087
- name: "Print test.pythoninfo"
7188
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./run-python-node.sh -m test.pythoninfo
7289
- name: "Run tests"
73-
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./test-emscripten-node.sh
90+
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./test-emscripten-node.sh -u all -W --slowest --fail-env-changed
7491
- name: "Upload node build artifacts"
7592
uses: actions/upload-artifact@v2
7693
with:
77-
name: emscripten-node
94+
name: emscripten-node-${{ matrix.pythonbranch }}
7895
path: |
7996
cpython/builddir/emscripten-node/python.wasm
8097
cpython/builddir/emscripten-node/python.worker.js
@@ -85,7 +102,7 @@ jobs:
85102
- name: "Upload build artifacts"
86103
uses: actions/upload-artifact@v2
87104
with:
88-
name: build-node
105+
name: build-node-${{ matrix.pythonbranch }}
89106
path: |
90107
cpython/builddir/emscripten-node/config.log
91108
cpython/builddir/emscripten-node/config.cache
@@ -100,23 +117,27 @@ jobs:
100117
cpython/builddir/emscripten-node/Programs/python.o
101118
if-no-files-found: error
102119
emscripte-browser:
103-
name: "Build Emscripten browser"
120+
name: "Build Emscripten browser ${{ matrix.pythonbranch }}"
104121
runs-on: "ubuntu-latest"
105122
needs: build-python
123+
strategy:
124+
fail-fast: false
125+
matrix:
126+
pythonbranch: [main, 3.11]
106127
steps:
107128
- name: "checkout python-wasm"
108129
uses: "actions/checkout@v2"
130+
- name: "Common prepare step"
131+
uses: ./.github/actions/prepare
109132
- name: "Fetch cached build Python"
110133
uses: actions/cache@v2
111134
with:
112135
path: cpython
113-
key: cpython-${{ runner.os }}-${{ github.sha }}
136+
key: cpython-${{ matrix.pythonbranch }}-${{ runner.os }}-${{ env.TODAY }}-${{ github.sha }}
114137
- name: "Check build Python"
115138
run: |
116139
test -e cpython/builddir/build/python || exit 1
117140
test -e cpython/configure || exit 2
118-
- name: "Common prepare step"
119-
uses: ./.github/actions/prepare
120141
- name: "Build emscripten Python for browser"
121142
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./build-python-emscripten-browser.sh
122143
- name: "Check artifacts"
@@ -127,7 +148,7 @@ jobs:
127148
- name: "Upload browser build artifacts"
128149
uses: actions/upload-artifact@v2
129150
with:
130-
name: emscripten-browser
151+
name: emscripten-browser-${{ matrix.pythonbranch }}
131152
path: |
132153
cpython/builddir/emscripten-browser/python.wasm
133154
cpython/builddir/emscripten-browser/python.html
@@ -138,7 +159,7 @@ jobs:
138159
- name: "Upload build artifacts"
139160
uses: actions/upload-artifact@v2
140161
with:
141-
name: build-browser
162+
name: build-browser-${{ matrix.pythonbranch }}
142163
path: |
143164
cpython/builddir/emscripten-browser/config.log
144165
cpython/builddir/emscripten-browser/config.cache
@@ -154,23 +175,27 @@ jobs:
154175
cpython/builddir/emscripten-browser/Programs/python.o
155176
if-no-files-found: error
156177
wasi:
157-
name: "Build WASI"
178+
name: "Build WASI ${{ matrix.pythonbranch }}"
158179
runs-on: "ubuntu-latest"
159180
needs: build-python
181+
strategy:
182+
fail-fast: false
183+
matrix:
184+
pythonbranch: [main, 3.11]
160185
steps:
161186
- name: "checkout python-wasm"
162187
uses: "actions/checkout@v2"
188+
- name: "Common prepare step"
189+
uses: ./.github/actions/prepare
163190
- name: "Fetch cached build Python"
164191
uses: actions/cache@v2
165192
with:
166193
path: cpython
167-
key: cpython-${{ runner.os }}-${{ github.sha }}
194+
key: cpython-${{ matrix.pythonbranch }}-${{ runner.os }}-${{ env.TODAY }}-${{ github.sha }}
168195
- name: "Check build Python"
169196
run: |
170197
test -e cpython/builddir/build/python || exit 1
171198
test -e cpython/configure || exit 2
172-
- name: "Common prepare step"
173-
uses: ./.github/actions/prepare
174199
- name: "Build WASI Python"
175200
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./build-python-wasi.sh
176201
- name: "Check artifacts"
@@ -180,13 +205,13 @@ jobs:
180205
- name: "Print test.pythoninfo"
181206
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./run-python-wasi.sh -m test.pythoninfo
182207
- name: "Run tests"
183-
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./test-wasi.sh
208+
run: docker run --rm -v $(pwd):/build -w /build quay.io/tiran/cpythonbuild:emsdk3 ./test-wasi.sh -u all -W --slowest --fail-env-changed
184209
# some WASI tests are failing
185210
continue-on-error: true
186211
- name: "Upload WASI artifacts"
187212
uses: actions/upload-artifact@v2
188213
with:
189-
name: wasi
214+
name: wasi-${{ matrix.pythonbranch }}
190215
path: |
191216
cpython/builddir/wasi/python.wasm
192217
cpython/builddir/wasi/pybuilddir.txt
@@ -195,7 +220,7 @@ jobs:
195220
- name: "Upload build artifacts"
196221
uses: actions/upload-artifact@v2
197222
with:
198-
name: build-wasi
223+
name: build-wasi-${{ matrix.pythonbranch }}
199224
path: |
200225
cpython/builddir/wasi/config.log
201226
cpython/builddir/wasi/config.cache
@@ -219,7 +244,7 @@ jobs:
219244
- uses: actions/checkout@v2
220245
- uses: actions/download-artifact@v2
221246
with:
222-
name: emscripten-browser
247+
name: emscripten-browser-main
223248
path: wasm
224249
- name: "Prepare artifacts for Github Pages"
225250
run: |

build-python-wasi.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi \
2525
--disable-ipv6
2626

2727
make -j$(nproc)
28-
29-
# XXX hack
30-
# Symlink pybuilddir.txt and build lib directory with sysconfig data into
31-
# VPATH root. "--mapdir .::../../" uses VPATH root as CWD.
32-
mkdir -p ../../build
33-
ln -srf -t ../../ pybuilddir.txt
34-
ln -srf -t ../../build/ build/lib.wasi-wasm32-3.*
35-
3628
popd
29+
30+
# sentinel for getpath.py
31+
touch cpython/Modules/Setup.local

run-python-wasi.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ set -e
33

44
export PATH="$PATH:/root/.wasmtime/bin"
55

6-
cd cpython/builddir/wasi
7-
exec wasmtime run --mapdir .::../../ -- python.wasm "$@"
6+
# PYTHONPATH is relative to mapped cpython/ directory.
7+
exec wasmtime run \
8+
--env PYTHONPATH=/builddir/wasi/$(cat cpython/builddir/wasi/pybuilddir.txt) \
9+
--mapdir /::cpython/ -- \
10+
cpython/builddir/wasi/python.wasm "$@"

0 commit comments

Comments
 (0)