-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Generate and publish code coverage reports in the CI #1947
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
930b076
Setup codecov reporting
Dentosal a3184dd
Add missing env var and wasm32 target
Dentosal e782bff
Merge branch 'master' into dento/ci-codecov-reporting
Dentosal 90e3bc9
Add #[cfg(not(coverage))] to some too-slow tests
Dentosal 4a0d6a8
Merge branch 'master' into dento/ci-codecov-reporting
Dentosal 3c8c97c
Merge branch 'master' into dento/ci-codecov-reporting
MitchTurner fb27240
Merge branch 'master' into dento/ci-codecov-reporting
Dentosal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,11 @@ concurrency: | |
cancel-in-progress: true | ||
|
||
env: | ||
GIT_BRANCH: ${{ github.head_ref || github.ref_name }} | ||
CARGO_TERM_COLOR: always | ||
RUST_VERSION: 1.75.0 | ||
NIGHTLY_RUST_VERSION: nightly-2023-10-29 | ||
RUST_VERSION_FMT: nightly-2023-10-29 | ||
RUST_VERSION_COV: nightly-2024-06-05 | ||
RUSTFLAGS: -D warnings | ||
REGISTRY: ghcr.io | ||
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 | ||
|
@@ -39,11 +41,11 @@ jobs: | |
- name: Install latest nightly | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ env.NIGHTLY_RUST_VERSION }} | ||
toolchain: ${{ env.RUST_VERSION_FMT }} | ||
components: rustfmt | ||
|
||
- name: Rustfmt check | ||
run: cargo +${{ env.NIGHTLY_RUST_VERSION }} fmt --all -- --check | ||
run: cargo +${{ env.RUST_VERSION_FMT }} fmt --all -- --check | ||
|
||
lint-toml-files: | ||
runs-on: buildjet-4vcpu-ubuntu-2204 | ||
|
@@ -193,6 +195,48 @@ jobs: | |
check-repo: false | ||
ignore-unpublished-changes: true | ||
|
||
publish-codecov: | ||
name: Publish code coverage report on GitHub pages branch | ||
runs-on: buildjet-4vcpu-ubuntu-2204 | ||
needs: | ||
- cargo-verifications | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the vm pr we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This workflow doesn't have |
||
permissions: # Write access to push changes to pages | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install latest Rust | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ env.RUST_VERSION_COV }} | ||
targets: wasm32-unknown-unknown | ||
|
||
- name: Install cargo-llvm-codecov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
|
||
- name: Code coverage report | ||
run: cargo +${{ env.RUST_VERSION_COV }} llvm-cov --all-features --html --branch | ||
|
||
- name: Checkout the repo again for pushing pages revision | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: 'codecov-pages' | ||
path: 'pages-branch' | ||
|
||
- name: Push codecov report to pages branch | ||
working-directory: ./pages-branch | ||
run: | | ||
export BRANCH_B64=$(echo -n "${{ env.GIT_BRANCH }}" | basenc --base64url) | ||
git config user.email "2204863+Dentosal@users.noreply.github.com" | ||
git config user.name "Dentosal" | ||
cp -r ../target/llvm-cov/html "$BRANCH_B64" | ||
python3 ../.github/workflows/scripts/generate_pages_index.py > index.html | ||
git add . | ||
git commit -m "Update codecov for ${{ env.GIT_BRANCH }}" | ||
git push | ||
export PAGES_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/$BRANCH_B64/index.html" | ||
echo "$PAGES_URL" | ||
echo "Codecov report $PAGES_URL" >> $GITHUB_STEP_SUMMARY | ||
|
||
verifications-complete: | ||
needs: | ||
- cargo-verifications | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!python3 | ||
# Generate index.html for code coverage pages | ||
|
||
from glob import iglob | ||
from base64 import urlsafe_b64encode, urlsafe_b64decode | ||
|
||
master_path = urlsafe_b64encode(b"master").decode("utf-8") | ||
|
||
print("<html><head><title>Code Coverage</title>") | ||
print("<style>body { font-size: 1.2em }</style>") | ||
print(f"</head><body><h1>Code coverage</h1>") | ||
print(f"<h2>Per branch (<a href=\"{master_path}/index.html\">master</a>)</h2><ul>") | ||
for path in sorted(list(iglob("*/index.html", recursive=True))): | ||
name = urlsafe_b64decode(path.split("/")[0].encode()).decode() | ||
style = "font-weight: bold" if name == "master" else "" | ||
print(f'<li style="{style}"><a href="{path}">{name}</a></li>') | ||
print("</ul></body></html>") |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use a different version of rust nightly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to touch formatting in this PR. The branch coverage needs.a more recent nightly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. That makes sense. Do we have any issues for unifying them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a separate PR, maybe. I don't want to reformat the whole codebase here.