diff --git a/tools/ci_build/github/azure-pipelines/mac-coreml-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/mac-coreml-ci-pipeline.yml index e2d9d03561..dd1793921c 100644 --- a/tools/ci_build/github/azure-pipelines/mac-coreml-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/mac-coreml-ci-pipeline.yml @@ -1,21 +1,34 @@ jobs: - job: CoreML_CI + workspace: + clean: all pool: vmImage: 'macOS-12' variables: MACOSX_DEPLOYMENT_TARGET: '10.14' + TODAY: $[format('{0:dd}{0:MM}{0:yyyy}', pipeline.startTime)] + CCACHE_DIR: '$(Pipeline.Workspace)/ccache' timeoutInMinutes: 120 steps: - script: brew install coreutils ninja displayName: Install coreutils and ninja - - script: | - python3 tools/ci_build/build.py \ - --build_dir build \ - --skip_submodule_sync \ - --cmake_generator=Ninja \ - --parallel \ - --build_shared_lib \ - --config Debug \ - --use_coreml - displayName: CoreML EP, Build and Test on macOS \ No newline at end of file + - template: templates/mac-build-step-with-cache.yml + parameters: + TODAY: $(TODAY) + AdditionalKey: coreml + CACHE_DIR: $(CCACHE_DIR) + BuildStep: + - script: | + python3 tools/ci_build/build.py \ + --build_dir build \ + --skip_submodule_sync \ + --cmake_generator=Ninja \ + --parallel \ + --build_shared_lib \ + --config Debug \ + --use_cache \ + --use_coreml + displayName: CoreML EP, Build and Test on macOS + env: + CCACHE_COMPILERCHECK: content diff --git a/tools/ci_build/github/azure-pipelines/templates/mac-build-step-with-cache.yml b/tools/ci_build/github/azure-pipelines/templates/mac-build-step-with-cache.yml new file mode 100644 index 0000000000..68fe83a52d --- /dev/null +++ b/tools/ci_build/github/azure-pipelines/templates/mac-build-step-with-cache.yml @@ -0,0 +1,42 @@ +# It's used for compilation with cache in Mac Host. + +parameters: +- name: TODAY + type: string + +- name: BuildStep + type: stepList + +- name: AdditionalKey + type: string + +- name: CACHE_DIR + type: string + +steps: + - script: | + brew install ccache + echo "##vso[task.prependpath]/usr/local/opt/ccache/libexec" + mkdir -p "${{ parameters.CACHE_DIR }}" + displayName: Install ccache and update PATH to use linked versions of gcc, cc, etc + + - task: Cache@2 + inputs: + key: ' "${{parameters.TODAY}}" | ${{parameters.AdditionalKey}} | "$(Build.SourceVersion)" ' + path: ${{ parameters.CACHE_DIR }} + restoreKeys: | + "${{parameters.TODAY}}" | ${{parameters.AdditionalKey}} + displayName: ccache task + + - ${{ parameters.BuildStep }} + + - script: | + set -ex + ccache -s + ccache -z + ls -l "${{ parameters.CACHE_DIR }}" + du -sh "${{ parameters.CACHE_DIR }}" + displayName: Show Cache stats and Clear stats. + env: + CCACHE_DIR: ${{parameters.CACHE_DIR}} + condition: always()