Skip to content

Code Coverage

Code Coverage #2

name: Code Coverage
on:
schedule:
- cron: '0 9 * * *' # UTC timing is every day at 1am PST
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
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
- 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
# 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]
runs-on: ubuntu-latest
if: always() # always notify
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 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_url=$(echo ${sui_branch_name} | sed 's\/\%2F\g')" >> $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: 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/[email protected] # [email protected]
env:
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'
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: <https://github.com/MystenLabs/sui/commit/${{ env.SUI_SHA }}|${{ env.SUI_SHA }}>\nSui branch: `${{ env.SUI_BRANCH_NAME }}`\nRun: <${{ env.GH_JOB_LINK }}|${{ github.run_id }}>"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<@${{ env.slack_id }}> (current sui-core oncall), please look over the code coverage <https://app.codecov.io/github/MystenLabs/sui/tree/${{ env.SUI_BRANCH_NAME_URL }}|report> for the `${{ env.SUI_BRANCH_NAME }}` branch in Sui repo."
}
}
]
}