29
29
- project : mithril-core
30
30
cargo_project_name : mithril
31
31
artifacts_pattern : libmithril
32
- skip_tests : true
33
32
- project : mithril-common
34
33
artifacts_pattern : libmithril_common
35
34
- project : mithril-client
74
73
toolchain : stable
75
74
override : true
76
75
76
+ - name : Rust Cache
77
+ uses : Swatinem/rust-cache@v2
78
+ with :
79
+ key : ${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}
80
+
81
+ - name : Cargo build
82
+ uses : actions-rs/cargo@v1
83
+ with :
84
+ command : build
85
+ args : --release --features portable -p ${{ env.CARGO_PROJECT_NAME }}
86
+
87
+ - name : Publish ${{ matrix.project }} (${{ runner.os }}-${{ runner.arch }})
88
+ uses : actions/upload-artifact@v3
89
+ with :
90
+ name : ${{ env.ARTIFACTS_BASE_NAME }}-${{ runner.os }}-${{ runner.arch }}
91
+ path : |
92
+ target/release/${{ env.ARTIFACTS_PATTERN }}*
93
+ if-no-files-found : error
94
+
95
+ test :
96
+ strategy :
97
+ fail-fast : false
98
+ matrix :
99
+ project : [
100
+ mithril-core,
101
+ mithril-common,
102
+ mithril-aggregator,
103
+ mithril-client,
104
+ mithril-signer,
105
+ mithril-test-lab/mithril-end-to-end,
106
+ demo/protocol-demo
107
+ ]
108
+ os : [ubuntu-22.04]
109
+
110
+ include :
111
+ - project : mithril-core
112
+ cargo_project_name : mithril
113
+ cargo-args : --release # Mithril core tests are ~2x quicker on release build
114
+ - project : mithril-common
115
+ - project : mithril-client
116
+ os : macos-latest
117
+ - project : mithril-client
118
+ os : windows-latest
119
+ - project : mithril-test-lab/mithril-end-to-end
120
+ cargo_project_name : mithril-end-to-end
121
+ artifacts_base_name : mithril-end-to-end
122
+ - project : demo/protocol-demo
123
+ cargo_project_name : mithrildemo
124
+ artifacts_base_name : mithrildemo
125
+ env :
126
+ CARGO_PROJECT_NAME : ${{ matrix.project }}
127
+ ARTIFACTS_BASE_NAME : ${{ matrix.project }}
128
+
129
+ runs-on : ${{ matrix.os }}
130
+
131
+ steps :
132
+ - name : Checkout sources
133
+ uses : actions/checkout@v3
134
+
135
+ - name : Overriding default $CARGO_PROJECT_NAME with matrix value
136
+ if : ${{ matrix.cargo_project_name }}
137
+ run : echo "CARGO_PROJECT_NAME=${{ matrix.cargo_project_name }}" >> $GITHUB_ENV
138
+
139
+ - name : Overriding default $ARTIFACTS_BASE_NAME with matrix value
140
+ if : ${{ matrix.artifacts_base_name }}
141
+ run : echo "ARTIFACTS_BASE_NAME=${{ matrix.artifacts_base_name }}" >> $GITHUB_ENV
142
+
143
+ - name : Install stable toolchain
144
+ uses : actions-rs/toolchain@v1
145
+ with :
146
+ profile : minimal
147
+ toolchain : stable
148
+ override : true
149
+
77
150
- name : Rust Cache
78
151
uses : Swatinem/rust-cache@v2
79
152
with :
@@ -84,37 +157,28 @@ jobs:
84
157
shell : bash
85
158
run : |
86
159
cargo install cargo2junit 2>/dev/null || true # Suppress the "binary `xyz` already exists in destination" error
87
-
160
+
88
161
- name : Cargo build
89
162
uses : actions-rs/cargo@v1
90
163
with :
91
164
command : build
92
- args : --release --all-targets -- features portable -p ${{ env.CARGO_PROJECT_NAME }}
165
+ args : --tests --features portable -p ${{ env.CARGO_PROJECT_NAME }} ${{ matrix.cargo-args }}
93
166
94
167
- name : Run tests
95
- if : ${{ matrix.skip_tests != true }}
96
168
shell : bash
97
169
run : |
98
170
set -o pipefail && \
99
- cargo test --release -- features portable -p $CARGO_PROJECT_NAME --no-fail-fast \
171
+ cargo test --features portable -p $CARGO_PROJECT_NAME --no-fail-fast ${{ matrix.cargo-args }} \
100
172
-- -Z unstable-options --format json --report-time \
101
- | tee >(cargo2junit > test-results-${{ env.ARTIFACTS_PATTERN }}-${{ runner.os }}-${{ runner.arch }}.xml)
173
+ | tee >(cargo2junit > test-results-${{ env.artifacts_base_name }}-${{ runner.os }}-${{ runner.arch }}.xml)
102
174
103
175
- name : Upload Tests Results
104
- if : ${{ always() && matrix.skip_tests != true }}
105
176
uses : actions/upload-artifact@v3
177
+ if : ${{ success() || failure() }}
106
178
with :
107
179
name : test-results-${{ env.ARTIFACTS_BASE_NAME }}-${{ runner.os }}-${{ runner.arch }}
108
180
path : |
109
181
./**/test-results-*.xml
110
-
111
- - name : Publish ${{ matrix.project }} (${{ runner.os }}-${{ runner.arch }})
112
- uses : actions/upload-artifact@v3
113
- with :
114
- name : ${{ env.ARTIFACTS_BASE_NAME }}-${{ runner.os }}-${{ runner.arch }}
115
- path : |
116
- target/release/${{ env.ARTIFACTS_PATTERN }}*
117
- if-no-files-found : error
118
182
119
183
check :
120
184
runs-on : ubuntu-22.04
@@ -164,54 +228,6 @@ jobs:
164
228
shell : bash
165
229
run : cargo sort -w -c
166
230
167
- test-mithril-core :
168
- runs-on : ubuntu-22.04
169
- if : ${{ github.event_name == 'push' }}
170
- needs : [ build ]
171
- steps :
172
- - name : Checkout sources
173
- uses : actions/checkout@v3
174
-
175
- - name : Install stable toolchain
176
- uses : actions-rs/toolchain@v1
177
- with :
178
- profile : minimal
179
- toolchain : stable
180
- override : true
181
-
182
- - name : Rust Cache
183
- uses : Swatinem/rust-cache@v2
184
- with :
185
- key : ${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}
186
-
187
- - name : Install cargo tools
188
- if : ${{ steps.cargo-cache.outputs.cache-hit == false }}
189
- run : |
190
- cargo install cargo2junit 2>/dev/null || true # Suppress the "binary `xyz` already exists in destination" error
191
-
192
- - name : Cargo build
193
- uses : actions-rs/cargo@v1
194
- with :
195
- command : build
196
- args : --release --tests --features portable -p mithril
197
-
198
- - name : Run tests
199
- if : ${{ matrix.skip_test != true }}
200
- shell : bash
201
- run : |
202
- set -o pipefail && \
203
- cargo test --release --features portable -p mithril --no-fail-fast \
204
- -- -Z unstable-options --format json --report-time \
205
- | tee >(cargo2junit > test-results-libmithril.xml-${{ runner.os }}-${{ runner.arch }}.xml)
206
-
207
- - name : Upload Tests Results
208
- if : ${{ always() && matrix.skip_test != true }}
209
- uses : actions/upload-artifact@v3
210
- with :
211
- name : test-results-mithril-core-${{ runner.os }}-${{ runner.arch }}
212
- path : |
213
- ./**/test-results-*.xml
214
-
215
231
run-test-lab :
216
232
runs-on : ubuntu-22.04
217
233
needs : [ build ]
@@ -268,66 +284,67 @@ jobs:
268
284
if-no-files-found : error
269
285
270
286
publish-tests-results :
271
- if : github.event.pull_request.draft == false && ${{ always () }}
287
+ if : github.event.pull_request.draft == false && ${{ success() || failure () }}
272
288
runs-on : ubuntu-22.04
273
- needs : [ test-mithril-core ]
289
+ needs :
290
+ - test
274
291
steps :
275
292
- name : Download mithril-core Tests Results
276
- if : always()
293
+ if : ${{ success() || failure() }}
277
294
uses : actions/download-artifact@v3
278
295
with :
279
296
name : test-results-mithril-core-${{ runner.os }}-${{ runner.arch }}
280
297
281
298
- name : Download mithril-common Tests Results
282
- if : always()
299
+ if : ${{ success() || failure() }}
283
300
uses : actions/download-artifact@v3
284
301
with :
285
302
name : test-results-mithril-common-${{ runner.os }}-${{ runner.arch }}
286
303
287
304
- name : Download mithril-aggregator Tests Results
288
- if : always()
305
+ if : ${{ success() || failure() }}
289
306
uses : actions/download-artifact@v3
290
307
with :
291
308
name : test-results-mithril-aggregator-${{ runner.os }}-${{ runner.arch }}
292
309
293
310
- name : Download mithril-client (${{ runner.os }}-${{ runner.arch }}) Tests Results
294
- if : always()
311
+ if : ${{ success() || failure() }}
295
312
uses : actions/download-artifact@v3
296
313
with :
297
314
name : test-results-mithril-client-${{ runner.os }}-${{ runner.arch }}
298
315
299
316
- name : Download mithril-client (macOS-X64) Tests Results
300
- if : always()
317
+ if : ${{ success() || failure() }}
301
318
uses : actions/download-artifact@v3
302
319
with :
303
320
name : test-results-mithril-client-macOS-X64
304
321
305
322
- name : Download mithril-client (Windows-X64) Tests Results
306
- if : always()
323
+ if : ${{ success() || failure() }}
307
324
uses : actions/download-artifact@v3
308
325
with :
309
326
name : test-results-mithril-client-Windows-X64
310
327
311
328
- name : Download mithril-signer Tests Results
312
- if : always()
329
+ if : ${{ success() || failure() }}
313
330
uses : actions/download-artifact@v3
314
331
with :
315
332
name : test-results-mithril-signer-${{ runner.os }}-${{ runner.arch }}
316
333
317
334
- name : Download mithril-end-to-end Tests Results
318
- if : always()
335
+ if : ${{ success() || failure() }}
319
336
uses : actions/download-artifact@v3
320
337
with :
321
338
name : test-results-mithril-end-to-end-${{ runner.os }}-${{ runner.arch }}
322
339
323
340
- name : Download mithril-demo Tests Results
324
- if : always()
341
+ if : ${{ success() || failure() }}
325
342
uses : actions/download-artifact@v3
326
343
with :
327
344
name : test-results-mithrildemo-${{ runner.os }}-${{ runner.arch }}
328
345
329
346
- name : Publish Unit Test Results
330
- if : always()
347
+ if : ${{ success() || failure() }}
331
348
uses : EnricoMi/publish-unit-test-result-action@v1
332
349
with :
333
350
files : ./**/test-results-*.xml
@@ -336,8 +353,9 @@ jobs:
336
353
runs-on : ubuntu-22.04
337
354
if : ${{ github.event_name == 'push' }}
338
355
needs :
356
+ - build
339
357
- check
340
- - test-mithril-core
358
+ - test
341
359
- run-test-lab
342
360
strategy :
343
361
fail-fast : false
@@ -394,7 +412,8 @@ jobs:
394
412
if : github.ref == 'refs/heads/main' && github.event_name == 'push'
395
413
runs-on : ubuntu-22.04
396
414
needs :
397
- - test-mithril-core
415
+ - build
416
+ - test
398
417
- run-test-lab
399
418
- check
400
419
steps :
0 commit comments