Skip to content

Commit e7a6427

Browse files
authored
Improve CI status check (#1102)
* simplify and add status check * fix syntax * add status check to tee-worker CI * adjust README * fix path error
1 parent 8b7f31b commit e7a6427

File tree

3 files changed

+60
-23
lines changed

3 files changed

+60
-23
lines changed

.github/workflows/parachain-ci.yml

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ jobs:
5353
- 'runtime/**'
5454
- 'mock-tee-primitives/**'
5555
- 'docker/Dockerfile'
56-
- '**/Cargo.lock'
57-
- '**/Cargo.toml'
58-
- '**/rust-toolchain.toml'
56+
- 'Cargo.lock'
57+
- 'Cargo.toml'
58+
- 'rust-toolchain.toml'
5959
6060
check-cargo-fmt:
6161
runs-on: ubuntu-latest
@@ -112,7 +112,7 @@ jobs:
112112
run: |
113113
sudo apt-get update && \
114114
sudo apt-get install -yq openssl clang libclang-dev cmake protobuf-compiler
115-
115+
116116
- name: Run cargo clippy check
117117
run: make clippy
118118

@@ -206,6 +206,22 @@ jobs:
206206
run: |
207207
make clean-docker-${{ matrix.chain }}
208208
209+
# This is used to set github merge rules to protected branch, it's useful for
210+
# checking the matrix status, where we need to cover
211+
# - "successful" status (e.g. run-ts-tests(litmus)), and
212+
# - "skipped" status (run-ts-tests).
213+
# see https://github.com/orgs/community/discussions/26822
214+
run-ts-tests-status-check:
215+
if: ${{ always() }}
216+
runs-on: ubuntu-latest
217+
needs: run-ts-tests
218+
steps:
219+
- run: |
220+
case "${{ needs.run-ts-tests.result }}" in
221+
success|skipped) exit 0 ;;
222+
*) exit 1 ;;
223+
esac
224+
209225
run-cargo-unit-tests:
210226
runs-on: ubuntu-latest
211227
needs: [check-cargo-fmt, check-file-change]
@@ -254,18 +270,11 @@ jobs:
254270
if: failure()
255271
uses: andymckay/[email protected]
256272

257-
258-
# The reason why not to put the if-check on the job level is to make sure the
259-
# *matrix* job is run, although it can be skipped in the end.
260-
#
261-
# This is required when setting github merge rules to protected branch,
262-
# where you can only select one of `run-cargo-runtime-tests` and `run-cargo-runtime-tests(litmus)`.
263-
# If you put if-check on the job level, it can't fit every possible case.
264-
#
265273
# Tried https://github.com/Swatinem/rust-cache too but it didn't work so well
266274
run-cargo-runtime-tests:
267275
runs-on: ubuntu-latest
268276
needs: [check-cargo-fmt, check-file-change]
277+
if: needs.check-file-change.outputs.src == 'true'
269278
env:
270279
RUSTC_WRAPPER: sccache
271280
SCCACHE_CACHE_SIZE: 10G
@@ -283,7 +292,6 @@ jobs:
283292
fetch-depth: 0
284293

