From 93e69c917c94b40d1cf61487a29a32d70f4a80dd Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Tue, 23 Jul 2024 20:54:14 +0200 Subject: [PATCH] Small CI improvements (#1924) --- .github/workflows/build-wasm.yml | 32 +++++++++++++---------------- .github/workflows/codecov.yml | 13 ++++++++++-- .github/workflows/sanity-checks.yml | 1 + 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 80481fb0a6..6ac6189d7b 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -18,11 +18,14 @@ jobs: # Benchmark (with cache hit) # ubuntu-latest 50 min # ubuntu-latest-4-cores 34 min - runs-on: ubuntu-latest-4-cores + # As this is not a critical PR feedback item, we can run it on free ubuntu-latest + runs-on: ubuntu-latest strategy: matrix: chain: [ altair, centrifuge, development ] name: build-runtime-${{ matrix.chain }} + env: + SRTOOL_IMAGE: "paritytech/srtool:1.77.0-0.15.0" steps: # PREP - name: Check out code @@ -47,6 +50,7 @@ jobs: # with: # image: paritytech/srtool:${{ matrix.rust_version }} # options: --user root -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build -e BUILD_OPTS=${{ env.BUILD_OPTS || ''}} -e PACKAGE=${{ matrix.chain }}-runtime + # options: --user root -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build -e BUILD_OPTS=${{ env.BUILD_OPTS || ''}} -e PACKAGE=${{ matrix.chain }}-runtime # run: | # echo "---- Env VARS ----" # echo "BUILD_OPT=${BUILD_OPT}" @@ -68,7 +72,7 @@ jobs: CMD="docker run --rm --user root --platform=linux/amd64 -e PROFILE=release -e PACKAGE=${{ matrix.chain }}-runtime -e BUILD_OPTS="--features=on-chain-release-build" -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build - paritytech/srtool:1.77.0-0.15.0 /srtool/build --app --json -cM" + ${{ env.SRTOOL_IMAGE }} /srtool/build --app --json -cM" echo ::debug::build::docker_run $CMD echo ::endgroup # here we keep streaming the progress and fetch the last line for the json result @@ -79,30 +83,17 @@ jobs: JSON="$line" done echo "json=$JSON" >> $GITHUB_OUTPUT - - PROP=`echo $JSON | jq -r .runtimes.compact.prop` - echo "proposal_hash=$PROP" >> $GITHUB_OUTPUT WASM=`echo $JSON | jq -r .runtimes.compact.wasm` echo "wasm=$WASM" >> $GITHUB_OUTPUT Z_WASM=`echo $JSON | jq -r .runtimes.compressed.wasm` echo "wasm_compressed=$Z_WASM" >> $GITHUB_OUTPUT - - IPFS=`echo $JSON | jq -r .runtimes.compact.ipfs` - echo "ipfs=$IPFS" >> $GITHUB_OUTPUT } - name: Summary run: | - ## Summary and JSON output - echo "::group::Summary" - echo "- version: ${{ steps.srtool_build.outputs.version }}" - echo "- info: ${{ steps.srtool_build.outputs.info }}" - echo "- prop: ${{ steps.srtool_build.outputs.proposal_hash }}" - echo "- runtime location: ${{ steps.srtool_build.outputs.wasm }}" - echo "::endgroup" - + ## JSON output echo "::group::JSON output" PRETTY_JSON=$(echo '${{ steps.srtool_build.outputs.json }}' | jq .) echo '${{ steps.srtool_build.outputs.json }}' | jq . > "${{ matrix.chain }}-srtool-digest.json" @@ -128,7 +119,12 @@ jobs: ## Publish WASM and JSON summary echo '${{ steps.srtool_build.outputs.json }}' | jq . > "${{ matrix.chain }}-srtool-digest.json" gsutil cp \ - "${{ steps.srtool_build.outputs.wasm }}" \ + "${{ steps.srtool_build.wasm_compressed }}" \ + "gs://centrifuge-wasm-repo/${{ matrix.chain }}/${{ matrix.chain }}-$(git rev-parse --short HEAD).wasm" + ## Publish WASM and JSON summary + echo '${{ steps.srtool_build.outputs.json }}' | jq . > "${{ matrix.chain }}-srtool-digest.json" + gsutil cp \ + "${{ steps.srtool_build.wasm_compressed }}" \ "gs://centrifuge-wasm-repo/${{ matrix.chain }}/${{ matrix.chain }}-$(git rev-parse --short HEAD).wasm" gsutil cp \ "${{ matrix.chain }}-srtool-digest.json" \ @@ -141,7 +137,7 @@ jobs: with: tag: ${{ github.ref_name }} commit: ${{ github.sha }} - artifacts: "${{ steps.srtool_build.outputs.wasm }}, ${{ matrix.chain }}-srtool-digest.json" + artifacts: "${{ steps.srtool_build.wasm_compressed }}, ${{ matrix.chain }}-srtool-digest.json" replacesArtifacts: true allowUpdates: true artifactErrorsFailBuild: true diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 29c544a396..ccb532ca56 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -2,6 +2,10 @@ on: push: branches: [main] pull_request: + types: [opened, synchronize, reopened, ready_for_review] + pull_request_review: + types: [submitted] + workflow_dispatch: name: Code coverage concurrency: group: 'codecov-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' @@ -11,8 +15,13 @@ permissions: contents: read jobs: codecov: - runs-on: ubuntu-latest-8-cores - if: github.event.pull_request.draft == false || github.ref == 'refs/heads/main' + runs-on: ubuntu-latest-4-cores + if: > + github.event.pull_request.draft == false || + github.ref == 'refs/heads/main' || + (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || + github.event.action == 'ready_for_review' || + github.event_name == 'workflow_dispatch' steps: - uses: actions/checkout@master diff --git a/.github/workflows/sanity-checks.yml b/.github/workflows/sanity-checks.yml index 832ecf3642..d102ab1f31 100644 --- a/.github/workflows/sanity-checks.yml +++ b/.github/workflows/sanity-checks.yml @@ -1,5 +1,6 @@ on: pull_request: + types: [opened, synchronize, reopened, ready_for_review] name: Sanity checks concurrency: group: 'tests-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'