Add Mac CI GitHub Actions workflow (#20717)

Add a new GitHub Actions workflow, `.github/workflows/mac.yml`. It contains these jobs:
- ARM64 MacOS CI build.
- Objective-C static analysis build. This was moved over from another Azure DevOps pipeline to make it more visible.
This commit is contained in:
Edward Chen 2024-05-20 10:27:03 -07:00 committed by GitHub
parent ebed2c3785
commit fefae0cd04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 109 additions and 45 deletions

109
.github/workflows/mac.yml vendored Normal file
View file

@ -0,0 +1,109 @@
name: Mac_CI
on:
push:
branches:
- main
- rel-*
pull_request:
branches:
- main
- rel-*
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
python_version: 3.11
xcode_version: 15.2
jobs:
ARM64:
runs-on: macos-14
timeout-minutes: 60
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Verify ARM64 machine
shell: python
run: |
import platform
assert platform.machine() == "arm64", "This job expects to be run on an ARM64 machine."
- name: Use Xcode ${{ env.xcode_version }}
shell: bash
run: |
XCODE_DEVELOPER_DIR="/Applications/Xcode_${{ env.xcode_version }}.app/Contents/Developer"
sudo xcode-select --switch "${XCODE_DEVELOPER_DIR}"
- uses: actions/checkout@v4
- name: Build and test
shell: bash
run: |
python ./tools/ci_build/build.py \
--build_dir ./build \
--update \
--build --parallel \
--test \
--build_shared_lib \
--build_objc \
--use_xnnpack \
--use_binskim_compliant_compile_flags
# TODO add --use_coreml once unit test failures are addressed
Objective-C-StaticAnalysis:
runs-on: macos-14
timeout-minutes: 30
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Use Xcode ${{ env.xcode_version }}
shell: bash
run: |
XCODE_DEVELOPER_DIR="/Applications/Xcode_${{ env.xcode_version }}.app/Contents/Developer"
sudo xcode-select --switch "${XCODE_DEVELOPER_DIR}"
- uses: actions/checkout@v4
- name: Generate compile_commands.json and ONNX protobuf files
shell: bash
run: |
python ./tools/ci_build/build.py \
--build_dir ./build \
--cmake_generator "Unix Makefiles" \
--config Debug \
--build_shared_lib \
--use_coreml \
--build_objc \
--enable_training_apis \
--cmake_extra_defines CMAKE_EXPORT_COMPILE_COMMANDS=ON \
--use_binskim_compliant_compile_flags \
--update \
--build --parallel \
--target onnx_proto
- name: Analyze Objective-C/C++ source code
shell: bash
run: |
CLANG_TIDY_CHECKS="-*,clang-analyzer-*"
"$(brew --prefix llvm@15)/bin/clang-tidy" \
-p=./build/Debug \
--checks="${CLANG_TIDY_CHECKS}" \
--warnings-as-errors="${CLANG_TIDY_CHECKS}" \
--header-filter="objectivec/include|objectivec|onnxruntime/core" \
./objectivec/*.mm \
./onnxruntime/core/platform/apple/logging/apple_log_sink.mm \
./onnxruntime/core/providers/coreml/model/*.mm

View file

@ -1,45 +0,0 @@
jobs:
- job: ObjCStaticAnalysis
pool:
vmImage: 'macOS-latest'
timeoutInMinutes: 30
steps:
- checkout: self
clean: true
submodules: recursive
- task: UsePythonVersion@0
inputs:
versionSpec: "3.9"
addToPath: true
architecture: "x64"
- script: |
python tools/ci_build/build.py \
--build_dir "$(Build.BinariesDirectory)" \
--cmake_generator "Unix Makefiles" \
--config Debug \
--build_shared_lib --use_coreml --build_objc \
--enable_training_apis \
--cmake_extra_defines CMAKE_EXPORT_COMPILE_COMMANDS=ON \
--update --skip_submodule_sync \
--build --parallel --use_binskim_compliant_compile_flags --target onnx_proto
displayName: Generate compile_commands.json and ONNX protobuf files
- script: |
set -e
CLANG_TIDY_CHECKS="-*,clang-analyzer-*"
"$(brew --prefix llvm@15)/bin/clang-tidy" \
-p="$(Build.BinariesDirectory)/Debug" \
--checks="${CLANG_TIDY_CHECKS}" \
--warnings-as-errors="${CLANG_TIDY_CHECKS}" \
--header-filter="objectivec/include|objectivec|onnxruntime/core" \
./objectivec/*.mm \
./onnxruntime/core/platform/apple/logging/apple_log_sink.mm \
./onnxruntime/core/providers/coreml/model/*.mm
displayName: Analyze Objective-C/C++ source code