From 6463f4383bb481498f30cd52de5f3bcd320e0dc5 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 10 Jan 2023 10:54:19 +0800 Subject: [PATCH] make WITHCACHE as an option in MacOS workflow (#14188) ### Description 1. Set the WithCache default value as false in Mac OS CI workflow too. 2. Add date of today in cache key to avoid cache size keep increasing too. WithCache, the pipeline duration reduced from 70 more minutes to 10 more minutes --- .../azure-pipelines/mac-ci-pipeline.yml | 3 ++- .../azure-pipelines/templates/mac-ci.yml | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/mac-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/mac-ci-pipeline.yml index bbb94c9d6f..8f7ef5a3ee 100644 --- a/tools/ci_build/github/azure-pipelines/mac-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/mac-ci-pipeline.yml @@ -3,4 +3,5 @@ jobs: parameters: AllowReleasedOpsetOnly: 0 BuildForAllArchs: false - AdditionalBuildFlags: --build_objc --enable_language_interop_ops --build_wheel \ No newline at end of file + AdditionalBuildFlags: --build_objc --enable_language_interop_ops --build_wheel + WithCache: true diff --git a/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml b/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml index 56bf153c00..280c321033 100644 --- a/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml @@ -17,6 +17,11 @@ parameters: displayName: Build for all CPU ARCHs type: boolean +- name: WithCache + displayName: Build with Cache + type: boolean + default: false + jobs: - job: MacOS_C_API_Packaging_CPU_x64 workspace: @@ -25,6 +30,7 @@ jobs: MACOSX_DEPLOYMENT_TARGET: '10.14' ALLOW_RELEASED_ONNX_OPSET_ONLY: ${{ parameters.AllowReleasedOpsetOnly }} CCACHE_DIR: $(Pipeline.Workspace)/ccache + TODAY: $[format('{0:dd}{0:MM}{0:yyyy}', pipeline.startTime)] pool: vmImage: 'macOS-11' timeoutInMinutes: 300 @@ -48,14 +54,16 @@ jobs: brew install ccache echo "##vso[task.prependpath]/usr/local/opt/ccache/libexec" displayName: Install ccache and update PATH to use linked versions of gcc, cc, etc + condition: eq(${{ parameters.WITHCACHE }}, true) - task: Cache@2 inputs: - key: 'ccache | "$(Agent.OS)" | protocol | "$(Build.SourceVersion)" ' + key: ' "$(TODAY)" | ccache | protocol | "$(Build.SourceVersion)" ' path: $(CCACHE_DIR) restoreKeys: | - ccache | "$(Agent.OS)" | protocol + "$(TODAY)" | ccache | protocol displayName: ccache protocol + condition: eq(${{ parameters.WITHCACHE }}, true) - script: | set -e -x @@ -73,14 +81,16 @@ jobs: ccache -s ccache -z displayName: Show Cache stats and Clear protolbuf stats. + condition: eq(${{ parameters.WITHCACHE }}, true) - task: Cache@2 inputs: - key: 'ccache | "$(Agent.OS)" | onnxruntime | "$(Build.SourceVersion)" ' + key: ' "$(TODAY)" | ccache | onnxruntime | "$(Build.SourceVersion)" ' path: $(CCACHE_DIR) restoreKeys: | - ccache | "$(Agent.OS)" | onnxruntime + "$(TODAY)" | ccache | onnxruntime displayName: ccache MacOS Build + condition: eq(${{ parameters.WITHCACHE }}, true) - ${{ if eq(parameters.BuildForAllArchs, true) }}: - template: mac-packaging.yml @@ -109,6 +119,7 @@ jobs: ccache -s ccache -z displayName: Show Cache stats + condition: eq(${{ parameters.WITHCACHE }}, true) - task: PublishPipelineArtifact@1 inputs: