-
Notifications
You must be signed in to change notification settings - Fork 1
/
cached.yml
89 lines (76 loc) · 3.01 KB
/
cached.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
parameters:
- name: arch
type: string
default: ""
- name: version
type: string
default: $(cacheKeyVersion)
- name: cacheName
type: string
default:
- name: keyDocker
type: string
default: $(cacheKeyDocker)
- name: keyBazel
type: string
default: $(cacheKeyBazel)
- name: pathTemp
type: string
default: $(pathCacheTemp)
- name: tmpfsDisabled
type: string
default:
- name: tmpfsDockerDisabled
type: string
default:
- name: pathDockerBind
type: string
default: $(pathDockerBind)
- name: cacheTimeoutWorkaround
type: number
default: 5
- name: prime
type: boolean
default: false
steps:
- script: sudo .azure-pipelines/docker/prepare_cache.sh "${{ parameters.pathTemp }}" "${{ parameters.tmpfsDisabled }}"
displayName: "Cache/prepare"
- task: Cache@2
condition: and(not(canceled()), ne('${{ parameters.cacheName }}', ''))
env:
VSO_DEDUP_REDIRECT_TIMEOUT_IN_SEC: "${{ parameters.cacheTimeoutWorkaround }}"
displayName: "Cache (${{ parameters.cacheName }})"
inputs:
key: '${{ parameters.cacheName }} | "${{ parameters.version }}" | "${{ parameters.arch }}" | ${{ parameters.keyDocker }} | ${{ parameters.keyBazel }}'
path: "${{ parameters.pathTemp }}/all"
cacheHitVar: CACHE_RESTORED
- task: Cache@2
condition: and(not(canceled()), not(failed()), or(ne(variables.CACHE_RESTORED, 'true'), eq('${{ parameters.cacheName }}', '')))
env:
VSO_DEDUP_REDIRECT_TIMEOUT_IN_SEC: "${{ parameters.cacheTimeoutWorkaround }}"
displayName: "Cache (Docker)"
inputs:
key: '"${{ parameters.version }}" | "${{ parameters.arch }}" | ${{ parameters.keyDocker }} | docker'
path: "${{ parameters.pathTemp }}/docker"
cacheHitVar: DOCKER_CACHE_RESTORED
- task: Cache@2
condition: and(not(canceled()), not(failed()), or(ne(variables.CACHE_RESTORED, 'true'), eq('${{ parameters.cacheName }}', '')))
env:
VSO_DEDUP_REDIRECT_TIMEOUT_IN_SEC: "${{ parameters.cacheTimeoutWorkaround }}"
displayName: "Cache (Bazel)"
inputs:
key: '"${{ parameters.version }}" | "${{ parameters.arch }}" | ${{ parameters.keyBazel }} | bazel'
path: "${{ parameters.pathTemp }}/bazel"
cacheHitVar: BAZEL_CACHE_RESTORED
# Prime the caches for all jobs
- script: .azure-pipelines/docker/prime_cache.sh "$(Build.StagingDirectory)" "${{ parameters.pathTemp }}" "${{ parameters.arch }}"
env:
DOCKER_RESTORED: $(DOCKER_CACHE_RESTORED)
BAZEL_RESTORED: $(BAZEL_CACHE_RESTORED)
displayName: "Cache/prime (Docker/Bazel)"
# TODO(phlax): figure if there is a way to test cache without downloading it
condition: and(not(canceled()), eq(${{ parameters.prime }}, true), eq('${{ parameters.cacheName }}', ''), or(ne(variables.DOCKER_CACHE_RESTORED, 'true'), ne(variables.BAZEL_CACHE_RESTORED, 'true')))
# Load the caches for a job
- script: sudo .azure-pipelines/docker/load_caches.sh "$(Build.StagingDirectory)" "${{ parameters.pathTemp }}" "${{ parameters.pathDockerBind }}" "${{ parameters.tmpfsDockerDisabled }}"
displayName: "Cache/restore"
condition: and(not(canceled()), eq(${{ parameters.prime }}, false))