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.
This commit is contained in:
Yi Zhang 2023-04-04 20:21:05 +08:00 committed by GitHub
parent 5baf5f506b
commit b54ca9a041
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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