name: "Linux WASM CI Reusable Workflow for build and test"
|
description: "This is a reusable workflow for Linux WASM CI pipelines to build and test"
|
|
on:
|
workflow_call:
|
inputs:
|
job_name: # workflow-scope unique key
|
required: true
|
type: string
|
build_config:
|
required: true
|
type: string
|
extra_build_args:
|
required: false
|
type: string
|
default: ""
|
skip_publish:
|
required: false
|
type: boolean
|
default: false
|
use_vcpkg:
|
required: false
|
type: boolean
|
default: true
|
enable_wasm_threads:
|
required: false
|
type: boolean
|
default: true
|
build_jsep:
|
required: false
|
type: boolean
|
default: false
|
build_webgpu:
|
required: false
|
type: boolean
|
default: false
|
build_webgpu_static_plugin:
|
required: false
|
type: boolean
|
default: false
|
|
jobs:
|
build-wasm:
|
runs-on: [
|
"self-hosted",
|
"1ES.Pool=onnxruntime-github-linux-large",
|
"JobId=build-wasm-${{inputs.job_name}}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
|
]
|
timeout-minutes: 120
|
env:
|
buildArch: x64
|
common_build_args: >-
|
--parallel
|
--use_cache
|
${{ inputs.use_vcpkg == true && '--use_vcpkg --use_vcpkg_ms_internal_asset_cache' || '' }}
|
--config ${{ inputs.build_config }}
|
--skip_submodule_sync
|
--build_wasm
|
--enable_wasm_simd
|
${{ inputs.enable_wasm_threads == true && '--enable_wasm_threads' || '' }}
|
${{ inputs.extra_build_args }}
|
reduced_size_build_args: >-
|
--disable_ml_ops
|
--disable_generation_ops
|
--disable_types string float4 float8 optional sparsetensor
|
--include_ops_by_config onnxruntime/wasm/reduced_types.config
|
--enable_reduced_operator_type_support
|
|
steps:
|
- name: Checkout code
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
with:
|
submodules: recursive
|
|
- name: Set up Node.js
|
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
with:
|
node-version: "24.x"
|
|
- name: Set up Python
|
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
with:
|
python-version: "3.12"
|
architecture: ${{ env.buildArch }}
|
|
- name: Install python dependencies
|
run: python -m pip install flatbuffers
|
|
- name: Setup CCache
|
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
|
with:
|
# Fully qualify by workflow. `actions/cache` does not isolate by workflow, unlike ADO cache actions.
|
key: ccache | web.yml | ${{ inputs.job_name }}
|
path: ~/.cache/ccache
|
|
- name: Setup VCPKG Cache
|
uses: ./.github/actions/setup-vcpkg-cache
|
with:
|
key: web-${{ inputs.job_name }}
|
|
- name: Get vcpkg tool info
|
id: vcpkg-tool-info
|
uses: ./.github/actions/get-vcpkg-tool-info
|
|
- uses: microsoft/onnxruntime-github-actions/setup-build-tools@8bad63a3c05d448311dfa8e5f531171c97471aa1 # v0.0.12
|
with:
|
ccache-version: 4.13.1
|
ccache-hash: 626407a9b81dd86f8ec9867bff396b32dd1f00344f5b323526579a64f6d4104927f83e8d7a05ad9806fd78f4491e0adb4cff73388000a62050cb1b00766214ee
|
vcpkg-version: ${{ steps.vcpkg-tool-info.outputs.release_tag }}
|
vcpkg-hash: ${{ steps.vcpkg-tool-info.outputs.sha512 }}
|
cmake-version: '3.31.6'
|
cmake-hash: '42395e20b10a8e9ef3e33014f9a4eed08d46ab952e02d2c1bbc8f6133eca0d7719fb75680f9bbff6552f20fcd1b73d86860f7f39388d631f98fb6f622b37cf04'
|
add-cmake-to-path: 'true'
|
disable-terrapin: 'true'
|
|
- name: Build (simd + threads)
|
run: |
|
python ./tools/ci_build/build.py \
|
${{ env.common_build_args }} \
|
--build_dir ${{ github.workspace }}/build/wasm_inferencing \
|
${{ inputs.build_config == 'Release' && '--enable_wasm_api_exception_catching' || '' }} \
|
--skip_tests
|
working-directory: ${{ github.workspace }}
|
|
- name: Build (simd + threads + JSEP)
|
if: ${{ inputs.build_jsep == true }}
|
run: |
|
python ./tools/ci_build/build.py \
|
${{ env.common_build_args }} \
|
--build_dir ${{ github.workspace }}/build/wasm_inferencing_jsep \
|
--use_jsep \
|
--use_webnn \
|
--target onnxruntime_webassembly \
|
${{ inputs.build_config == 'Release' && '--enable_wasm_api_exception_catching' || '' }} \
|
--skip_tests
|
working-directory: ${{ github.workspace }}
|
|
- name: Build (simd + threads + WebGPU experimental)
|
if: ${{ inputs.build_webgpu == true }}
|
run: |
|
python ./tools/ci_build/build.py \
|
${{ env.common_build_args }} \
|
--build_dir ${{ github.workspace }}/build/wasm_inferencing_webgpu \
|
--use_webgpu \
|
--use_webnn \
|
--target onnxruntime_webassembly \
|
${{ inputs.build_config == 'Release' && '--enable_wasm_api_exception_catching' || '' }} \
|
${{ env.reduced_size_build_args }} \
|
--skip_tests
|
working-directory: ${{ github.workspace }}
|
|
- name: Build (simd + threads + WebGPU experimental, JSPI)
|
if: ${{ inputs.build_webgpu == true }}
|
run: |
|
python ./tools/ci_build/build.py \
|
${{ env.common_build_args }} \
|
--build_dir ${{ github.workspace }}/build/wasm_inferencing_webgpu_jspi \
|
--use_webgpu \
|
--use_webnn \
|
--enable_wasm_jspi \
|
--target onnxruntime_webassembly \
|
${{ env.reduced_size_build_args }} \
|
--skip_tests
|
working-directory: ${{ github.workspace }}
|
|
# Build-only coverage for registering the WebGPU EP as a statically linked plugin EP under Emscripten.
|
# The output is deliberately not published: it has the same file names as the published WebGPU build, and
|
# the ORT Web test harness selects the wasm binary by file name, so both variants cannot ship together.
|
# This leg becomes redundant once the published WebGPU wasm build switches over to the plugin EP.
|
- name: Build (simd + threads + WebGPU experimental, static plugin EP)
|
if: ${{ inputs.build_webgpu_static_plugin == true }}
|
run: |
|
python ./tools/ci_build/build.py \
|
${{ env.common_build_args }} \
|
--build_dir ${{ github.workspace }}/build/wasm_inferencing_webgpu_static_plugin \
|
--use_webgpu static_plugin \
|
--use_webnn \
|
--target onnxruntime_webassembly \
|
${{ inputs.build_config == 'Release' && '--enable_wasm_api_exception_catching' || '' }} \
|
${{ env.reduced_size_build_args }} \
|
--skip_tests
|
working-directory: ${{ github.workspace }}
|
|
- name: Create Artifacts
|
if: ${{ inputs.skip_publish != true }}
|
run: |
|
mkdir -p ${{ github.workspace }}/artifacts/wasm/
|
cp ${{ github.workspace }}/build/wasm_inferencing/${{ inputs.build_config }}/ort-wasm-simd-threaded.wasm ${{ github.workspace }}/artifacts/wasm/
|
cp ${{ github.workspace }}/build/wasm_inferencing/${{ inputs.build_config }}/ort-wasm-simd-threaded.mjs ${{ github.workspace }}/artifacts/wasm/
|
if [ -d ${{ github.workspace }}/build/wasm_inferencing_jsep ]; then
|
cp ${{ github.workspace }}/build/wasm_inferencing_jsep/${{ inputs.build_config }}/ort-wasm-simd-threaded.jsep.wasm ${{ github.workspace }}/artifacts/wasm/
|
cp ${{ github.workspace }}/build/wasm_inferencing_jsep/${{ inputs.build_config }}/ort-wasm-simd-threaded.jsep.mjs ${{ github.workspace }}/artifacts/wasm/
|
fi
|
if [ -d ${{ github.workspace }}/build/wasm_inferencing_webgpu ]; then
|
cp ${{ github.workspace }}/build/wasm_inferencing_webgpu/${{ inputs.build_config }}/ort-wasm-simd-threaded.asyncify.wasm ${{ github.workspace }}/artifacts/wasm/
|
cp ${{ github.workspace }}/build/wasm_inferencing_webgpu/${{ inputs.build_config }}/ort-wasm-simd-threaded.asyncify.mjs ${{ github.workspace }}/artifacts/wasm/
|
fi
|
if [ -d ${{ github.workspace }}/build/wasm_inferencing_webgpu_jspi ]; then
|
cp ${{ github.workspace }}/build/wasm_inferencing_webgpu_jspi/${{ inputs.build_config }}/ort-wasm-simd-threaded.jspi.wasm ${{ github.workspace }}/artifacts/wasm/
|
cp ${{ github.workspace }}/build/wasm_inferencing_webgpu_jspi/${{ inputs.build_config }}/ort-wasm-simd-threaded.jspi.mjs ${{ github.workspace }}/artifacts/wasm/
|
fi
|
|
- name: Upload WASM artifacts
|
if: ${{ inputs.skip_publish != true }}
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
with:
|
name: ${{ inputs.build_config }}_wasm
|
path: ${{ github.workspace }}/artifacts/wasm
|
|
- name: Test (Node.js) (simd + threads)
|
# unit tests are currently only supported in Debug builds because they require exceptions, which are disabled in Release builds.
|
if: ${{ inputs.build_config == 'Debug' }}
|
run: |
|
python ./tools/ci_build/build.py \
|
${{ env.common_build_args }} \
|
--build_dir ${{ github.workspace }}/build/wasm_inferencing \
|
--test
|
working-directory: ${{ github.workspace }}
|
|
- name: Test (browser) (simd + threads)
|
# unit tests are currently only supported in Debug builds because they require exceptions, which are disabled in Release builds.
|
if: ${{ inputs.build_config == 'Debug' }}
|
run: |
|
python ./tools/ci_build/build.py \
|
${{ env.common_build_args }} \
|
--build_dir ${{ github.workspace }}/build/wasm_inferencing \
|
--wasm_run_tests_in_browser \
|
--targets onnxruntime_test_all onnxruntime_provider_test \
|
--update --build --test
|
working-directory: ${{ github.workspace }}
|
|
- name: Publish test results
|
if: ${{ always() && inputs.build_config == 'Debug' }}
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
with:
|
name: test-results
|
path: ${{ github.workspace }}/build/**/*.results.xml
|