285294
- name: Install toolchain
286-
if: needs.check-file-change.outputs.src == 'true'
287295
uses: actions-rs/toolchain@v1
288296
with:
289297
profile: minimal
@@ -311,9 +319,7 @@ jobs:
311319
sudo apt-get install -yq openssl clang libclang-dev cmake protobuf-compiler
312320
313321
- name: Cache cargo registry
314-
if: needs.check-file-change.outputs.src == 'true'
315322
uses: actions/cache@v3
316-
continue-on-error: false
317323
with:
318324
path: |
319325
~/.cargo/registry
@@ -324,9 +330,7 @@ jobs:
324330
cargo-
325331
326332
- name: Cache sccache
327-
if: needs.check-file-change.outputs.src == 'true'
328333
uses: actions/cache@v3
329-
continue-on-error: false
330334
with:
331335
path: /home/runner/.cache/sccache
332336
key: sccache-${{ env.REF_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
@@ -335,17 +339,26 @@ jobs:
335339
sccache-
336340
337341
- name: Run runtime integration tests
338-
if: needs.check-file-change.outputs.src == 'true'
339342
run: cargo test --locked --release -p ${{ matrix.chain }}-parachain-runtime --lib
340343

341344
- name: Print sccache stats
342-
if: needs.check-file-change.outputs.src == 'true'
343345
run: sccache --show-stats
344346

345347
- name: Fail-fast; cancel other jobs
346348
if: failure()
347349
uses: andymckay/[email protected]
348350

351+
run-cargo-runtime-tests-status-check:
352+
if: ${{ always() }}
353+
runs-on: ubuntu-latest
354+
needs: run-cargo-runtime-tests
355+
steps:
356+
- run: |
357+
case "${{ needs.run-cargo-runtime-tests.result }}" in
358+
success|skipped) exit 0 ;;
359+
*) exit 1 ;;
360+
esac
361+
349362
# Secrets are not passed to the runner when a workflow is triggered from a forked repository,
350363
# see https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
351364
# Only push docker image when tests are passed on dev branch

.github/workflows/tee-worker-ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ jobs:
147147
name: integritee-cli-client-${{ matrix.flavor_id }}-${{ github.sha }}.tar.gz
148148
path: ${{ env.UPLOAD_DOWNLOAD_DIR_PREFIX }}/integritee-cli-client-${{ matrix.flavor_id }}-${{ github.sha }}.tar.gz
149149

150+
build-test-status-check:
151+
if: ${{ always() }}
152+
runs-on: ubuntu-latest
153+
needs: build-test
154+
steps:
155+
- uses: actions/checkout@v3
156+
- run: |
157+
case "${{ needs.build-test.result }}" in
158+
success|skipped) exit 0 ;;
159+
*) exit 1 ;;
160+
esac
161+
150162
clippy:
151163
runs-on: ubuntu-latest
152164
needs: check-file-change
@@ -319,6 +331,18 @@ jobs:
319331
name: logs-${{ matrix.test }}-${{ matrix.flavor_id }}
320332
path: ${{ env.UPLOAD_DOWNLOAD_DIR_PREFIX }}/${{ env.LOG_DIR }}
321333

334+
integration-tests-status-check:
335+
if: ${{ always() }}
336+
runs-on: ubuntu-latest
337+
needs: integration-tests
338+
steps:
339+
- uses: actions/checkout@v3
340+
- run: |
341+
case "${{ needs.integration-tests.result }}" in
342+
success|skipped) exit 0 ;;
343+
*) exit 1 ;;
344+
esac
345+
322346
# Only push docker image when tests are passed and it's a push event
323347
push-docker-image:
324348
runs-on: ubuntu-latest

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# litentry-parachain
2-
[![Build & Test](https://github.com/litentry/litentry-parachain/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/build-and-test.yml)
3-
[![Build wasm](https://github.com/litentry/litentry-parachain/actions/workflows/build-wasm.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/build-wasm.yml)
4-
[![Benchmark runtime weights](https://github.com/litentry/litentry-parachain/actions/workflows/benchmark-runtime-weights.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/benchmark-runtime-weights.yml)
5-
[![Release](https://github.com/litentry/litentry-parachain/actions/workflows/create-release-draft.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/create-release-draft.yml)
2+
[![parachain](https://github.com/litentry/litentry-parachain/actions/workflows/parachain-ci.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/parachain-ci.yml)
3+
[![tee-worker](https://github.com/litentry/litentry-parachain/actions/workflows/tee-worker-ci.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/tee-worker-ci.yml)
4+
[![release](https://github.com/litentry/litentry-parachain/actions/workflows/create-release-draft.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/create-release-draft.yml)
5+
[![runtime upgrade](https://github.com/litentry/litentry-parachain/actions/workflows/runtime-upgrade-simulation.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/runtime-upgrade-simulation.yml)
66

77
The Litentry parachain.
88

0 commit comments

Comments
 (0)