|
| 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