|
| 1 | +name: "Linux WASM CI Reusable Workflow for build and test" |
| 2 | +description: "This is a reusable workflow for Linux WASM CI pipelines to build and test" |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + build_config: |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + extra_build_args: |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + default: "" |
| 14 | + skip_publish: |
| 15 | + required: false |
| 16 | + type: boolean |
| 17 | + default: false |
| 18 | + build_jsep: |
| 19 | + required: false |
| 20 | + type: boolean |
| 21 | + default: false |
| 22 | + build_webgpu: |
| 23 | + required: false |
| 24 | + type: boolean |
| 25 | + default: false |
| 26 | + |
| 27 | +jobs: |
| 28 | + build-wasm: |
| 29 | + runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"] |
| 30 | + env: |
| 31 | + buildArch: x64 |
| 32 | + common_build_args: --parallel --use_vcpkg --use_vcpkg_ms_internal_asset_cache --config ${{ inputs.build_config }} --skip_submodule_sync --build_wasm --enable_wasm_simd --enable_wasm_threads ${{ inputs.extra_build_args }} |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Checkout code |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + submodules: recursive |
| 39 | + |
| 40 | + - name: Set up Python |
| 41 | + uses: actions/setup-python@v4 |
| 42 | + with: |
| 43 | + python-version: "3.12" |
| 44 | + architecture: ${{ env.buildArch }} |
| 45 | + |
| 46 | + - name: Export GitHub Actions cache environment variables |
| 47 | + uses: actions/github-script@v7 |
| 48 | + with: |
| 49 | + script: | |
| 50 | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); |
| 51 | + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); |
| 52 | +
|
| 53 | + - name: Install EMSDK |
| 54 | + run: | |
| 55 | + set -ex |
| 56 | + cd ${{ github.workspace }}/cmake/external/emsdk |
| 57 | + ./emsdk install 4.0.4 |
| 58 | + ./emsdk activate 4.0.4 |
| 59 | +
|
| 60 | + - name: Build and test (browser) (simd + threads) |
| 61 | + run: | |
| 62 | + set -e -x |
| 63 | + source ${{ github.workspace }}/cmake/external/emsdk/emsdk_env.sh |
| 64 | + cd '${{ github.workspace }}' |
| 65 | + python ./tools/ci_build/build.py \ |
| 66 | + ${{ env.common_build_args }} \ |
| 67 | + --build_dir ${{ github.workspace }}/build/wasm_inferencing \ |
| 68 | + --wasm_run_tests_in_browser |
| 69 | +
|
| 70 | + - name: Build (simd + threads + JSEP) |
| 71 | + if: ${{ inputs.build_jsep == true }} |
| 72 | + run: | |
| 73 | + set -e -x |
| 74 | + source ${{ github.workspace }}/cmake/external/emsdk/emsdk_env.sh |
| 75 | + cd '${{ github.workspace }}' |
| 76 | + python ./tools/ci_build/build.py \ |
| 77 | + ${{ env.common_build_args }} \ |
| 78 | + --build_dir ${{ github.workspace }}/build/wasm_inferencing_jsep \ |
| 79 | + --use_jsep \ |
| 80 | + --use_webnn \ |
| 81 | + --target onnxruntime_webassembly \ |
| 82 | + --skip_tests |
| 83 | +
|
| 84 | + - name: Build (simd + threads + WebGPU experimental) |
| 85 | + if: ${{ inputs.build_webgpu == true }} |
| 86 | + run: | |
| 87 | + set -e -x |
| 88 | + source ${{ github.workspace }}/cmake/external/emsdk/emsdk_env.sh |
| 89 | + cd '${{ github.workspace }}' |
| 90 | + python ./tools/ci_build/build.py \ |
| 91 | + ${{ env.common_build_args }} \ |
| 92 | + --build_dir ${{ github.workspace }}/build/wasm_inferencing_webgpu \ |
| 93 | + --use_webgpu \ |
| 94 | + --use_jsep \ |
| 95 | + --use_webnn \ |
| 96 | + --target onnxruntime_webassembly \ |
| 97 | + --skip_tests |
| 98 | +
|
| 99 | + - name: Create Artifacts |
| 100 | + if: ${{ inputs.skip_publish != true }} |
| 101 | + run: | |
| 102 | + mkdir -p ${{ github.workspace }}/artifacts/wasm/ |
| 103 | + cp ${{ github.workspace }}/build/wasm_inferencing/${{ inputs.build_config }}/ort-wasm-simd-threaded.wasm ${{ github.workspace }}/artifacts/wasm/ |
| 104 | + cp ${{ github.workspace }}/build/wasm_inferencing/${{ inputs.build_config }}/ort-wasm-simd-threaded.mjs ${{ github.workspace }}/artifacts/wasm/ |
| 105 | + if [ -d ${{ github.workspace }}/build/wasm_inferencing_jsep ]; then |
| 106 | + cp ${{ github.workspace }}/build/wasm_inferencing_jsep/${{ inputs.build_config }}/ort-wasm-simd-threaded.jsep.wasm ${{ github.workspace }}/artifacts/wasm/ |
| 107 | + cp ${{ github.workspace }}/build/wasm_inferencing_jsep/${{ inputs.build_config }}/ort-wasm-simd-threaded.jsep.mjs ${{ github.workspace }}/artifacts/wasm/ |
| 108 | + fi |
| 109 | +
|
| 110 | + - name: Create WebGPU Artifacts |
| 111 | + if: ${{ inputs.skip_publish != true && inputs.build_webgpu == true }} |
| 112 | + run: | |
| 113 | + mkdir -p ${{ github.workspace }}/artifacts/wasm_webgpu/ |
| 114 | + cp ${{ github.workspace }}/build/wasm_inferencing_webgpu/${{ inputs.build_config }}/ort-wasm-simd-threaded.jsep.wasm ${{ github.workspace }}/artifacts/wasm_webgpu/ |
| 115 | + cp ${{ github.workspace }}/build/wasm_inferencing_webgpu/${{ inputs.build_config }}/ort-wasm-simd-threaded.jsep.mjs ${{ github.workspace }}/artifacts/wasm_webgpu/ |
| 116 | +
|
| 117 | + - name: Upload WASM artifacts |
| 118 | + if: ${{ inputs.skip_publish != true }} |
| 119 | + uses: actions/upload-artifact@v4 |
| 120 | + with: |
| 121 | + name: ${{ inputs.build_config }}_wasm |
| 122 | + path: ${{ github.workspace }}/artifacts/wasm |
| 123 | + |
| 124 | + - name: Upload WebGPU artifacts |
| 125 | + if: ${{ inputs.skip_publish != true && inputs.build_webgpu == true }} |
| 126 | + uses: actions/upload-artifact@v4 |
| 127 | + with: |
| 128 | + name: ${{ inputs.build_config }}_wasm_webgpu |
| 129 | + path: ${{ github.workspace }}/artifacts/wasm_webgpu |
| 130 | + |
| 131 | + - name: Publish test results |
| 132 | + if: ${{ always() && inputs.build_config == 'Debug' }} |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: test-results |
| 136 | + path: ${{ github.workspace }}/build/**/*.results.xml |
0 commit comments