Skip to content

Commit 147f911

Browse files
committed
Heavily simplify ci matrix build to reduce cache usage
1 parent 4433dc4 commit 147f911

File tree

3 files changed

+78
-211
lines changed

3 files changed

+78
-211
lines changed

.github/workflows/ci.yml

Lines changed: 68 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -13,58 +13,20 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
project: [
17-
mithril-core,
18-
mithril-common,
19-
mithril-aggregator,
20-
mithril-client,
21-
mithril-signer,
22-
mithril-test-lab/mithril-end-to-end,
23-
demo/protocol-demo
24-
]
25-
os: [ubuntu-22.04]
16+
os: [ ubuntu-22.04, macos-12, windows-latest ]
2617

2718
include:
28-
- project: mithril-core
29-
cargo_project_name: mithril
30-
artifacts_pattern: libmithril
31-
- project: mithril-common
32-
artifacts_pattern: libmithril_common
33-
- project: mithril-client
34-
os: macos-latest
35-
- project: mithril-client
36-
os: windows-latest
37-
- project: mithril-test-lab/mithril-end-to-end
38-
cargo_project_name: mithril-end-to-end
39-
artifacts_base_name: mithril-end-to-end
40-
artifacts_pattern: mithril-end-to-end
41-
- project: demo/protocol-demo
42-
cargo_project_name: mithrildemo
43-
artifacts_base_name: mithrildemo
44-
artifacts_pattern: mithrildemo
45-
env:
46-
CARGO_PROJECT_NAME: ${{ matrix.project }}
47-
ARTIFACTS_BASE_NAME: ${{ matrix.project }}
48-
ARTIFACTS_PATTERN: ${{ matrix.project }}
49-
19+
# Only build client on windows & mac
20+
- os: macos-12
21+
build-args: -p mithril-client
22+
- os: windows-latest
23+
build-args: -p mithril-client
5024
runs-on: ${{ matrix.os }}
5125

5226
steps:
5327
- name: Checkout sources
5428
uses: actions/checkout@v3
5529

56-
- name: Overriding default $CARGO_PROJECT_NAME with matrix value
57-
if: ${{ matrix.cargo_project_name }}
58-
run: echo "CARGO_PROJECT_NAME=${{ matrix.cargo_project_name }}" >> $GITHUB_ENV
59-
60-
- name: Overriding default $ARTIFACTS_BASE_NAME with matrix value
61-
if: ${{ matrix.artifacts_base_name }}
62-
run: echo "ARTIFACTS_BASE_NAME=${{ matrix.artifacts_base_name }}" >> $GITHUB_ENV
63-
64-
- name: Overriding default $ARTIFACTS_PATTERN with matrix value
65-
if: ${{ matrix.artifacts_pattern }}
66-
run: echo "ARTIFACTS_PATTERN=${{ matrix.artifacts_pattern }}" >> $GITHUB_ENV
67-
6830
- name: Install stable toolchain
6931
uses: actions-rs/toolchain@v1
7032
with:
@@ -81,64 +43,64 @@ jobs:
8143
uses: actions-rs/cargo@v1
8244
with:
8345
command: build
84-
args: --release --features portable -p ${{ env.CARGO_PROJECT_NAME }}
46+
args: --release ${{ matrix.build-args }}
8547

86-
- name: Publish ${{ matrix.project }} (${{ runner.os }}-${{ runner.arch }})
48+
- name: Publish Mithril Distribution (${{ runner.os }}-${{ runner.arch }})
8749
uses: actions/upload-artifact@v3
8850
with:
89-
name: ${{ env.ARTIFACTS_BASE_NAME }}-${{ runner.os }}-${{ runner.arch }}
51+
name: mithril-distribution-${{ runner.os }}-${{ runner.arch }}
9052
path: |
91-
target/release/${{ env.ARTIFACTS_PATTERN }}*
53+
target/release/libmithril.*
54+
target/release/libmithril_common.*
55+
target/release/mithril-aggregator
56+
target/release/mithril-aggregator.exe
57+
target/release/mithril-client
58+
target/release/mithril-client.exe
59+
target/release/mithril-signer
60+
target/release/mithril-signer.exe
61+
target/release/mithrildemo
62+
target/release/mithrildemo.exe
63+
if-no-files-found: error
64+
65+
- name: Publish End-to-end runner (${{ runner.os }}-${{ runner.arch }})
66+
uses: actions/upload-artifact@v3
67+
if: ${{ runner.os == 'Linux' }}
68+
with:
69+
name: mithril-end-to-end-${{ runner.os }}-${{ runner.arch }}
70+
path: target/release/mithril-end-to-end
9271
if-no-files-found: error
9372

