From de6429aea1c07e12c4e7d88d55ff4f12c296c799 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 14:51:47 +0100 Subject: [PATCH 01/12] add try-runtime to ci pipeline --- .github/workflows/try-runtime.yml | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/try-runtime.yml diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml new file mode 100644 index 0000000000..24f4960f38 --- /dev/null +++ b/.github/workflows/try-runtime.yml @@ -0,0 +1,50 @@ +on: + schedule: + - cron: '0 0 * * 0' # At 00:00 on Sunday + pull_request: + types: [labeled] + paths: + - '**.rs' + - .github/workflows/try-runtime.yml +jobs: + try-runtime-altair: + if: contains(github.event.pull_request.labels.*.name, 'D8-migration') + runs-on: ubuntu-latest-4-cores + steps: + - name: Check out code + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 + + - name: Prep build on Ubuntu + uses: ./.github/actions/prep-ubuntu + + - name: Install try-runtime-cli + run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.5.4 --locked + + - name: Run try-runtime + run: | + RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ + cargo run --release --features try-runtime try-runtime \ + --runtime target/release/wbuild/altair-runtime/altair_runtime.wasm \ + --chain altair on-runtime-upgrade live \ + --uri wss://fullnode.altair.centrifuge.io:443 + + try-runtime-centrifuge: + if: contains(github.event.pull_request.labels.*.name, 'D8-migration') + runs-on: ubuntu-latest-4-cores + steps: + - name: Check out code + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 + + - name: Prep build on Ubuntu + uses: ./.github/actions/prep-ubuntu + + - name: Install try-runtime-cli + run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.5.4 --locked + + - name: Run try-runtime + run: | + RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ + cargo run --release --features try-runtime try-runtime \ + --runtime target/release/wbuild/centrifuge-runtime/centrifuge_runtime.wasm \ + --chain centrifuge on-runtime-upgrade live --uri wss://fullnode.centrifuge.io:443 +# centrifuge y altair -> run on both chains \ No newline at end of file From 3bd82320ecb123f6a2b37bd2d4f69a8d7faae369 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 14:58:47 +0100 Subject: [PATCH 02/12] bundle code with matrix --- .github/workflows/try-runtime.yml | 42 ++++++++++++------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 24f4960f38..ed7ad0d6af 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -1,15 +1,19 @@ on: schedule: - - cron: '0 0 * * 0' # At 00:00 on Sunday + - cron: '0 6 * * 0' # At 00:00 on Sunday pull_request: types: [labeled] paths: - '**.rs' - .github/workflows/try-runtime.yml jobs: - try-runtime-altair: - if: contains(github.event.pull_request.labels.*.name, 'D8-migration') + try-runtime: + strategy: + matrix: + chain: [altair, centrifuge] + if: github.event_name == 'schedule' || contains(github.event.pull_request.labels.*.name, 'D8-migration') runs-on: ubuntu-latest-4-cores + name: try-runtime "${{ matrix.chain }}" steps: - name: Check out code uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 @@ -20,31 +24,17 @@ jobs: - name: Install try-runtime-cli run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.5.4 --locked - - name: Run try-runtime + - name: Run try-runtime run: | - RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ - cargo run --release --features try-runtime try-runtime \ - --runtime target/release/wbuild/altair-runtime/altair_runtime.wasm \ - --chain altair on-runtime-upgrade live \ - --uri wss://fullnode.altair.centrifuge.io:443 - - try-runtime-centrifuge: - if: contains(github.event.pull_request.labels.*.name, 'D8-migration') - runs-on: ubuntu-latest-4-cores - steps: - - name: Check out code - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 - - - name: Prep build on Ubuntu - uses: ./.github/actions/prep-ubuntu - - - name: Install try-runtime-cli - run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.5.4 --locked - - - name: Run try-runtime - run: | + if [ "${{ matrix.chain }}" == "altair" ]; then + RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ + cargo run --release --features try-runtime try-runtime \ + --runtime target/release/wbuild/altair-runtime/altair_runtime.wasm \ + --chain altair on-runtime-upgrade live \ + --uri wss://fullnode.altair.centrifuge.io:443 + elif [ "${{ matrix.chain }}" == "centrifuge" ]; then RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ cargo run --release --features try-runtime try-runtime \ --runtime target/release/wbuild/centrifuge-runtime/centrifuge_runtime.wasm \ --chain centrifuge on-runtime-upgrade live --uri wss://fullnode.centrifuge.io:443 -# centrifuge y altair -> run on both chains \ No newline at end of file + fi From 1e0b48b4ab7dda0cb53c45e49e7308ac1365eaf5 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 15:28:25 +0100 Subject: [PATCH 03/12] allow trigger also on comments --- .github/workflows/try-runtime.yml | 47 ++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index ed7ad0d6af..7cb00725cf 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -1,23 +1,68 @@ on: schedule: - cron: '0 6 * * 0' # At 00:00 on Sunday + issue_comment: + types: [created] pull_request: types: [labeled] paths: - '**.rs' - .github/workflows/try-runtime.yml jobs: + comment-checks: + if: > + github.event_name == 'issue_comment' && + github.event.issue.pull_request != '' && + contains(github.event.comment.body, '/try-runtime') + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + try-runtime: strategy: matrix: chain: [altair, centrifuge] - if: github.event_name == 'schedule' || contains(github.event.pull_request.labels.*.name, 'D8-migration') + if: > + github.event_name == 'schedule' || + contains(github.event.pull_request.labels.*.name, 'D8-migration') || + (github.event_name == 'issue_comment' && + contains(github.event.comment.body, '/try-runtime') && + github.event.issue.pull_request != '') + runs-on: ubuntu-latest-4-cores name: try-runtime "${{ matrix.chain }}" steps: - name: Check out code uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 + - name: Get PR author and commenter + id: get-users + if: github.event_name == 'issue_comment' + run: | + PR_AUTHOR=$(gh pr view ${{ github.event.issue.number }} --json author --jq .author.login) + COMMENT_AUTHOR="${{ github.event.comment.user.login }}" + echo "::set-output name=pr_author::$PR_AUTHOR" + echo "::set-output name=comment_author::$COMMENT_AUTHOR" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if commenter is PR author and a repo contributor + if: > + steps.get-users.outputs.pr_author == steps.get-users.outputs.comment_author && + github.event_name == 'issue_comment' + run: | + if [[ "${{ steps.get-users.outputs.pr_author }}" != "${{ steps.get-users.outputs.comment_author }}" ]]; then + echo "PR author is not the comment author." + exit 1 + fi + CONTRIBUTOR_CHECK=$(gh api repos/${{ github.repository }}/contributors --jq '.[].login | select(. == "${{ steps.get-users.outputs.comment_author }}")') + if [[ -z "$CONTRIBUTOR_CHECK" ]]; then + echo "Commenter is not a contributor." + exit 1 + fi + echo "Commenter is a contributor and PR author." + - name: Prep build on Ubuntu uses: ./.github/actions/prep-ubuntu From 1566ab0314b780ad11f237d4d5fa568d691e04f4 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 15:35:20 +0100 Subject: [PATCH 04/12] remove comment-checks: --- .github/workflows/try-runtime.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 7cb00725cf..8a94ae24fb 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -9,16 +9,6 @@ on: - '**.rs' - .github/workflows/try-runtime.yml jobs: - comment-checks: - if: > - github.event_name == 'issue_comment' && - github.event.issue.pull_request != '' && - contains(github.event.comment.body, '/try-runtime') - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - try-runtime: strategy: matrix: From 2d60bae8f4bbff424c273f507ccfbee651107c30 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 15:53:35 +0100 Subject: [PATCH 05/12] Move logic to run-check & remove compiling try-runtime --- .github/workflows/try-runtime.yml | 21 ++++++--------------- ci/run-check.sh | 21 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 8a94ae24fb..98b71899a1 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -56,20 +56,11 @@ jobs: - name: Prep build on Ubuntu uses: ./.github/actions/prep-ubuntu - - name: Install try-runtime-cli - run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.5.4 --locked + # - name: Install try-runtime-cli + # run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.5.4 --locked - name: Run try-runtime - run: | - if [ "${{ matrix.chain }}" == "altair" ]; then - RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ - cargo run --release --features try-runtime try-runtime \ - --runtime target/release/wbuild/altair-runtime/altair_runtime.wasm \ - --chain altair on-runtime-upgrade live \ - --uri wss://fullnode.altair.centrifuge.io:443 - elif [ "${{ matrix.chain }}" == "centrifuge" ]; then - RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ - cargo run --release --features try-runtime try-runtime \ - --runtime target/release/wbuild/centrifuge-runtime/centrifuge_runtime.wasm \ - --chain centrifuge on-runtime-upgrade live --uri wss://fullnode.centrifuge.io:443 - fi + run: ./ci/run-check.sh "${{ matrix.chain }}" + env: + TARGET: try-runtime + RUSTC_WRAPPER: "sccache" diff --git a/ci/run-check.sh b/ci/run-check.sh index c75124c403..a44a0eb3d0 100755 --- a/ci/run-check.sh +++ b/ci/run-check.sh @@ -41,7 +41,26 @@ case $TARGET in docs-build) RUSTDOCFLAGS="-D warnings" cargo doc --all --no-deps ;; - + + try-runtime) + if [ "$1" == "altair" ]; then + echo "Running try-runtime for altair" + RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ + cargo run --release --features try-runtime try-runtime \ + --runtime target/release/wbuild/altair-runtime/altair_runtime.wasm \ + --chain altair on-runtime-upgrade live \ + --uri wss://fullnode.altair.centrifuge.io:443 + elif [ "$1" == "centrifuge" ]; then + echo "Running try-runtime for centrifuge" + RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \ + cargo run --release --features try-runtime try-runtime \ + --runtime target/release/wbuild/centrifuge-runtime/centrifuge_runtime.wasm \ + --chain centrifuge on-runtime-upgrade live --uri wss://fullnode.centrifuge.io:443 + else + echo "Invalid argument. Please specify 'altair' or 'centrifuge'." + exit 1 + fi + ;; subalfred) # Find all child directories containing Cargo.toml files # TODO: Filter by crates found in the workspace From 73b80417b4eb8bb30f36edae29dcdc942c774d97 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 15:56:09 +0100 Subject: [PATCH 06/12] activate sccache --- .github/workflows/try-runtime.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 98b71899a1..1d20424f58 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -55,6 +55,10 @@ jobs: - name: Prep build on Ubuntu uses: ./.github/actions/prep-ubuntu + with: + cache: enabled + GWIP: ${{ secrets.GWIP_SCCACHE }} + GSA: ${{ secrets.GSA_SCCACHE }} # - name: Install try-runtime-cli # run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.5.4 --locked From 8903e38463ba156265ef10dc3504e4c757c1d315 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 15:57:47 +0100 Subject: [PATCH 07/12] add missing secret permissions --- .github/workflows/try-runtime.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 1d20424f58..aa4edf5969 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -10,6 +10,9 @@ on: - .github/workflows/try-runtime.yml jobs: try-runtime: + permissions: + id-token: write + contents: read strategy: matrix: chain: [altair, centrifuge] From 30c9eac4843b7ffdb5abe0aca0d428dd2c1cd082 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 16:23:22 +0100 Subject: [PATCH 08/12] compile first then run try-runtime --- .github/workflows/try-runtime.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index aa4edf5969..8b4517dca6 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -1,3 +1,4 @@ +name: try-runtime on: schedule: - cron: '0 6 * * 0' # At 00:00 on Sunday @@ -24,7 +25,7 @@ jobs: github.event.issue.pull_request != '') runs-on: ubuntu-latest-4-cores - name: try-runtime "${{ matrix.chain }}" + name: "${{ matrix.chain }}" steps: - name: Check out code uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2 @@ -65,9 +66,13 @@ jobs: # - name: Install try-runtime-cli # run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.5.4 --locked - + - name: cargo build + run: ./ci/run-check.sh -F try-runtime + env: + TARGET: cargo-build + RUSTC_WRAPPER: "sccache" + - name: Run try-runtime run: ./ci/run-check.sh "${{ matrix.chain }}" env: TARGET: try-runtime - RUSTC_WRAPPER: "sccache" From e19e546328eb0ee831eefabf896fd902e0ad0eb0 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 18:06:45 +0100 Subject: [PATCH 09/12] keep running all try-runtime cases if one job fails --- .github/workflows/try-runtime.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 8b4517dca6..f580d4dff1 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -15,6 +15,7 @@ jobs: id-token: write contents: read strategy: + fail-fast: false matrix: chain: [altair, centrifuge] if: > From 5d08703ab13f24df6838de9d79eeb1325af756b9 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 18:22:57 +0100 Subject: [PATCH 10/12] add Slack notifications for scheduled jobs failing --- .github/workflows/try-runtime.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index f580d4dff1..6f1f58db6b 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -77,3 +77,21 @@ jobs: run: ./ci/run-check.sh "${{ matrix.chain }}" env: TARGET: try-runtime + + notify-slack: + needs: try-runtime + if: ${{ always() && needs.try-runtime.result == 'failure' }} && github.event_name == 'schedule' + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8 #v2.2.1 + env: + SLACK_CHANNEL: eng-protocol-general + SLACK_COLOR: '#FF0000' + SLACK_ICON: ':boom:' + SLACK_MESSAGE: | + Weekly try-runtime job failed on main branch. Please check: + <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|GHA Job URL> + SLACK_TITLE: 'Job Failure Notification' + SLACK_USERNAME: "Centrifuge GHA Bot" + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file From 84699c5f5d111408c55061115bae77e3bf3126d1 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 18:34:00 +0100 Subject: [PATCH 11/12] fix conditional for notify slack --- .github/workflows/try-runtime.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 6f1f58db6b..4b6b90d61c 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -80,7 +80,7 @@ jobs: notify-slack: needs: try-runtime - if: ${{ always() && needs.try-runtime.result == 'failure' }} && github.event_name == 'schedule' + if: always() && needs.try-runtime.result == 'failure' && github.event_name == 'schedule' runs-on: ubuntu-latest steps: - name: Notify Slack From 0793d24f70bebdcd467e28661ef566cce0a62d22 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Fri, 16 Feb 2024 18:36:06 +0100 Subject: [PATCH 12/12] fix slack icon --- .github/workflows/try-runtime.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 4b6b90d61c..ee92b7f6f4 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -88,7 +88,7 @@ jobs: env: SLACK_CHANNEL: eng-protocol-general SLACK_COLOR: '#FF0000' - SLACK_ICON: ':boom:' + SLACK_ICON: "https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png" SLACK_MESSAGE: | Weekly try-runtime job failed on main branch. Please check: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|GHA Job URL>