Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Turn on code coverage #584

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Run Coverage

on:
push:
workflow_dispatch: {}

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- name: Checkout code
uses: actions/checkout@v2

run-tests:
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Load issue number
uses: actions/github-script@v6
id: get_issue_number
with:
script: |
if (context.issue.number) {
// Return issue number if present
return context.issue.number;
} else {
// Otherwise return issue number from commit
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0].number;
}
result-encoding: string
- name: Checkout code
uses: actions/checkout@v2
- name: Install lcov
run: |
sudo apt-get install lcov
id: lcov
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run coverage
run: forge coverage --report lcov
- name: Prune coverage report
run: lcov --remove ./lcov.info -o ./lcov.info.pruned 'src/test/*' 'script/*' --ignore-errors inconsistent
- name: Generate reports
run: genhtml -o report ./lcov.info.pruned
- name: Upload coverage results (s3 link here)
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: report/*
- name: View Coverage (text here)
id: print_coverage
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "comment_contents<<$EOF" >> $GITHUB_OUTPUT
echo "$(lcov --list ./lcov.info.pruned --ignore-errors inconsistent)" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Comment the full report
uses: actions/github-script@v7
with:
script: |
let body = `${{ steps.print_coverage.outputs.comment_contents }}`;
github.rest.issues.createComment({
issue_number: ${{ steps.get_issue_number.outputs.result }},
owner: context.repo.owner,
repo: context.repo.repo,
body: `
\`\`\`
${body}
\`\`\`
`
})
Loading
Loading