9473
test:
9574
strategy:
9675
fail-fast: false
9776
matrix:
98-
project: [
99-
mithril-core,
100-
mithril-common,
101-
mithril-aggregator,
102-
mithril-client,
103-
mithril-signer,
104-
mithril-test-lab/mithril-end-to-end,
105-
demo/protocol-demo
106-
]
107-
os: [ubuntu-22.04]
77+
title: [ "mithril" ]
78+
os: [ ubuntu-22.04, macos-12, windows-latest ]
10879

10980
include:
110-
- project: mithril-core
111-
cargo_project_name: mithril
112-
cargo-args: --release # Mithril core tests are ~2x quicker on release build
113-
- project: mithril-common
114-
- project: mithril-client
115-
os: macos-latest
116-
- project: mithril-client
117-
os: windows-latest
118-
- project: mithril-test-lab/mithril-end-to-end
119-
cargo_project_name: mithril-end-to-end
120-
artifacts_base_name: mithril-end-to-end
121-
- project: demo/protocol-demo
122-
cargo_project_name: mithrildemo
123-
artifacts_base_name: mithrildemo
124-
env:
125-
CARGO_PROJECT_NAME: ${{ matrix.project }}
126-
ARTIFACTS_BASE_NAME: ${{ matrix.project }}
81+
- os: ubuntu-22.04
82+
build-args: --workspace
83+
test-args: --workspace --exclude mithril # mithril core is tested separately since it's slow
84+
- title: mithril-core
85+
os: ubuntu-22.04
86+
# Mithril core tests are ~2x faster on release build
87+
build-args: --release -p mithril
88+
test-args: --release -p mithril
89+
artifact-suffix: -mithril-core
90+
# Only test client on windows & mac (since its the only binaries supported for those os for now)
91+
- os: macos-12
92+
build-args: -p mithril-client
93+
test-args: -p mithril-client
94+
- os: windows-latest
95+
build-args: -p mithril-client
96+
test-args: -p mithril-client
12797

12898
runs-on: ${{ matrix.os }}
12999

130100
steps:
131101
- name: Checkout sources
132102
uses: actions/checkout@v3
133103

134-
- name: Overriding default $CARGO_PROJECT_NAME with matrix value
135-
if: ${{ matrix.cargo_project_name }}
136-
run: echo "CARGO_PROJECT_NAME=${{ matrix.cargo_project_name }}" >> $GITHUB_ENV
137-
138-
- name: Overriding default $ARTIFACTS_BASE_NAME with matrix value
139-
if: ${{ matrix.artifacts_base_name }}
140-
run: echo "ARTIFACTS_BASE_NAME=${{ matrix.artifacts_base_name }}" >> $GITHUB_ENV
141-
142104
- name: Install stable toolchain
143105
uses: actions-rs/toolchain@v1
144106
with:
@@ -152,30 +114,23 @@ jobs:
152114
key: ${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}
153115

154116
- name: Install cargo tools
155-
if: ${{ steps.cargo-cache.outputs.cache-hit == false }}
156117
shell: bash
157118
run: |
158119
cargo install cargo2junit 2>/dev/null || true # Suppress the "binary `xyz` already exists in destination" error
159120
160-
- name: Cargo build
161-
uses: actions-rs/cargo@v1
162-
with:
163-
command: build
164-
args: --tests --features portable -p ${{ env.CARGO_PROJECT_NAME }} ${{ matrix.cargo-args }}
165-
166121
- name: Run tests
167122
shell: bash
168123
run: |
169124
set -o pipefail && \
170-
cargo test --features portable -p $CARGO_PROJECT_NAME --no-fail-fast ${{ matrix.cargo-args }} \
125+
cargo test --features portable --no-fail-fast ${{ matrix.test-args }} \
171126
-- -Z unstable-options --format json --report-time \
172-
| tee >(cargo2junit > test-results-${{ env.artifacts_base_name }}-${{ runner.os }}-${{ runner.arch }}.xml)
127+
| tee >(cargo2junit > test-results${{ matrix.artifact-suffix }}-${{ runner.os }}-${{ runner.arch }}.xml)
173128
174129
- name: Upload Tests Results
175130
uses: actions/upload-artifact@v3
176131
if: ${{ success() || failure() }}
177132
with:
178-
name: test-results-${{ env.ARTIFACTS_BASE_NAME }}-${{ runner.os }}-${{ runner.arch }}
133+
name: test-results${{ matrix.artifact-suffix }}-${{ runner.os }}-${{ runner.arch }}
179134
path: |
180135
./**/test-results-*.xml
181136
@@ -234,22 +189,10 @@ jobs:
234189
- name: Checkout sources
235190
uses: actions/checkout@v3
236191

