From b54ca9a041b7d2baf870bd7301625f676d915066 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 4 Apr 2023 20:21:05 +0800 Subject: [PATCH] Read the cache in main build if it's a (Intermediate)merge branch. (#15330) ### Description In merge branch, the run only reads the cache generated in main build. As a result, each run in merge branch will not upload new cache except at the first time. ### Motivation and Context 1.Reduce the cache storage. If there's some big changes, devs should trigger the specific builds manually in https://dev.azure.com/onnxruntime/onnxruntime/_build. It still reads own branch cache. --- .../azure-pipelines/templates/mac-cpu-packing-jobs.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml b/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml index d646287ad2..411c2277e7 100644 --- a/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml +++ b/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml @@ -92,9 +92,13 @@ jobs: parameters: CacheDir: $(PROTO_CACHE_DIR) + # If it's a merge build, the run will read the cache generated by main build. - task: Cache@2 inputs: - key: ' "$(TODAY)" | ccache | onnxruntime | "$(Build.SourceVersion)" ' + ${{if eq(variables['Build.SourceBranchName'], 'merge')}}: + key: ' "$(TODAY)" | ccache | merge ' + ${{else}}: + key: ' "$(TODAY)" | ccache | onnxruntime | $(Build.SourceVersion) ' path: $(ORT_CACHE_DIR) restoreKeys: | "$(TODAY)" | ccache | onnxruntime