From 13d47ec0e347605a0ccbb586dec061874ab9e170 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Tue, 30 Jan 2024 23:33:10 +0000 Subject: [PATCH 01/13] Creating code coverage workflow --- .github/workflows/cargo-llvm-cov.yml | 55 ++++++++++++++++++++++++---- scripts/simtest/cargo-simtest | 10 +++++ 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 1f113f8719184..42f8d64055764 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -2,32 +2,71 @@ name: Code Coverage on: workflow_dispatch: +env: + CARGO_TERM_COLOR: always + # Disable incremental compilation. + # + # Incremental compilation is useful as part of an edit-build-test-edit cycle, + # as it lets the compiler avoid recompiling code that hasn't changed. However, + # on CI, we're not making small edits; we're almost always building the entire + # project from scratch. Thus, incremental compilation on CI actually + # introduces *additional* overhead to support making future builds + # faster...but no future builds will ever occur in any given CI environment. + # + # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow + # for details. + CARGO_INCREMENTAL: 0 + # Allow more retries for network requests in cargo (downloading crates) and + # rustup (installing toolchains). This should help to reduce flaky CI failures + # from transient network timeouts or other issues. + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + # Don't emit giant backtraces in the CI logs. + RUST_BACKTRACE: short + # RUSTFLAGS: -D warnings + RUSTDOCFLAGS: -D warnings + jobs: cargo-llvm-cov: name: Generate code coverage - runs-on: ubuntu-ghcloud + runs-on: [ubuntu-ghcloud] + timeout-minutes: 120 env: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - uses: bmwill/rust-cache@v1 + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + + - name: Install nextest + uses: taiki-e/install-action@nextest + - name: Set Swap Space uses: pierotofy/set-swap-space@master with: - swap-size-gb: 256 + swap-size-gb: 256 - name: Install Rust run: rustup update stable + + # - name: Run code coverage for nextest + # run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov + # - name: Upload report to Codecov for nextest + # uses: codecov/codecov-action@v3 + # with: + # files: lcov.info + # fail_ci_if_error: true - - name: Generate code coverage - run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + - name: Run code coverage for simtest + run: | + ./scripts/simtest/install.sh + ./scripts/simtest/cargo-simtest simtest codecov - - name: Upload coverage to Codecov + - name: Upload report to Codecov for simtest uses: codecov/codecov-action@v3 with: files: lcov.info - fail_ci_if_error: true + fail_ci_if_error: true diff --git a/scripts/simtest/cargo-simtest b/scripts/simtest/cargo-simtest index f8f44c6c87b10..282600bd1a0bd 100755 --- a/scripts/simtest/cargo-simtest +++ b/scripts/simtest/cargo-simtest @@ -7,6 +7,12 @@ if [ "$1" != "simtest" ]; then exit 1 fi +CODE_COV=0 +if [ "$2" == "codecov" ]; then + CODE_COV=1 + shift +fi + # consume simtest arg shift @@ -93,6 +99,10 @@ if [ "$1" = "build" ]; then CARGO_COMMAND=(build --profile simulator) fi +if [ $CODE_COV == 1 ]; then + CARGO_COMMAND=(llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest) +fi + # Must supply a new temp dir - the test is deterministic and can't choose one randomly itself. export TMPDIR=$(mktemp -d) From a9dd95c6408bce5a68f493b6d857400971c67037 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Wed, 31 Jan 2024 00:36:38 +0000 Subject: [PATCH 02/13] use env. variable instead --- .github/workflows/cargo-llvm-cov.yml | 55 ++++------------------------ scripts/simtest/cargo-simtest | 10 +---- 2 files changed, 10 insertions(+), 55 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 42f8d64055764..1f113f8719184 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -2,71 +2,32 @@ name: Code Coverage on: workflow_dispatch: -env: - CARGO_TERM_COLOR: always - # Disable incremental compilation. - # - # Incremental compilation is useful as part of an edit-build-test-edit cycle, - # as it lets the compiler avoid recompiling code that hasn't changed. However, - # on CI, we're not making small edits; we're almost always building the entire - # project from scratch. Thus, incremental compilation on CI actually - # introduces *additional* overhead to support making future builds - # faster...but no future builds will ever occur in any given CI environment. - # - # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow - # for details. - CARGO_INCREMENTAL: 0 - # Allow more retries for network requests in cargo (downloading crates) and - # rustup (installing toolchains). This should help to reduce flaky CI failures - # from transient network timeouts or other issues. - CARGO_NET_RETRY: 10 - RUSTUP_MAX_RETRIES: 10 - # Don't emit giant backtraces in the CI logs. - RUST_BACKTRACE: short - # RUSTFLAGS: -D warnings - RUSTDOCFLAGS: -D warnings - jobs: cargo-llvm-cov: name: Generate code coverage - runs-on: [ubuntu-ghcloud] - timeout-minutes: 120 + runs-on: ubuntu-ghcloud env: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - uses: bmwill/rust-cache@v1 - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov - - - name: Install nextest - uses: taiki-e/install-action@nextest - - name: Set Swap Space uses: pierotofy/set-swap-space@master with: - swap-size-gb: 256 + swap-size-gb: 256 - name: Install Rust run: rustup update stable - - # - name: Run code coverage for nextest - # run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest - # - name: Upload report to Codecov for nextest - # uses: codecov/codecov-action@v3 - # with: - # files: lcov.info - # fail_ci_if_error: true + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov - - name: Run code coverage for simtest - run: | - ./scripts/simtest/install.sh - ./scripts/simtest/cargo-simtest simtest codecov + - name: Generate code coverage + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info - - name: Upload report to Codecov for simtest + - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: files: lcov.info - fail_ci_if_error: true + fail_ci_if_error: true diff --git a/scripts/simtest/cargo-simtest b/scripts/simtest/cargo-simtest index 282600bd1a0bd..3f7511963272d 100755 --- a/scripts/simtest/cargo-simtest +++ b/scripts/simtest/cargo-simtest @@ -7,12 +7,6 @@ if [ "$1" != "simtest" ]; then exit 1 fi -CODE_COV=0 -if [ "$2" == "codecov" ]; then - CODE_COV=1 - shift -fi - # consume simtest arg shift @@ -99,8 +93,8 @@ if [ "$1" = "build" ]; then CARGO_COMMAND=(build --profile simulator) fi -if [ $CODE_COV == 1 ]; then - CARGO_COMMAND=(llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest) +if [ -n "$CODECOV" ]; then + CARGO_COMMAND=(llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest --cargo-profile simulator) fi # Must supply a new temp dir - the test is deterministic and can't choose one randomly itself. From 82d536c13a948595b66f52f59eaa1baf75637ed9 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Wed, 31 Jan 2024 00:38:14 +0000 Subject: [PATCH 03/13] set variable --- .github/workflows/cargo-llvm-cov.yml | 56 ++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 1f113f8719184..2c98d6de419d4 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -2,32 +2,72 @@ name: Code Coverage on: workflow_dispatch: +env: + CARGO_TERM_COLOR: always + # Disable incremental compilation. + # + # Incremental compilation is useful as part of an edit-build-test-edit cycle, + # as it lets the compiler avoid recompiling code that hasn't changed. However, + # on CI, we're not making small edits; we're almost always building the entire + # project from scratch. Thus, incremental compilation on CI actually + # introduces *additional* overhead to support making future builds + # faster...but no future builds will ever occur in any given CI environment. + # + # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow + # for details. + CARGO_INCREMENTAL: 0 + # Allow more retries for network requests in cargo (downloading crates) and + # rustup (installing toolchains). This should help to reduce flaky CI failures + # from transient network timeouts or other issues. + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + # Don't emit giant backtraces in the CI logs. + RUST_BACKTRACE: short + # RUSTFLAGS: -D warnings + RUSTDOCFLAGS: -D warnings + CODECOV: true + jobs: cargo-llvm-cov: name: Generate code coverage - runs-on: ubuntu-ghcloud + runs-on: [ubuntu-ghcloud] + timeout-minutes: 120 env: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 - uses: bmwill/rust-cache@v1 + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + + - name: Install nextest + uses: taiki-e/install-action@nextest + - name: Set Swap Space uses: pierotofy/set-swap-space@master with: - swap-size-gb: 256 + swap-size-gb: 256 - name: Install Rust run: rustup update stable + + # - name: Run code coverage for nextest + # run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov + # - name: Upload report to Codecov for nextest + # uses: codecov/codecov-action@v3 + # with: + # files: lcov.info + # fail_ci_if_error: true - - name: Generate code coverage - run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + - name: Run code coverage for simtest + run: | + ./scripts/simtest/install.sh + CODECOV=1 ./scripts/simtest/cargo-simtest simtest - - name: Upload coverage to Codecov + - name: Upload report to Codecov for simtest uses: codecov/codecov-action@v3 with: files: lcov.info - fail_ci_if_error: true + fail_ci_if_error: true From 52c7c92d96d7a28358d0f3550691ae40a406c089 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Wed, 31 Jan 2024 00:52:59 +0000 Subject: [PATCH 04/13] testing simtest by itself --- .github/workflows/cargo-llvm-cov.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 2c98d6de419d4..4dad2ba67dfbb 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -25,7 +25,7 @@ env: RUST_BACKTRACE: short # RUSTFLAGS: -D warnings RUSTDOCFLAGS: -D warnings - CODECOV: true + CODECOV: 1 jobs: cargo-llvm-cov: @@ -64,7 +64,7 @@ jobs: - name: Run code coverage for simtest run: | ./scripts/simtest/install.sh - CODECOV=1 ./scripts/simtest/cargo-simtest simtest + ./scripts/simtest/cargo-simtest simtest - name: Upload report to Codecov for simtest uses: codecov/codecov-action@v3 From a30c666fefaa711692e80211c9e1049f04b73d96 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Wed, 31 Jan 2024 00:53:50 +0000 Subject: [PATCH 05/13] removing code cov variable --- .github/workflows/cargo-llvm-cov.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 4dad2ba67dfbb..3297c0df01729 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -25,7 +25,6 @@ env: RUST_BACKTRACE: short # RUSTFLAGS: -D warnings RUSTDOCFLAGS: -D warnings - CODECOV: 1 jobs: cargo-llvm-cov: From f8180b9a270c6ae3edd7eac276734f4eddc46715 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Wed, 31 Jan 2024 16:40:48 +0000 Subject: [PATCH 06/13] add cargo update --- .github/workflows/cargo-llvm-cov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 3297c0df01729..ff063a5c471b7 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -63,6 +63,7 @@ jobs: - name: Run code coverage for simtest run: | ./scripts/simtest/install.sh + cargo update ./scripts/simtest/cargo-simtest simtest - name: Upload report to Codecov for simtest From 004e37fbc36e2773c5dd5dddfe150e3350fc61da Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Wed, 31 Jan 2024 17:50:05 +0000 Subject: [PATCH 07/13] Add slack message --- .github/workflows/cargo-llvm-cov.yml | 96 ++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index ff063a5c471b7..0ae4692893c15 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -1,5 +1,7 @@ name: Code Coverage on: + # schedule: + # - cron: '0 9 * * *' # UTC timing is every day at 1am PST workflow_dispatch: env: @@ -51,23 +53,91 @@ jobs: - name: Install Rust run: rustup update stable - # - name: Run code coverage for nextest - # run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest + - name: Run code coverage for nextest + run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest - # - name: Upload report to Codecov for nextest + - name: Upload report to Codecov for nextest + uses: codecov/codecov-action@v3 + with: + files: lcov.info + fail_ci_if_error: true + + # - name: Run code coverage for simtest + # run: | + # ./scripts/simtest/install.sh + # cargo update + # ./scripts/simtest/cargo-simtest simtest + + # - name: Upload report to Codecov for simtest # uses: codecov/codecov-action@v3 # with: # files: lcov.info # fail_ci_if_error: true - - name: Run code coverage for simtest - run: | - ./scripts/simtest/install.sh - cargo update - ./scripts/simtest/cargo-simtest simtest + notify: + name: Notify + needs: [cargo-llvm-cov] + runs-on: ubuntu-latest + if: always() # always notify - - name: Upload report to Codecov for simtest - uses: codecov/codecov-action@v3 - with: - files: lcov.info - fail_ci_if_error: true + steps: + - uses: technote-space/workflow-conclusion-action@v3 + + - name: Checkout sui repo main branch + uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # pin@v3 + + - name: Get sui commit + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + export sui_sha=$(git rev-parse HEAD) + echo "sui_sha=${sui_sha}" >> $GITHUB_ENV + + - name: Get link to logs + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh_job_link=$(gh api -X GET 'repos/MystenLabs/sui/actions/runs/${{ github.run_id }}/jobs' --jq '.jobs.[0].html_url') + echo "gh_job_link=${gh_job_link}" >> $GITHUB_ENV + + - name: Post to slack + uses: slackapi/slack-github-action@v1.24.0 # pin@v1.21.0 + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + SUI_SHA: ${{ env.sui_sha }} + GH_JOB_LINK: ${{ env.gh_job_link }} + with: + channel-id: 'code-coverage' + payload: | + { + "text": "*${{ github.workflow }}* workflow status: `${{ env.WORKFLOW_CONCLUSION }}`", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*${{ github.workflow }}* workflow status: `${{ env.WORKFLOW_CONCLUSION }}`" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "Sui commit: \nRun: <${{ env.GH_JOB_LINK }}|${{ github.run_id }}>" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "@sui-core, Please look over the code coverage for the main branch" + } + } + ] + } From 634dfc97b59eca031bbe21e11071fe457c9a66e7 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Wed, 31 Jan 2024 19:33:27 +0000 Subject: [PATCH 08/13] run simtests again --- .github/workflows/cargo-llvm-cov.yml | 29 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 0ae4692893c15..ffe182c9fa693 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -53,27 +53,26 @@ jobs: - name: Install Rust run: rustup update stable - - name: Run code coverage for nextest - run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest + # - name: Run code coverage for nextest + # run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest - - name: Upload report to Codecov for nextest - uses: codecov/codecov-action@v3 - with: - files: lcov.info - fail_ci_if_error: true - - # - name: Run code coverage for simtest - # run: | - # ./scripts/simtest/install.sh - # cargo update - # ./scripts/simtest/cargo-simtest simtest - - # - name: Upload report to Codecov for simtest + # - name: Upload report to Codecov for nextest # uses: codecov/codecov-action@v3 # with: # files: lcov.info # fail_ci_if_error: true + - name: Run code coverage for simtest + run: | + ./scripts/simtest/install.sh + CODECOV=1 ./scripts/simtest/cargo-simtest simtest + + - name: Upload report to Codecov for simtest + uses: codecov/codecov-action@v3 + with: + files: lcov.info + fail_ci_if_error: true + notify: name: Notify needs: [cargo-llvm-cov] From f243fd6e84030689979b6e2f06fa2b671e7ab4a7 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Thu, 1 Feb 2024 17:29:13 +0000 Subject: [PATCH 09/13] Adding branch info and disabling simtests for now --- .github/workflows/cargo-llvm-cov.yml | 42 ++++++++++++++++++---------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index ffe182c9fa693..5c271ed35bcf3 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -53,26 +53,28 @@ jobs: - name: Install Rust run: rustup update stable - # - name: Run code coverage for nextest - # run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest + - name: Run code coverage for nextest + run: SUI_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest - # - name: Upload report to Codecov for nextest - # uses: codecov/codecov-action@v3 - # with: - # files: lcov.info - # fail_ci_if_error: true - - - name: Run code coverage for simtest - run: | - ./scripts/simtest/install.sh - CODECOV=1 ./scripts/simtest/cargo-simtest simtest - - - name: Upload report to Codecov for simtest + - name: Upload report to Codecov for nextest uses: codecov/codecov-action@v3 with: files: lcov.info fail_ci_if_error: true + # TODO: Will enable this once we get this work + # + # - name: Run code coverage for simtest + # run: | + # ./scripts/simtest/install.sh + # CODECOV=1 ./scripts/simtest/cargo-simtest simtest + + # - name: Upload report to Codecov for simtest + # uses: codecov/codecov-action@v3 + # with: + # files: lcov.info + # fail_ci_if_error: true + notify: name: Notify needs: [cargo-llvm-cov] @@ -92,6 +94,16 @@ jobs: export sui_sha=$(git rev-parse HEAD) echo "sui_sha=${sui_sha}" >> $GITHUB_ENV + - name: Get a branch name for a sui commit + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + export sui_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/MystenLabs/sui/commits/${{ env.SUI_SHA }}/branches-where-head --jq '.[].name' | head -n 1) + # if the commit is not the head of the branch, get it's base branch + [[ -z $sui_branch_name ]] && export sui_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/MystenLabs/sui/commits/${{ env.SUI_SHA }}/pulls --jq '.[].base.ref' | head -n 1) + echo "sui_branch_name=${sui_branch_name}" >> $GITHUB_ENV + echo "sui_branch_name=${sui_branch_name}" + - name: Get link to logs env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -125,7 +137,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "Sui commit: \nRun: <${{ env.GH_JOB_LINK }}|${{ github.run_id }}>" + "text": "Sui commit: \n sui branch: `${{ env.sui_branch_name }}`\nRun: <${{ env.GH_JOB_LINK }}|${{ github.run_id }}>" } }, { From cab3ab3d93e6c42ed043ca7e29d8a865212aecb2 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Thu, 1 Feb 2024 18:06:25 +0000 Subject: [PATCH 10/13] Updating slack message --- .github/workflows/cargo-llvm-cov.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 5c271ed35bcf3..367866fd77f36 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -98,11 +98,10 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - export sui_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/MystenLabs/sui/commits/${{ env.SUI_SHA }}/branches-where-head --jq '.[].name' | head -n 1) + export sui_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/MystenLabs/sui/commits/${{ env.sui_sha }}/branches-where-head --jq '.[].name' | head -n 1) # if the commit is not the head of the branch, get it's base branch - [[ -z $sui_branch_name ]] && export sui_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/MystenLabs/sui/commits/${{ env.SUI_SHA }}/pulls --jq '.[].base.ref' | head -n 1) + [[ -z $sui_branch_name ]] && export sui_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/MystenLabs/sui/commits/${{ env.sui_sha }}/pulls --jq '.[].base.ref' | head -n 1) echo "sui_branch_name=${sui_branch_name}" >> $GITHUB_ENV - echo "sui_branch_name=${sui_branch_name}" - name: Get link to logs env: @@ -116,6 +115,7 @@ jobs: env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} SUI_SHA: ${{ env.sui_sha }} + SUI_BRANCH_NAME: ${{ env.sui_branch_name }} GH_JOB_LINK: ${{ env.gh_job_link }} with: channel-id: 'code-coverage' @@ -137,7 +137,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "Sui commit: \n sui branch: `${{ env.sui_branch_name }}`\nRun: <${{ env.GH_JOB_LINK }}|${{ github.run_id }}>" + "text": "Sui commit: \nSui branch: `${{ env.SUI_BRANCH_NAME }}`\nRun: <${{ env.GH_JOB_LINK }}|${{ github.run_id }}>" } }, { @@ -147,7 +147,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "@sui-core, Please look over the code coverage for the main branch" + "text": "@sui-core, Please look over the code coverage for the ${{ env.SUI_BRANCH_NAME }} branch in Sui repo." } } ] From 7f0c61217a2f45f9baf4e1bf1da399744737ec7a Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Thu, 1 Feb 2024 19:01:40 +0000 Subject: [PATCH 11/13] fix branch name url --- .github/workflows/cargo-llvm-cov.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 367866fd77f36..a5d242b80da7a 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -102,6 +102,7 @@ jobs: # if the commit is not the head of the branch, get it's base branch [[ -z $sui_branch_name ]] && export sui_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/MystenLabs/sui/commits/${{ env.sui_sha }}/pulls --jq '.[].base.ref' | head -n 1) echo "sui_branch_name=${sui_branch_name}" >> $GITHUB_ENV + echo "sui_branch_name_url=$(echo ${sui_branch_name} | sed 's\/\%2F\g')" >> $GITHUB_ENV - name: Get link to logs env: @@ -116,6 +117,7 @@ jobs: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} SUI_SHA: ${{ env.sui_sha }} SUI_BRANCH_NAME: ${{ env.sui_branch_name }} + SUI_BRANCH_NAME_URL: ${{ env.sui_branch_name_url }} GH_JOB_LINK: ${{ env.gh_job_link }} with: channel-id: 'code-coverage' @@ -147,7 +149,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "@sui-core, Please look over the code coverage for the ${{ env.SUI_BRANCH_NAME }} branch in Sui repo." + "text": "@sui-core, Please look over the code coverage for the `${{ env.SUI_BRANCH_NAME }}` branch in Sui repo." } } ] From 9fa88c84bd33008a340b051ce5d419cbc3df30c1 Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Thu, 1 Feb 2024 19:03:00 +0000 Subject: [PATCH 12/13] enable schedule --- .github/workflows/cargo-llvm-cov.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index a5d242b80da7a..a39293a5f15a4 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -1,7 +1,7 @@ name: Code Coverage on: - # schedule: - # - cron: '0 9 * * *' # UTC timing is every day at 1am PST + schedule: + - cron: '0 9 * * *' # UTC timing is every day at 1am PST workflow_dispatch: env: From 96764f226f7bbf9f3850858dddafc04068b28b8c Mon Sep 17 00:00:00 2001 From: Eugene Boguslavsky Date: Fri, 2 Feb 2024 18:35:35 +0000 Subject: [PATCH 13/13] Dynamically looking up sui-core oncall --- .github/workflows/cargo-llvm-cov.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index a39293a5f15a4..207c324bc8cab 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -109,7 +109,26 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh_job_link=$(gh api -X GET 'repos/MystenLabs/sui/actions/runs/${{ github.run_id }}/jobs' --jq '.jobs.[0].html_url') - echo "gh_job_link=${gh_job_link}" >> $GITHUB_ENV + echo "gh_job_link=${gh_job_link}" >> $GITHUB_ENV + + - name: Get current sui-core oncall + id: pagerduty + uses: mxie/pagerduty-oncall-action@main + with: + token: ${{ secrets.PAGERDUTY_ACCESS_KEY }} + schedule-id: PGCQ3YS # sui-core + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # pin@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Get slack id for the oncall + run: | + export slack_id=$(aws s3 cp s3://mysten-employees-dir/employees.json - | jq --arg ONCALL "${{ steps.pagerduty.outputs.person }}" '.[] | if .name == $ONCALL then .slack_id else empty end') + echo "slack_id=$(echo ${slack_id} | tr -d '"')" >> $GITHUB_ENV - name: Post to slack uses: slackapi/slack-github-action@v1.24.0 # pin@v1.21.0 @@ -149,7 +168,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "@sui-core, Please look over the code coverage for the `${{ env.SUI_BRANCH_NAME }}` branch in Sui repo." + "text": "<@${{ env.slack_id }}> (current sui-core oncall), please look over the code coverage for the `${{ env.SUI_BRANCH_NAME }}` branch in Sui repo." } } ]