237-
- name: Download aggregator
238-
uses: actions/download-artifact@v3
239-
with:
240-
name: mithril-aggregator-${{ runner.os }}-${{ runner.arch }}
241-
path: ./bin
242-
243-
- name: Download signer
192+
- name: Download binaries
244193
uses: actions/download-artifact@v3
245194
with:
246-
name: mithril-signer-${{ runner.os }}-${{ runner.arch }}
247-
path: ./bin
248-
249-
- name: Download client
250-
uses: actions/download-artifact@v3
251-
with:
252-
name: mithril-client-${{ runner.os }}-${{ runner.arch }}
195+
name: mithril-distribution-${{ runner.os }}-${{ runner.arch }}
253196
path: ./bin
254197

255198
- name: Download rust test runner
@@ -288,60 +231,30 @@ jobs:
288231
needs:
289232
- test
290233
steps:
291-
- name: Download mithril-core Tests Results
234+
- name: Download Tests Results (${{ runner.os }}-${{ runner.arch }})
292235
if: ${{ success() || failure() }}
293236
uses: actions/download-artifact@v3
294237
with:
295-
name: test-results-mithril-core-${{ runner.os }}-${{ runner.arch }}
238+
name: test-results-${{ runner.os }}-${{ runner.arch }}
296239

297-
- name: Download mithril-common Tests Results
240+
- name: Download mithril-core Tests Results (${{ runner.os }}-${{ runner.arch }})
298241
if: ${{ success() || failure() }}
299242
uses: actions/download-artifact@v3
300243
with:
301-
name: test-results-mithril-common-${{ runner.os }}-${{ runner.arch }}
302-
303-
- name: Download mithril-aggregator Tests Results
304-
if: ${{ success() || failure() }}
305-
uses: actions/download-artifact@v3
306-
with:
307-
name: test-results-mithril-aggregator-${{ runner.os }}-${{ runner.arch }}
308-
309-
- name: Download mithril-client (${{ runner.os }}-${{ runner.arch }}) Tests Results
310-
if: ${{ success() || failure() }}
311-
uses: actions/download-artifact@v3
312-
with:
313-
name: test-results-mithril-client-${{ runner.os }}-${{ runner.arch }}
314-
315-
- name: Download mithril-client (macOS-X64) Tests Results
316-
if: ${{ success() || failure() }}
317-
uses: actions/download-artifact@v3
318-
with:
319-
name: test-results-mithril-client-macOS-X64
320-
321-
- name: Download mithril-client (Windows-X64) Tests Results
322-
if: ${{ success() || failure() }}
323-
uses: actions/download-artifact@v3
324-
with:
325-
name: test-results-mithril-client-Windows-X64
244+
name: test-results-mithril-core-${{ runner.os }}-${{ runner.arch }}
326245

327-
- name: Download mithril-signer Tests Results
246+
- name: Download Tests Results (macOS-X64)
328247
if: ${{ success() || failure() }}
329248
uses: actions/download-artifact@v3
330249
with:
331-
name: test-results-mithril-signer-${{ runner.os }}-${{ runner.arch }}
250+
name: test-results-macOS-X64
332251

333-
- name: Download mithril-end-to-end Tests Results
252+
- name: Download Tests Results (Windows-X64)
334253
if: ${{ success() || failure() }}
335254
uses: actions/download-artifact@v3
336255
with:
337-
name: test-results-mithril-end-to-end-${{ runner.os }}-${{ runner.arch }}
256+
name: test-results-Windows-X64
338257

