name: "macOS CI Reusable Workflow for build and test" description: "This is a reusable workflow for macOS CI pipelines to build and test" on: workflow_call: inputs: use_webgpu: required: false type: boolean default: false use_xnnpack: required: false type: boolean default: false use_coreml: required: false type: boolean default: false python_version: required: false type: string default: "3.14" matrix_include: required: false type: string description: "JSON string specifying combinations to include in the matrix" # we do not have enough resources to run all combinations # Include arm64 + Debug combination by default default: >- [ {"machine": "arm64", "target": "arm64", "build_config": "Debug"} ] jobs: build-and-test: strategy: matrix: # To avoid creating too many jobs, we explicitly specify the combinations to run. # # # Specify the machine architecture to run the build on. # machine: ["x86_64", "arm64"] # # # Specify the target architecture for the build. # target: ["x86_64", "arm64"] # # # Specify the build configuration for the build. # build_config: ["Debug", "Release"] # include: ${{ fromJSON(inputs.matrix_include) }} # "macos-15" is an arm64 image. # see also: https://github.com/actions/runner-images/blob/main/README.md runs-on: ${{ matrix.machine == 'x86_64' && 'macos-15-intel' || 'macos-15' }} timeout-minutes: 120 env: build_flags: > --build_dir ./build --skip_submodule_sync --parallel --use_binskim_compliant_compile_flags --build_shared_lib --build_nodejs --build_objc --build_java --build_wheel ${{ matrix.target == 'arm64' && '--enable_arm_neon_nchwc' || '' }} ${{ inputs.use_webgpu && '--use_webgpu' || '' }} ${{ inputs.use_xnnpack && '--use_xnnpack' || '' }} ${{ inputs.use_coreml && '--use_coreml --skip_onnx_tests' || '' }} --use_vcpkg --use_vcpkg_ms_internal_asset_cache --config ${{ matrix.build_config }} --osx_arch ${{ matrix.target }} # A matrix entry may override the Xcode version via "xcode_version"; otherwise fall back to the default. # The Xcode version needs to be present on the image specified in the "runs-on" configuration. xcode_version: ${{ matrix.xcode_version || '26.3' }} steps: - name: Checkout code uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Setup VCPKG Cache uses: ./.github/actions/setup-vcpkg-cache with: key: >- ${{ format( 'macos-{0}-{1}-{2}-xcode-{3}-coreml-{4}-xnnpack-{5}-webgpu-{6}', matrix.machine, matrix.target, matrix.build_config, env.xcode_version, inputs.use_coreml, inputs.use_xnnpack, inputs.use_webgpu ) }} - name: Get vcpkg tool info id: vcpkg-tool-info uses: ./.github/actions/get-vcpkg-tool-info - uses: microsoft/onnxruntime-github-actions/setup-build-tools@d19341fb036c43a947a2c0e4a53ad4d15e10bc5c # v0.0.9 with: vcpkg-version: ${{ steps.vcpkg-tool-info.outputs.release_tag }} vcpkg-hash: ${{ steps.vcpkg-tool-info.outputs.sha512 }} cmake-version: '3.31.8' cmake-hash: 99cc9c63ae49f21253efb5921de2ba84ce136018abf08632c92c060ba91d552e0f6acc214e9ba8123dee0cf6d1cf089ca389e321879fd9d719a60d975bcffcc8 add-cmake-to-path: 'true' disable-terrapin: 'true' - name: macOS CI pipeline prepare steps uses: ./.github/actions/macos-ci-setup with: platform_machine: ${{ matrix.machine }} python_version: ${{ inputs.python_version }} xcode_version: ${{ env.xcode_version }} use_cache: true - uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0 id: onnx-node-tests-cache with: path: ${{ github.workspace }}/js/test/ key: onnxnodetests-${{ hashFiles('js/scripts/prepare-onnx-node-tests.ts') }} - name: Setup environment variables shell: bash run: | set -e -x export PATH=${{ github.workspace }}/build/installed/bin:$PATH export ONNX_ML=1 export CMAKE_ARGS="-DONNX_GEN_PB_TYPE_STUBS=ON -DONNX_WERROR=OFF" python -m pip install -r '${{ github.workspace }}/tools/ci_build/github/linux/docker/scripts/requirements.txt' - name: Configure Build (build.py --update) shell: bash working-directory: ${{ github.workspace }} run: | rm -rf ${{ github.workspace }}/build/${{ matrix.build_config }} python ./tools/ci_build/build.py --update ${{ env.build_flags }} - name: Build (build.py --build) shell: bash working-directory: ${{ github.workspace }} run: | python ./tools/ci_build/build.py --build ${{ env.build_flags }} - name: Install shell: bash run: | set -e -x rm -rf ${{ github.workspace }}/build/installed cd ${{ github.workspace }}/build/${{ matrix.build_config }} make install DESTDIR=${{ github.workspace }}/build/installed - name: Running Tests (build.py --test) # Skip tests when cross-compiling if: ${{ matrix.machine == matrix.target }} shell: bash working-directory: ${{ github.workspace }} run: | python ./tools/ci_build/build.py --test ${{ env.build_flags }} - name: WebGPU GEMV correctness (Metal) if: ${{ inputs.use_webgpu && matrix.machine == matrix.target }} shell: bash working-directory: ${{ github.workspace }}/build/${{ matrix.build_config }} env: PYTHONPATH: ${{ github.workspace }}/build/${{ matrix.build_config }} run: | python - <<'PY' import onnxruntime as ort assert any(device.ep_name == "WebGpuExecutionProvider" for device in ort.get_ep_devices()), \ "A WebGPU device is required for GEMV CI; skipping is not allowed." PY python -m pytest -v transformers/test_webgpu_matmul.py