2024-10-10 14:39:53 +02:00
|
|
|
name: Reusable WASI
|
|
|
|
|
2024-03-11 19:59:09 +01:00
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
config_hash:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build_wasi_reusable:
|
|
|
|
name: 'build and test'
|
|
|
|
timeout-minutes: 60
|
2024-11-06 00:29:21 +01:00
|
|
|
runs-on: ubuntu-24.04
|
2024-03-11 19:59:09 +01:00
|
|
|
env:
|
2024-07-10 00:02:25 +02:00
|
|
|
WASMTIME_VERSION: 22.0.0
|
2024-08-13 01:21:00 +02:00
|
|
|
WASI_SDK_VERSION: 24
|
2024-03-11 19:59:09 +01:00
|
|
|
WASI_SDK_PATH: /opt/wasi-sdk
|
|
|
|
CROSS_BUILD_PYTHON: cross-build/build
|
2024-11-07 22:40:56 +01:00
|
|
|
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
|
2024-03-11 19:59:09 +01:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
# No problem resolver registered as one doesn't currently exist for Clang.
|
|
|
|
- name: "Install wasmtime"
|
2024-07-10 00:02:25 +02:00
|
|
|
uses: bytecodealliance/actions/wasmtime/setup@v1
|
2024-03-11 19:59:09 +01:00
|
|
|
with:
|
2024-07-10 00:02:25 +02:00
|
|
|
version: ${{ env.WASMTIME_VERSION }}
|
2024-03-11 19:59:09 +01:00
|
|
|
- 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 }}
|
2024-11-07 22:40:56 +01:00
|
|
|
- name: "Install WASI SDK" # Hard-coded to x64.
|
2024-03-11 19:59:09 +01:00
|
|
|
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
|
|
|
|
run: |
|
|
|
|
mkdir ${{ env.WASI_SDK_PATH }} && \
|
2024-08-13 01:21:00 +02:00
|
|
|
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-x86_64-linux.tar.gz | \
|
2024-03-11 19:59:09 +01:00
|
|
|
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"
|
2024-10-28 19:59:35 +01:00
|
|
|
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
|
2024-03-11 19:59:09 +01:00
|
|
|
- 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
|
2024-07-10 00:02:25 +02:00
|
|
|
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python.
|
|
|
|
# Include the hash of `Tools/wasm/wasi.py` as it may change the environment variables.
|
|
|
|
# (Make sure to keep the key in sync with the other config.cache step below.)
|
|
|
|
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
|
2024-03-11 19:59:09 +01:00
|
|
|
- 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
|
2024-07-10 00:02:25 +02:00
|
|
|
# Should be kept in sync with the other config.cache step above.
|
|
|
|
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
|
2024-03-11 19:59:09 +01:00
|
|
|
- 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
|