From b2089d88bd6ef40ca17ddfa097b05b257cdcdf13 Mon Sep 17 00:00:00 2001 From: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:56:29 +0200 Subject: [PATCH] [ci] Fix final job for required workflows (#5619) Currently if a required job fails the final jobs is skipped which breaks the logic of required jobs. PR fixes it. Closes https://github.com/paritytech/ci_cd/issues/1033 --- .github/workflows/build-misc.yml | 24 ++++++----- .../workflows/check-cargo-check-runtimes.yml | 14 ++++-- .github/workflows/check-runtime-migration.yml | 13 +++++- .github/workflows/checks.yml | 13 +++++- .github/workflows/tests-linux-stable.yml | 11 ++++- .github/workflows/tests-misc.yml | 43 +++++++++++-------- 6 files changed, 83 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build-misc.yml b/.github/workflows/build-misc.yml index c85549b37999..a01384dc002c 100644 --- a/.github/workflows/build-misc.yml +++ b/.github/workflows/build-misc.yml @@ -5,10 +5,9 @@ on: branches: - master pull_request: - types: [ opened, synchronize, reopened, ready_for_review ] + types: [opened, synchronize, reopened, ready_for_review] merge_group: - concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -41,7 +40,7 @@ jobs: build-runtimes-polkavm: timeout-minutes: 20 - needs: [ set-image ] + needs: [set-image] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -65,7 +64,7 @@ jobs: build-subkey: timeout-minutes: 20 - needs: [ set-image ] + needs: [set-image] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -89,10 +88,15 @@ jobs: runs-on: ubuntu-latest name: All build misc jobs passed # If any new job gets added, be sure to add it to this array - needs: - [ - build-runtimes-polkavm, - build-subkey - ] + needs: [build-runtimes-polkavm, build-subkey] + if: always() && !cancelled() steps: - - run: echo '### Good job! All the build misc tests passed 🚀' >> $GITHUB_STEP_SUMMARY \ No newline at end of file + - run: | + tee resultfile <<< '${{ toJSON(needs) }}' + FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l) + if [ $FAILURES -gt 0 ]; then + echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY + exit 1 + else + echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/check-cargo-check-runtimes.yml b/.github/workflows/check-cargo-check-runtimes.yml index ebcf6c5fc9bd..6325033d214c 100644 --- a/.github/workflows/check-cargo-check-runtimes.yml +++ b/.github/workflows/check-cargo-check-runtimes.yml @@ -2,8 +2,7 @@ name: Check Cargo Check Runtimes on: pull_request: - types: [ opened, synchronize, reopened, ready_for_review, labeled ] - + types: [opened, synchronize, reopened, ready_for_review, labeled] # Jobs in this workflow depend on each other, only for limiting peak amount of spawned workers @@ -132,5 +131,14 @@ jobs: - check-runtime-contracts - check-runtime-starters - check-runtime-testing + if: always() && !cancelled() steps: - - run: echo '### Good job! All the tests passed 🚀' >> $GITHUB_STEP_SUMMARY + - run: | + tee resultfile <<< '${{ toJSON(needs) }}' + FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l) + if [ $FAILURES -gt 0 ]; then + echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY + exit 1 + else + echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/check-runtime-migration.yml b/.github/workflows/check-runtime-migration.yml index 5fb9dca38d17..0a1dbc4790c8 100644 --- a/.github/workflows/check-runtime-migration.yml +++ b/.github/workflows/check-runtime-migration.yml @@ -46,7 +46,7 @@ jobs: # We need to set this to rather long to allow the snapshot to be created, but the average time # should be much lower. timeout-minutes: 60 - needs: [ set-image ] + needs: [set-image] container: image: ${{ needs.set-image.outputs.IMAGE }} strategy: @@ -162,5 +162,14 @@ jobs: name: All runtime migrations passed # If any new job gets added, be sure to add it to this array needs: [check-runtime-migration] + if: always() && !cancelled() steps: - - run: echo '### Good job! All the checks passed 🚀' >> $GITHUB_STEP_SUMMARY + - run: | + tee resultfile <<< '${{ toJSON(needs) }}' + FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l) + if [ $FAILURES -gt 0 ]; then + echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY + exit 1 + else + echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9aebd83282e3..9de879d83676 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -12,7 +12,7 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true -permissions: { } +permissions: {} jobs: # temporary disabled because currently doesn't work in merge queue @@ -105,5 +105,14 @@ jobs: name: All checks passed # If any new job gets added, be sure to add it to this array needs: [cargo-clippy, check-try-runtime, check-core-crypto-features] + if: always() && !cancelled() steps: - - run: echo '### Good job! All the checks passed 🚀' >> $GITHUB_STEP_SUMMARY + - run: | + tee resultfile <<< '${{ toJSON(needs) }}' + FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l) + if [ $FAILURES -gt 0 ]; then + echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY + exit 1 + else + echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/tests-linux-stable.yml b/.github/workflows/tests-linux-stable.yml index 997d7622f0c3..7ed67703395f 100644 --- a/.github/workflows/tests-linux-stable.yml +++ b/.github/workflows/tests-linux-stable.yml @@ -138,5 +138,14 @@ jobs: test-linux-stable-runtime-benchmarks, test-linux-stable, ] + if: always() && !cancelled() steps: - - run: echo '### Good job! All the tests passed 🚀' >> $GITHUB_STEP_SUMMARY + - run: | + tee resultfile <<< '${{ toJSON(needs) }}' + FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l) + if [ $FAILURES -gt 0 ]; then + echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY + exit 1 + else + echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/tests-misc.yml b/.github/workflows/tests-misc.yml index 2e78f4a34ede..9aa6bf23727f 100644 --- a/.github/workflows/tests-misc.yml +++ b/.github/workflows/tests-misc.yml @@ -5,7 +5,7 @@ on: branches: - master pull_request: - types: [ opened, synchronize, reopened, ready_for_review ] + types: [opened, synchronize, reopened, ready_for_review] merge_group: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -43,12 +43,12 @@ jobs: echo "RUNNER=arc-runners-polkadot-sdk-beefy-persistent" >> $GITHUB_OUTPUT else echo "RUNNER=arc-runners-polkadot-sdk-beefy" >> $GITHUB_OUTPUT - fi - + fi + # more information about this job can be found here: # https://github.com/paritytech/substrate/pull/3778 test-full-crypto-feature: - needs: [ set-image ] + needs: [set-image] runs-on: ${{ needs.set-image.outputs.RUNNER }} timeout-minutes: 60 container: @@ -72,7 +72,7 @@ jobs: test-frame-examples-compile-to-wasm: timeout-minutes: 20 # into one job - needs: [ set-image, test-full-crypto-feature ] + needs: [set-image, test-full-crypto-feature] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -93,7 +93,7 @@ jobs: test-frame-ui: timeout-minutes: 60 - needs: [ set-image, test-frame-examples-compile-to-wasm ] + needs: [set-image, test-frame-examples-compile-to-wasm] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -121,7 +121,7 @@ jobs: test-deterministic-wasm: timeout-minutes: 20 - needs: [ set-image ] + needs: [set-image] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -143,7 +143,7 @@ jobs: sha256sum -c checksum.sha256 cargo-check-benches-branches: - needs: [ set-image ] + needs: [set-image] if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }} timeout-minutes: 60 outputs: @@ -156,7 +156,7 @@ jobs: echo "branch=['${{ github.base_ref }}', '${{ github.head_ref }}']" >> $GITHUB_OUTPUT cargo-check-benches: - needs: [ set-image, cargo-check-benches-branches ] + needs: [set-image, cargo-check-benches-branches] timeout-minutes: 60 strategy: matrix: @@ -191,7 +191,7 @@ jobs: node-bench-regression-guard: timeout-minutes: 20 runs-on: arc-runners-polkadot-sdk - needs: [ set-image, cargo-check-benches ] + needs: [set-image, cargo-check-benches] steps: - name: Checkout uses: actions/checkout@v4.1.7 @@ -227,7 +227,7 @@ jobs: fi test-node-metrics: - needs: [ set-image ] + needs: [set-image] timeout-minutes: 30 runs-on: ${{ needs.set-image.outputs.RUNNER }} container: @@ -260,7 +260,7 @@ jobs: # https://github.com/paritytech/substrate/pull/6916 check-tracing: timeout-minutes: 20 - needs: [ set-image, test-node-metrics ] + needs: [set-image, test-node-metrics] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -275,7 +275,7 @@ jobs: check-metadata-hash: timeout-minutes: 20 - needs: [ set-image, check-tracing ] + needs: [set-image, check-tracing] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -289,7 +289,7 @@ jobs: cargo-hfuzz: timeout-minutes: 20 - needs: [ set-image, check-metadata-hash ] + needs: [set-image, check-metadata-hash] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -329,7 +329,7 @@ jobs: cargo-check-each-crate: timeout-minutes: 140 - needs: [ set-image ] + needs: [set-image] runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} @@ -338,7 +338,7 @@ jobs: CI_JOB_NAME: cargo-check-each-crate strategy: matrix: - index: [ 1,2,3,4,5,6,7 ] # 7 parallel jobs + index: [1, 2, 3, 4, 5, 6, 7] # 7 parallel jobs steps: - name: Checkout uses: actions/checkout@v4.1.7 @@ -394,5 +394,14 @@ jobs: - cargo-check-each-crate - test-deterministic-wasm # - cargo-hfuzz remove from required for now, as it's flaky + if: always() && !cancelled() steps: - - run: echo '### Good job! All the required tests passed 🚀' >> $GITHUB_STEP_SUMMARY \ No newline at end of file + - run: | + tee resultfile <<< '${{ toJSON(needs) }}' + FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l) + if [ $FAILURES -gt 0 ]; then + echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY + exit 1 + else + echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY + fi