forked from johnterickson/cargo2junit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
208 lines (195 loc) · 7.96 KB
/
azure-pipelines.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Recommened editor for this file: https://github.com/Microsoft/azure-pipelines-vscode
schedules:
# run weekly to keep cache fresh
- cron: "0 0 * * 0"
branches:
include:
- master
always: true
variables:
CHANNEL: stable
CACHE_SALT: 1
RUSTCACHE_ROOT: $(Build.SourcesDirectory)/target
CARGO_DEPENDENCIES_FILE: $(Pipeline.Workspace)/Cargo.dependencies
CARGO_HOME: $(RUSTCACHE_ROOT)/rustcache/.cargo
RUSTUP_HOME: $(RUSTCACHE_ROOT)/rustcache/.rustup
SCCACHE_DIR: $(RUSTCACHE_ROOT)/rustcache/sccache
SCCACHE_CACHE_SIZE: 1G
CACHE_KEY_BASE: '"CACHE_SALT=$(CACHE_SALT)-$(VM_IMAGE)-$(CHANNEL)-$(TOOLS_TARGET)-$(TARGET)-ENABLE_SCCACHE=$(ENABLE_SCCACHE)"'
TOOLS_TARGET: $(TARGET)
POOL_NAME: ''
VM_IMAGE: ''
ENABLE_SCCACHE: 0
jobs:
- job: cached
pool:
name: $(POOL_NAME)
vmImage: $(VM_IMAGE)
strategy:
matrix:
vs2017-gnu:
TARGET: x86_64-pc-windows-gnu
TOOLS_TARGET: x86_64-pc-windows-msvc
VM_IMAGE: vs2017-win2016
vs2019-gnu:
TARGET: x86_64-pc-windows-gnu
TOOLS_TARGET: x86_64-pc-windows-msvc
VM_IMAGE: windows-2019
vs2019-gnu-sccache:
TARGET: x86_64-pc-windows-gnu
TOOLS_TARGET: x86_64-pc-windows-msvc
VM_IMAGE: windows-2019
ENABLE_SCCACHE: 1
vs2017-msvc:
TARGET: x86_64-pc-windows-msvc
VM_IMAGE: vs2017-win2016
vs2019-msvc:
TARGET: x86_64-pc-windows-msvc
VM_IMAGE: windows-2019
vs2019-msvc-sccache:
TARGET: x86_64-pc-windows-msvc
VM_IMAGE: windows-2019
ENABLE_SCCACHE: 1
osx-10.14-x86_64-apple-darwin:
TARGET: x86_64-apple-darwin
VM_IMAGE: macos-10.14
osx-10.14-x86_64-apple-darwin-sccache:
TARGET: x86_64-apple-darwin
VM_IMAGE: macos-10.14
ENABLE_SCCACHE: 1
x86_64-unknown-linux-gnu:
TARGET: x86_64-unknown-linux-gnu
VM_IMAGE: ubuntu-16.04
x86_64-unknown-linux-gnu-sccache:
TARGET: x86_64-unknown-linux-gnu
VM_IMAGE: ubuntu-16.04
ENABLE_SCCACHE: 1
steps:
- bash: |
echo "$(CARGO_DEPENDENCIES_FILE)"
echo "$CARGO_DEPENDENCIES_FILE"
grep checksum ./Cargo.lock > "$CARGO_DEPENDENCIES_FILE"
displayName: 'extract dependencies from cargo.lock'
# set up environment and restore cache
- bash: |
rm -Rf "$RUSTCACHE_ROOT"
echo "##vso[task.prependpath]$(CARGO_HOME)/bin"
displayName: clean state on private agents
- task: Cache@2
inputs:
key: '$(CACHE_KEY_BASE) | ./Cargo.toml | ./Cargo.lock | $(CARGO_DEPENDENCIES_FILE) | $(Build.SourceVersion)'
path: $(RUSTCACHE_ROOT)
cacheHitVar: CACHE_LOOKUP_RESULT
restoreKeys: |
$(CACHE_KEY_BASE) | ./Cargo.toml | ./Cargo.lock | $(CARGO_DEPENDENCIES_FILE)
$(CACHE_KEY_BASE) | ./Cargo.toml | ./Cargo.lock
$(CACHE_KEY_BASE) | ./Cargo.toml
$(CACHE_KEY_BASE)
# install tools (these will be cached)
- bash: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain none
which rustup && rustup -V
displayName: Enusure rustup is installed
condition: and(succeeded(), ne(variables['CACHE_LOOKUP_RESULT'], 'true'))
- bash: |
rustup toolchain install stable-$(TOOLS_TARGET)
rustup default stable-$(TOOLS_TARGET)
rustup update stable-$(TOOLS_TARGET)
which rustup && rustup -V && which cargo && cargo -V && which rustc && rustc -V
displayName: Select toolchain for tools (if updating the cache anyway)
condition: and(succeeded(), ne(variables['CACHE_LOOKUP_RESULT'], 'true'))
- bash: |
cargo install sccache
echo '##vso[task.setvariable variable=RUSTC_WRAPPER]sccache'
which sccache && sccache --version && sccache --show-stats
displayName: Install sccache (if updating the cache anyway)
condition: and(succeeded(), and(eq(variables['ENABLE_SCCACHE'], '1'),ne(variables['CACHE_LOOKUP_RESULT'], 'true')))
- bash: |
cargo install cargo2junit
displayName: Install cargo2junit (if updating the cache anyway)
condition: and(succeeded(), ne(variables['CACHE_LOOKUP_RESULT'], 'true'))
- bash: |
cargo install cargo-cache
cargo cache
displayName: Install cargo-cache (if updating the cache anyway)
condition: and(succeeded(), ne(variables['CACHE_LOOKUP_RESULT'], 'true'))
- bash: |
rustup toolchain install $(CHANNEL)-$(TARGET)
rustup default $(CHANNEL)-$(TARGET)
rustup update $(CHANNEL)-$(TARGET)
which rustup && rustup -V && which cargo && cargo -V && which rustc && rustc -V
displayName: Select toolchain for build
condition: and(succeeded(), ne(variables['CACHE_LOOKUP_RESULT'], 'true'))
# build and test
- bash: |
cargo build
displayName: cargo build
- bash: |
cargo test -- -Z unstable-options --format json | tee test_results_debug.json
displayName: cargo test
- bash: |
cargo build --release
displayName: cargo build --release
- bash: |
cargo test --release -- -Z unstable-options --format json | tee test_results_release.json
displayName: cargo test --release
# store test results
- bash: |
cat test_results_debug.json | cargo2junit > test_results_debug_lkg.xml
cat test_results_release.json | cargo2junit > test_results_release_lkg.xml
displayName: convert to junit using LKG cargo2junit
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'test_results_debug_lkg.xml'
testRunTitle: LKG_DEBUG_$(System.JobDisplayName)
buildPlatform: LKG_DEBUG_$(System.JobDisplayName)
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'test_results_release_lkg.xml'
testRunTitle: LKG_RELEASE_$(System.JobDisplayName)
buildPlatform: LKG_RELEASE_$(System.JobDisplayName)
condition: succeededOrFailed()
# self-host test of cargo2junit: store test results using the cargo2junit that was just built
- bash: |
cat test_results_debug.json | ./target/debug/cargo2junit > test_results_debug.xml
cat test_results_release.json | ./target/debug/cargo2junit > test_results_release.xml
displayName: convert to junit using just-built cargo2junit
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'test_results_debug.xml'
testRunTitle: DEBUG_$(System.JobDisplayName)
buildPlatform: DEBUG_$(System.JobDisplayName)
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'test_results_release.xml'
testRunTitle: RELEASE_$(System.JobDisplayName)
buildPlatform: RELEASE_$(System.JobDisplayName)
condition: succeededOrFailed()
# publish bits
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(RUSTCACHE_ROOT)/debug'
artifactName: '$(System.JobDisplayName)_debug'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(RUSTCACHE_ROOT)/release'
artifactName: '$(System.JobDisplayName)_release'
# some cleanup before the cache stores
- bash: |
sccache --show-stats
sccache --stop-server
displayName: shutdown sccache
condition: eq(variables['ENABLE_SCCACHE'], '1')
continueOnError: true
- bash: |
cargo cache
cargo cache --autoclean
cargo cache
displayName: run cargo cache --autoclean