]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-115976: Add WASI to CI (GH-116516)
authorBrett Cannon <brett@python.org>
Mon, 11 Mar 2024 18:59:09 +0000 (11:59 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Mar 2024 18:59:09 +0000 (11:59 -0700)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
.github/workflows/build.yml
.github/workflows/reusable-wasi.yml [new file with mode: 0644]

index 20d1fad40ecafee47d96585deb5526a70cb3e56a..ae14046935b97bcc81433f297980e844f2c02d71 100644 (file)
@@ -301,6 +301,14 @@ jobs:
     - name: SSL tests
       run: ./python Lib/test/ssltests.py
 
+  build_wasi:
+    name: 'WASI'
+    needs: check_source
+    if: needs.check_source.outputs.run_tests == 'true'
+    uses: ./.github/workflows/reusable-wasi.yml
+    with:
+      config_hash: ${{ needs.check_source.outputs.config_hash }}
+
   test_hypothesis:
     name: "Hypothesis tests on Ubuntu"
     runs-on: ubuntu-20.04
@@ -525,6 +533,7 @@ jobs:
     - build_ubuntu
     - build_ubuntu_free_threading
     - build_ubuntu_ssltests
+    - build_wasi
     - build_windows
     - build_windows_free_threading
     - test_hypothesis
@@ -558,6 +567,7 @@ jobs:
             build_ubuntu,
             build_ubuntu_free_threading,
             build_ubuntu_ssltests,
+            build_wasi,
             build_windows,
             build_windows_free_threading,
             build_asan,
diff --git a/.github/workflows/reusable-wasi.yml b/.github/workflows/reusable-wasi.yml
new file mode 100644 (file)
index 0000000..995e669
--- /dev/null
@@ -0,0 +1,71 @@
+on:
+  workflow_call:
+    inputs:
+      config_hash:
+        required: true
+        type: string
+
+jobs:
+  build_wasi_reusable:
+    name: 'build and test'
+    timeout-minutes: 60
+    runs-on: ubuntu-20.04
+    env:
+      WASMTIME_VERSION: 18.0.2
+      WASI_SDK_VERSION: 20
+      WASI_SDK_PATH: /opt/wasi-sdk
+      CROSS_BUILD_PYTHON: cross-build/build
+      CROSS_BUILD_WASI: cross-build/wasm32-wasi
+    steps:
+    - uses: actions/checkout@v4
+    # No problem resolver registered as one doesn't currently exist for Clang.
+    - name: "Install wasmtime"
+      uses: jcbhmr/setup-wasmtime@v2
+      with:
+        wasmtime-version: ${{ env.WASMTIME_VERSION }}
+    - name: "Restore WASI SDK"
+      id: cache-wasi-sdk
+      uses: actions/cache@v4
+      with:
+        path: ${{ env.WASI_SDK_PATH }}
+        key: ${{ runner.os }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}
+    - name: "Install WASI SDK"
+      if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
+      run: |
+        mkdir ${{ env.WASI_SDK_PATH }} && \
+        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 | \
+        tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
+    - name: "Configure ccache action"
+      uses: hendrikmuhs/ccache-action@v1.2
+      with:
+        save: ${{ github.event_name == 'push' }}
+        max-size: "200M"
+    - name: "Add ccache to PATH"
+      run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
+    - name: "Install Python"
+      uses: actions/setup-python@v5
+      with:
+        python-version: '3.x'
+    - name: "Restore Python build config.cache"
+      uses: actions/cache@v4
+      with:
+        path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
+        key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
+    - name: "Configure build Python"
+      run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
+    - name: "Make build Python"
+      run: python3 Tools/wasm/wasi.py make-build-python
+    - name: "Restore host config.cache"
+      uses: actions/cache@v4
+      with:
+        path: ${{ env.CROSS_BUILD_WASI }}/config.cache
+        key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}-${{ inputs.config_hash }}
+    - name: "Configure host"
+      # `--with-pydebug` inferred from configure-build-python
+      run: python3 Tools/wasm/wasi.py configure-host -- --config-cache
+    - name: "Make host"
+      run: python3 Tools/wasm/wasi.py make-host
+    - name: "Display build info"
+      run: make --directory ${{ env.CROSS_BUILD_WASI }} pythoninfo
+    - name: "Test"
+      run: make --directory ${{ env.CROSS_BUILD_WASI }} test