339-
- name: Download mithril-demo Tests Results
340-
if: ${{ success() || failure() }}
341-
uses: actions/download-artifact@v3
342-
with:
343-
name: test-results-mithrildemo-${{ runner.os }}-${{ runner.arch }}
344-
345258
- name: Publish Unit Test Results
346259
if: ${{ success() || failure() }}
347260
uses: EnricoMi/publish-unit-test-result-action@v1
@@ -350,7 +263,6 @@ jobs:
350263

351264
docker-mithril:
352265
runs-on: ubuntu-22.04
353-
if: ${{ github.event_name == 'push' }}
354266
needs:
355267
- build
356268
- check
@@ -393,10 +305,10 @@ jobs:
393305
unstable
394306
type=raw,value={{branch}}-{{sha}}
395307
396-
- name: Download ${{ matrix.project }} executable
308+
- name: Download built artifacts
397309
uses: actions/download-artifact@v3
398310
with:
399-
name: ${{ matrix.project }}-${{ runner.os }}-${{ runner.arch }}
311+
name: mithril-distribution-${{ runner.os }}-${{ runner.arch }}
400312
path: ${{ matrix.project }}
401313

402314
- name: Build and push Docker image
@@ -408,51 +320,33 @@ jobs:
408320
tags: ${{ steps.meta.outputs.tags }}
409321

410322
unstable-release:
411-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
412323
runs-on: ubuntu-22.04
413324
needs:
414325
- build
415326
- test
416327
- run-test-lab
417328
- check
418329
steps:
419-
- name: Download mithril-core lib
420-
uses: actions/download-artifact@v3
421-
with:
422-
name: mithril-core-${{ runner.os }}-${{ runner.arch }}
423-
path: ./build
424-
425-
- name: Download aggregator
426-
uses: actions/download-artifact@v3
427-
with:
428-
name: mithril-aggregator-${{ runner.os }}-${{ runner.arch }}
429-
path: ./build
430-
431-
- name: Download signer
432-
uses: actions/download-artifact@v3
433-
with:
434-
name: mithril-signer-${{ runner.os }}-${{ runner.arch }}
435-
path: ./build
436-
437-
- name: Download client (${{ runner.os }}-${{ runner.arch }})
330+
- name: Download built artifacts (${{ runner.os }}-${{ runner.arch }})
438331
uses: actions/download-artifact@v3
439332
with:
440-
name: mithril-client-${{ runner.os }}-${{ runner.arch }}
333+
name: mithril-distribution-${{ runner.os }}-${{ runner.arch }}
441334
path: ./build
442335

443-
- name: Download client (macOS-X64)
336+
- name: Download built artifacts (macOS-X64)
444337
uses: actions/download-artifact@v3
445338
with:
446-
name: mithril-client-macOS-X64
339+
name: mithril-distribution-macOS-X64
447340
path: ./build
448341

449-
- name: Download client (Windows-X64)
342+
- name: Download built artifacts (Windows-X64)
450343
uses: actions/download-artifact@v3
451344
with:
452-
name: mithril-client-Windows-X64
345+
name: mithril-distribution-Windows-X64
453346
path: ./build
454347

455348
- name: Update unstable release
349+
if: github.ref == 'refs/heads/main'
456350
uses: marvinpinto/action-automatic-releases@latest
457351
with:
458352
repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -501,6 +395,6 @@ jobs:
501395
terraform plan -var "image_id=${{ env.BRANCH_NAME }}-${{ steps.slug.outputs.sha8 }}" -var 'private_key=${{ env.GCLOUD_PRIVATE_KEY }}' -var 'google_application_credentials_json=${{ env.GOOGLE_CREDENTIALS }}' -var 'genesis_secret_key=${{ env.GENESIS_SECRET_KEY }}'
502396
503397
- name: Terraform Apply
504-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
398+
if: github.ref == 'refs/heads/main'
505399
run: |
506400
terraform apply -auto-approve -var "image_id=${{ env.BRANCH_NAME }}-${{ steps.slug.outputs.sha8 }}" -var 'private_key=${{ env.GCLOUD_PRIVATE_KEY }}' -var 'google_application_credentials_json=${{ env.GOOGLE_CREDENTIALS }}' -var 'genesis_secret_key=${{ env.GENESIS_SECRET_KEY }}'

0 commit comments

Comments
 (0)