Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Oct 29, 2024
1 parent cc5ac66 commit 736e99a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 194 deletions.
177 changes: 22 additions & 155 deletions .github/workflows/cargo-llvm-cov.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Code Coverage
name: Code Coverage (llvm-cov)

on:
# Temporarily disabled until simtest job is fixed
# schedule:
# - cron: "0 9 * * *" # UTC timing is every day at 1am PST
schedule:
- cron: "0 1 * * *" # UTC timing is every day at 1am UTC
workflow_dispatch:

env:
Expand Down Expand Up @@ -31,8 +30,8 @@ env:
RUSTDOCFLAGS: -D warnings

jobs:
cargo-llvm-cov:
name: Generate code coverage
llvm-cov:
name: Generate code coverage (llvm-cov)
runs-on: [self-hosted]
timeout-minutes: 120
env:
Expand All @@ -50,163 +49,31 @@ jobs:
- name: Update Rust toolchain
run: rustup update stable

- name: Remove old coverage artifacts
- name: Generate code coverage (from nextest) # ./target/llvm-cov/html
run: |
if [ -d "./target/llvm-cov-target" ]; then
rm -rf ./target/llvm-cov-target
echo "Removed old artifacts"
else
echo "No artifacts found"
fi
- name: Run code coverage (nextest)
run: IOTA_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest
cargo llvm-cov clean
IOTA_SKIP_SIMTESTS=1 cargo llvm-cov --all-features --branch --ignore-run-fail --html nextest
- name: Upload coverage report (nextest)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # pin@v4
if: always()
with:
name: lcov.info
path: ./lcov.info
name: llvm-cov-nextest-html
path: target/llvm-cov/html
if-no-files-found: error
retention-days: 30

# - name: Clean up coverage artifacts
# run: |
# if [ -d "./target/llvm-cov-target" ]; then
# rm -rf ./target/llvm-cov-target
# echo "Previous Coverage artifacts removed"
# fi

# - name: Run code coverage (simtest)
# run: |
# git clean -fd
# ./scripts/simtest/codecov.sh
retention-days: 7

# - name: Upload coverage report (simtest)
# uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # pin@v4
# if: always()
# with:
# name: lcov-simtest.info
# path: ./lcov-simtest.info
# if-no-files-found: error
# retention-days: 30

- name: Clean up coverage artifacts
- name: Run code coverage (simtest)
run: |
if [ -d "./target/llvm-cov-target" ]; then
rm -rf ./target/llvm-cov-target
echo "Cleaned up coverage artificats"
fi
notify:
name: Notify
needs: [cargo-llvm-cov]
runs-on: self-hosted
if: always() # always notify
git clean -fd
./scripts/simtest/codecov.sh
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: Upload coverage report (simtest)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # pin@v4
if: always()
with:
name: llvm-cov-simtest-html
path: target/llvm-cov/html
if-no-files-found: error
retention-days: 7

# - 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."
# }
# }
# ]
# }
67 changes: 29 additions & 38 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Codecov
name: Code Coverage (grcov)

on:
# Temporarily disabled
Expand All @@ -23,33 +23,38 @@ jobs:
# - name: Detect Changes
# uses: "./.github/actions/diffs"
# id: diff

codecov-grcov:
name: Generate code coverage
grcov:
name: Generate code coverage (grcov)
# Temporarily disabled
# needs: diff
# Temporarily disabled
# if: github.event.pull_request.draft == false && needs.diff.outputs.isRust == 'true'
runs-on: [self-hosted]
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4
- run: rustup component add llvm-tools-preview
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
- name: Install grcov, and cache the binary
uses: baptiste0928/cargo-install@1cd874a5478fdca35d868ccc74640c5aabbb8f1b # [email protected]
with:
crate: grcov
locked: true
- uses: bmwill/rust-cache@fb63fcd7a959767755b88b5af2f5cbf65fb8a127 # pin@v1

- name: Install grcov
uses: taiki-e/install-action@grcov # pin@nextest

- name: Install nextest
uses: taiki-e/install-action@7e58f89e24a544d88f7a74c6eed8a3df3fd4c658 # pin@nextest

- name: Update Rust toolchain
run: rustup update stable

- name: Install llvm-tools-preview
run: rustup component add llvm-tools-preview

- name: Remove old coverage artifacts
run: |
if [ -d "./target/grcov-target" ]; then
rm -rf ./target/grcov-target
echo "Removed old artifacts"
else
echo "No artifacts found"
fi
if [ -d "./target/grcov" ]; then
rm -rf ./target/grcov
echo "Removed old artifacts."
else
echo "Target directory is clean."
fi
fi
- name: Build
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # [email protected]
Expand All @@ -63,34 +68,20 @@ jobs:
env:
RUSTFLAGS: "-Cinstrument-coverage"
RUSTDOCFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "target/grcov-target/codecov-instrumentation-%p-%m.profraw"
LLVM_PROFILE_FILE: "target/grcov/codecov-instrumentation-%p-%m.profraw"
run: |
mkdir target/grcov-target
mkdir -p target/grcov/html
cargo test
- name: Run grcov
run: grcov . --binary-path target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o target/grcov-target/coverage.lcov

- name: Create coverage report
run: |
cd target/grcov-target
genhtml -o coverage_report coverage.lcov --verbose --ignore-errors source --synthesize-missing
tar -czf coverage_report.tgz coverage_report/
grcov . --binary-path target/debug/ -s . -t html --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o target/grcov/html
- name: Upload coverage report
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # pin@v4
if: always()
with:
name: coverage_report.tgz
path: ./target/grcov-target/coverage_report.tgz
name: grcov-html
path: ./target/grcov/html
if-no-files-found: error
retention-days: 30

- name: Clean up coverage artifacts
run: |
if [ -d "./target/grcov-target" ]; then
rm -rf ./target/grcov-target
echo "Cleaned up coverage artifacts"
fi
retention-days: 7
4 changes: 3 additions & 1 deletion scripts/simtest/codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ git apply ./scripts/simtest/config-patch
root_dir=$(git rev-parse --show-toplevel)
export SIMTEST_STATIC_INIT_MOVE=$root_dir"/examples/move/basics"

MSIM_WATCHDOG_TIMEOUT_MS=60000 MSIM_TEST_SEED=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov-simtest.info nextest --cargo-profile simulator
cargo llvm-cov clean

MSIM_WATCHDOG_TIMEOUT_MS=60000 MSIM_TEST_SEED=1 cargo llvm-cov --all-features --branch --ignore-run-fail --html nextest --cargo-profile simulator

# remove the patch
git checkout .cargo/config Cargo.toml Cargo.lock

0 comments on commit 736e99a

Please sign in to comment.