44on : [push]
55
66jobs :
7- build-mithril-core :
7+ build :
88 if : github.event.pull_request.draft == false
99 runs-on : ubuntu-latest
1010 steps :
@@ -20,76 +20,40 @@ jobs:
2020 override : true
2121
222223- name : Cache mithril-core/ Cargo.lock
23+ name : Cache Cargo.lock
2424 with :
2525 path : |
2626 ~/.cargo/registry
2727 ~/.cargo/git
28- mithril-core/ target
29- key : ${{ runner.os }}-${{ hashFiles('mithril-core/ Cargo.lock') }}
28+ target/
29+ key : ${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
3030 restore-keys : |
31- ${{ runner.os }}-key
31+ ${{ runner.os }}-key
3232
3333 - name : Cargo build
3434 uses : actions-rs/cargo@v1
3535 with :
3636 command : build
37- args : --release --manifest-path ./mithril-core/Cargo.toml
38-
39- - name : Cargo check
40- uses : actions-rs/cargo@v1
41- with :
42- command : check
43- args : --release --all-targets --manifest-path ./mithril-core/Cargo.toml
44-
45- - name : Cargo fmt
46- uses : actions-rs/cargo@v1
47- with :
48- command : fmt
49- args : --all --manifest-path ./mithril-core/Cargo.toml -- --check
50-
51- - name : Clippy Check
52- uses : actions-rs/clippy-check@v1
53- with :
54- name : clippy-mithril-core
55- token : ${{ secrets.GITHUB_TOKEN }}
56- args : --manifest-path ./mithril-core/Cargo.toml --all-features
57-
58- - name : Compile benchmarks
59- uses : actions-rs/cargo@v1
60- continue-on-error : false
61- with :
62- command : bench
63- args : --no-run --locked --manifest-path ./mithril-core/Cargo.toml
64-
65- - name : Mithril Core / Generate doc
66- uses : actions-rs/cargo@v1
67- with :
68- command : doc
69- args : --no-deps --release --manifest-path ./mithril-core/Cargo.toml
70-
71- - name : Publish libmithril
72- uses : actions/upload-artifact@v3
73- with :
74- name : libmithril
75- if-no-files-found : error
76- path : |
77- mithril-core/target/release/libmithril.so
78- mithril-core/target/include/mithril.h
79-
80- - name : Publish libmithril-doc
81- uses : actions/upload-artifact@v3
82- with :
83- name : libmithril-doc
84- if-no-files-found : error
85- path : |
86- mithril-core/target/doc/
87-
88- test-mithril-core :
37+ args : --release --workspace --all-targets
38+
39+ upload-artifacts :
8940 if : github.event.pull_request.draft == false
90- needs :
91- - build-mithril-core
9241 runs-on : ubuntu-latest
42+ needs : [ build ]
43+ strategy :
44+ fail-fast : false
45+ matrix :
46+ project :
47+ - name : mithril-core
48+ artefacts_pattern : libmithril
49+ - name : mithril-common
50+ artefacts_pattern : libmithril_common
51+ - name : mithril-aggregator
52+ artefacts_pattern : mithril-aggregator
53+ - name : mithril-client
54+ artefacts_pattern : mithril-client
55+ - name : mithril-signer
56+ artefacts_pattern : mithril-signer
9357 steps :
9458 - name : Checkout sources
9559 uses : actions/checkout@v2
@@ -103,58 +67,46 @@ jobs:
10367 override : true
10468
10569106- name : Cache mithril-core/ Cargo.lock
70+ name : Cache Cargo.lock
10771 with :
10872 path : |
10973 ~/.cargo/registry
11074 ~/.cargo/git
111- mithril-core/ target
112- key : ${{ runner.os }}-${{ hashFiles('mithril-core /Cargo.lock') }}
75+ target/
76+ key : ${{ runner.os }}-${{ hashFiles('/Cargo.lock') }}
11377 restore-keys : |
114- ${{ runner.os }}-key
78+ ${{ runner.os }}-key
11579
116- 117- name : Cache cargo2junit
80+ - name : Generate ${{ matrix.project.name }} doc
81+ uses : actions-rs/cargo@v1
11882 with :
119- path : |
120- ~/.cargo/bin/cargo2junit
121- key : ${{ runner.os }}-${{ hashFiles('~/.cargo/bin/cargo2junit') }}
122- restore-keys : |
123- ${{ runner.os }}-cargo2junit-key
83+ command : doc
84+ args : --no-deps --release --manifest-path ./${{ matrix.project.name }}/Cargo.toml
12485
125- - name : Download mithril core
126- uses : actions/download -artifact@v3
86+ - name : Publish ${{ matrix.project.name }}
87+ uses : actions/upload -artifact@v3
12788 with :
128- name : libmithril
129- path : mithril-core/target/include/
130-
131- - name : Install cargo2junit
132- run : |
133- # Suppress the "binary `cargo2junit` already exists in destination" error
134- cargo install cargo2junit 2>/dev/null || true
135-
136- - name : Run cargo test
137- shell : bash
138- working-directory : mithril-core
139- run : |
140- set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-mithril-core.xml)
141-
89+ name : ${{ matrix.project.name }}
90+ path : |
91+ target/release/${{ matrix.project.artefacts_pattern }}*
92+ if-no-files-found : error
14293
143- - name : Upload Unit Test Results
144- if : always()
94+ - name : Publish ${{ matrix.project.name }}-doc
14595 uses : actions/upload-artifact@v3
14696 with :
147- name : test-results-mithril-core
97+ name : ${{ matrix.project.name }}-doc
98+ if-no-files-found : error
14899 path : |
149- ./**/test-results-*.xml
100+ target/doc/
150101
151- build-mithril :
102+ test-check :
152103 if : github.event.pull_request.draft == false
153104 runs-on : ubuntu-latest
105+ needs : [ build ]
154106 strategy :
155107 fail-fast : false
156108 matrix :
157- project : [ mithril-common, mithril-aggregator, mithril-client, mithril-signer ]
109+ project : [ mithril-core, mithril- common, mithril-aggregator, mithril-client, mithril-signer ]
158110 steps :
159111 - name : Checkout sources
160112 uses : actions/checkout@v2
@@ -168,13 +120,13 @@ jobs:
168120 override : true
169121
170122171- name : Cache ${{ matrix.project }}/ Cargo.lock
123+ name : Cache Cargo.lock
172124 with :
173125 path : |
174126 ~/.cargo/registry
175127 ~/.cargo/git
176- ${{ matrix.project }}/ target
177- key : ${{ runner.os }}-${{ hashFiles('${{ matrix.project }} /Cargo.lock') }}
128+ target/
129+ key : ${{ runner.os }}-${{ hashFiles('/Cargo.lock') }}
178130 restore-keys : |
179131 ${{ runner.os }}-key
180132
@@ -187,12 +139,6 @@ jobs:
187139 restore-keys : |
188140 ${{ runner.os }}-cargo2junit-key
189141
190- - name : Cargo build
191- uses : actions-rs/cargo@v1
192- with :
193- command : build
194- args : --release --manifest-path ./${{ matrix.project }}/Cargo.toml
195-
196142 - name : Cargo check
197143 uses : actions-rs/cargo@v1
198144 with :
@@ -210,7 +156,7 @@ jobs:
210156 with :
211157 name : clippy-${{ matrix.project }}
212158 token : ${{ secrets.GITHUB_TOKEN }}
213- args : --manifest-path ./${{ matrix.project }}/Cargo.toml --all-features
159+ args : --release -- manifest-path ./${{ matrix.project }}/Cargo.toml --all-features
214160
215161 - name : Install cargo2junit
216162 run : |
@@ -223,29 +169,6 @@ jobs:
223169 run : |
224170 set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-${{ matrix.project }}.xml)
225171
226- - name : Generate ${{ matrix.project }} doc
227- uses : actions-rs/cargo@v1
228- with :
229- command : doc
230- args : --no-deps --release --manifest-path ./${{ matrix.project }}/Cargo.toml
231-
232- - name : Publish ${{ matrix.project }}
233- uses : actions/upload-artifact@v3
234- with :
235- name : ${{ matrix.project }}
236- path : |
237- ${{ matrix.project }}/target/release/${{ matrix.project }}
238- ${{ matrix.project }}/target/release/lib*.so
239- if-no-files-found : error
240-
241- - name : Publish ${{ matrix.project }}-doc
242- uses : actions/upload-artifact@v3
243- with :
244- name : ${{ matrix.project }}-doc
245- if-no-files-found : error
246- path : |
247- ${{ matrix.project }}/target/doc/
248-
249172 - name : Upload Unit Test Results
250173 if : always()
251174 uses : actions/upload-artifact@v3
@@ -257,7 +180,7 @@ jobs:
257180 docker-mithril :
258181 runs-on : ubuntu-latest
259182 if : ${{ github.event_name == 'push' }}
260- needs : [ build-mithril-core, build-mithril ]
183+ needs : [ upload-artifacts, test-check ]
261184 strategy :
262185 fail-fast : false
263186 matrix :
@@ -311,7 +234,7 @@ jobs:
311234 publish-tests-results :
312235 if : github.event.pull_request.draft == false && ${{ always() }}
313236 runs-on : ubuntu-latest
314- needs : [ build-mithril, test-mithril-core ]
237+ needs : [ test-check ]
315238 steps :
316239 - name : Download mithril-core Tests Results
317240 if : always()
@@ -353,10 +276,10 @@ jobs:
353276 if : github.event.pull_request.draft == false
354277 runs-on : ubuntu-latest
355278 needs :
356- - build-mithril
279+ - upload-artifacts
357280 - docker-mithril
358- - test-mithril-core
359- - build -test-lab
281+ - test-check
282+ - run -test-lab
360283 steps :
361284 - name : Checkout sources
362285 uses : actions/checkout@v2
@@ -420,9 +343,9 @@ jobs:
420343 github_token : ${{ secrets.GITHUB_TOKEN || github.token }}
421344 publish_dir : ./github-pages
422345
423- build -test-lab :
346+ run -test-lab :
424347 runs-on : ubuntu-latest
425- needs : [ build-mithril-core, build-mithril ]
348+ needs : [ upload-artifacts ]
426349 steps :
427350 - name : Checkout sources
428351 uses : actions/checkout@v2
@@ -485,9 +408,10 @@ jobs:
485408 terraform :
486409 runs-on : ubuntu-latest
487410 needs :
488- - docker-mithril
489- - test-mithril-core
490- - build-test-lab
411+ - upload-artifacts
412+ - test-check
413+ - docker-mithril
414+ - run-test-lab
491415 env :
492416 # Contains a JSON-formatted service account key
493417 GOOGLE_CREDENTIALS : ${{ secrets.GOOGLE_CREDENTIALS }}
0 commit comments