Skip to content

Commit 47a6b4a

Browse files
committed
Move tests in a seperate CI job
1 parent a762609 commit 47a6b4a

File tree

1 file changed

+96
-77
lines changed

1 file changed

+96
-77
lines changed

.github/workflows/ci.yml

Lines changed: 96 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
- project: mithril-core
3030
cargo_project_name: mithril
3131
artifacts_pattern: libmithril
32-
skip_tests: true
3332
- project: mithril-common
3433
artifacts_pattern: libmithril_common
3534
- project: mithril-client
@@ -74,6 +73,80 @@ jobs:
7473
toolchain: stable
7574
override: true
7675

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+
77150
- name: Rust Cache
78151
uses: Swatinem/rust-cache@v2
79152
with:
@@ -84,37 +157,28 @@ jobs:
84157
shell: bash
85158
run: |
86159
cargo install cargo2junit 2>/dev/null || true # Suppress the "binary `xyz` already exists in destination" error
87-
160+
88161
- name: Cargo build
89162
uses: actions-rs/cargo@v1
90163
with:
91164
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 }}
93166

94167
- name: Run tests
95-
if: ${{ matrix.skip_tests != true }}
96168
shell: bash
97169
run: |
98170
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 }} \
100172
-- -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)
102174
103175
- name: Upload Tests Results
104-
if: ${{ always() && matrix.skip_tests != true }}
105176
uses: actions/upload-artifact@v3
177+
if: ${{ success() || failure() }}
106178
with:
107179
name: test-results-${{ env.ARTIFACTS_BASE_NAME }}-${{ runner.os }}-${{ runner.arch }}
108180
path: |
109181
./**/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
118182
119183
check:
120184
runs-on: ubuntu-22.04
@@ -164,54 +228,6 @@ jobs:
164228
shell: bash
165229
run: cargo sort -w -c
166230

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-
215231
run-test-lab:
216232
runs-on: ubuntu-22.04
217233
needs: [ build ]
@@ -268,66 +284,67 @@ jobs:
268284
if-no-files-found: error
269285

270286
publish-tests-results:
271-
if: github.event.pull_request.draft == false && ${{ always() }}
287+
if: github.event.pull_request.draft == false && ${{ success() || failure() }}
272288
runs-on: ubuntu-22.04
273-
needs: [ test-mithril-core ]
289+
needs:
290+
- test
274291
steps:
275292
- name: Download mithril-core Tests Results
276-
if: always()
293+
if: ${{ success() || failure() }}
277294
uses: actions/download-artifact@v3
278295
with:
279296
name: test-results-mithril-core-${{ runner.os }}-${{ runner.arch }}
280297

281298
- name: Download mithril-common Tests Results
282-
if: always()
299+
if: ${{ success() || failure() }}
283300
uses: actions/download-artifact@v3
284301
with:
285302
name: test-results-mithril-common-${{ runner.os }}-${{ runner.arch }}
286303

287304
- name: Download mithril-aggregator Tests Results
288-
if: always()
305+
if: ${{ success() || failure() }}
289306
uses: actions/download-artifact@v3
290307
with:
291308
name: test-results-mithril-aggregator-${{ runner.os }}-${{ runner.arch }}
292309

293310
- name: Download mithril-client (${{ runner.os }}-${{ runner.arch }}) Tests Results
294-
if: always()
311+
if: ${{ success() || failure() }}
295312
uses: actions/download-artifact@v3
296313
with:
297314
name: test-results-mithril-client-${{ runner.os }}-${{ runner.arch }}
298315

299316
- name: Download mithril-client (macOS-X64) Tests Results
300-
if: always()
317+
if: ${{ success() || failure() }}
301318
uses: actions/download-artifact@v3
302319
with:
303320
name: test-results-mithril-client-macOS-X64
304321

305322
- name: Download mithril-client (Windows-X64) Tests Results
306-
if: always()
323+
if: ${{ success() || failure() }}
307324
uses: actions/download-artifact@v3
308325
with:
309326
name: test-results-mithril-client-Windows-X64
310327

311328
- name: Download mithril-signer Tests Results
312-
if: always()
329+
if: ${{ success() || failure() }}
313330
uses: actions/download-artifact@v3
314331
with:
315332
name: test-results-mithril-signer-${{ runner.os }}-${{ runner.arch }}
316333

317334
- name: Download mithril-end-to-end Tests Results
318-
if: always()
335+
if: ${{ success() || failure() }}
319336
uses: actions/download-artifact@v3
320337
with:
321338
name: test-results-mithril-end-to-end-${{ runner.os }}-${{ runner.arch }}
322339

323340
- name: Download mithril-demo Tests Results
324-
if: always()
341+
if: ${{ success() || failure() }}
325342
uses: actions/download-artifact@v3
326343
with:
327344
name: test-results-mithrildemo-${{ runner.os }}-${{ runner.arch }}
328345

329346
- name: Publish Unit Test Results
330-
if: always()
347+
if: ${{ success() || failure() }}
331348
uses: EnricoMi/publish-unit-test-result-action@v1
332349
with:
333350
files: ./**/test-results-*.xml
@@ -336,8 +353,9 @@ jobs:
336353
runs-on: ubuntu-22.04
337354
if: ${{ github.event_name == 'push' }}
338355
needs:
356+
- build
339357
- check
340-
- test-mithril-core
358+
- test
341359
- run-test-lab
342360
strategy:
343361
fail-fast: false
@@ -394,7 +412,8 @@ jobs:
394412
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
395413
runs-on: ubuntu-22.04
396414
needs:
397-
- test-mithril-core
415+
- build
416+
- test
398417
- run-test-lab
399418
- check
400419
steps:

0 commit comments

Comments
 (0)