Code Coverage (llvm-cov) #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [self-hosted] | |
timeout-minutes: 120 | |
env: | |
CARGO_TERM_COLOR: always | |
steps: | |
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4 | |
- uses: bmwill/rust-cache@fb63fcd7a959767755b88b5af2f5cbf65fb8a127 # pin@v1 | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@125e82eef6e60d2b0c20d4d1f4cf81db37f68bf3 # pin@cargo-llvm-cov | |
- name: Install nextest | |
uses: taiki-e/install-action@7e58f89e24a544d88f7a74c6eed8a3df3fd4c658 # pin@nextest | |
- name: Set Swap Space | |
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # pin@master | |
with: | |
swap-size-gb: 256 | |
- name: Install Rust | |
run: rustup update stable | |
- name: Run code coverage for nextest | |
run: IOTA_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@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # pin@v4 | |
with: | |
files: lcov.info | |
- name: Run code coverage for simtest | |
run: | | |
git clean -fd | |
./scripts/simtest/codecov.sh | |
- name: Upload report to Codecov for simtest | |
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # pin@v4 | |
with: | |
files: lcov-simtest.info | |
notify: | |
name: Notify | |
needs: [cargo-llvm-cov] | |
runs-on: self-hosted | |
if: always() # always notify | |
steps: | |
- uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 # pin@v3 | |
- name: Checkout iota repo develop branch | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4 | |
- name: Get iota commit | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export iota_sha=$(git rev-parse HEAD) | |
echo "iota_sha=${iota_sha}" >> $GITHUB_ENV | |
- name: Get a branch name for a iota commit | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export iota_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/iotaledger/iota/commits/${{ env.iota_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 $iota_branch_name ]] && export iota_branch_name=$(gh api -H 'Accept: application/vnd.github+json' /repos/iotaledger/iota/commits/${{ env.iota_sha }}/pulls --jq '.[].base.ref' | head -n 1) | |
echo "iota_branch_name=${iota_branch_name}" >> $GITHUB_ENV | |
echo "iota_branch_name_url=$(echo ${iota_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/iotaledger/iota/actions/runs/${{ github.run_id }}/jobs' --jq '.jobs.[0].html_url') | |
echo "gh_job_link=${gh_job_link}" >> $GITHUB_ENV | |
- name: Get current oncall | |
run: | | |
export current_oncall=$(curl -s --request GET \ | |
--url 'https://api.pagerduty.com/oncalls?schedule_ids[]=PGCQ3YS' \ | |
--header 'Accept: application/json' \ | |
--header 'Authorization: Token token=${{ secrets.PAGERDUTY_ACCESS_KEY }}' \ | |
--header 'Content-Type: application/json' \ | |
| jq '.oncalls[].user.summary' | tr -d '"') | |
echo "current_oncall=$(echo ${current_oncall})" >> $GITHUB_ENV | |
export oncall_name=$(curl -s --request GET \ | |
--url 'https://api.pagerduty.com/oncalls?schedule_ids[]=PGCQ3YS' \ | |
--header 'Accept: application/json' \ | |
--header 'Authorization: Token token=${{ secrets.PAGERDUTY_ACCESS_KEY }}' \ | |
--header 'Content-Type: application/json' \ | |
| jq '.oncalls[].escalation_policy.summary' | tr -d '"') | |
echo "oncall_name=$(echo ${oncall_name})" >> $GITHUB_ENV | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # pin@v4 | |
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://iota-employees-dir/employees.json - | jq --arg ONCALL "${{ env.current_oncall }}" '.[] | 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@936158bbe252e9a6062e793ea4609642c966e302 # [email protected] | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
IOTA_SHA: ${{ env.iota_sha }} | |
IOTA_BRANCH_NAME: ${{ env.iota_branch_name }} | |
IOTA_BRANCH_NAME_URL: ${{ env.iota_branch_name_url }} | |
GH_JOB_LINK: ${{ env.gh_job_link }} | |
SLACK_ID: ${{ env.slack_id }} | |
ONCALL_NAME: ${{ env.oncall_name }} | |
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": "IOTA commit: <https://github.com/iotaledger/iota/commit/${{ env.IOTA_SHA }}|${{ env.IOTA_SHA }}>\nIOTA branch: `${{ env.IOTA_BRANCH_NAME }}`\nRun: <${{ env.GH_JOB_LINK }}|${{ github.run_id }}>" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "<@${{ env.SLACK_ID }}>, current `${{ env.ONCALL_NAME }}` oncall, please look over the code coverage <https://app.codecov.io/github/iotaledger/iota/tree/${{ env.IOTA_BRANCH_NAME_URL }}|report> for the `${{ env.IOTA_BRANCH_NAME }}` branch in IOTA repo." | |
} | |
} | |
] | |
} |