-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Overhaul coverage setup #2202
Merged
Merged
Overhaul coverage setup #2202
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
annotate() { | ||
${BUILDKITE:-false} && { | ||
buildkite-agent annotate "$@" | ||
} | ||
} | ||
|
||
affectedFiles="$(buildkite-agent meta-data get affected_files)" | ||
echo "Affected files in this PR: $affectedFiles" | ||
if [[ ! ":$affectedFiles:" =~ \.rs: ]]; then | ||
annotate --style info --context coverage-info \ | ||
"Coverage skipped as no .rs files were modified" | ||
exit 0 | ||
fi | ||
|
||
source ci/upload-ci-artifact.sh | ||
ci/version-check-with-upgrade.sh nightly | ||
|
||
scripts/coverage.sh | ||
|
||
report=coverage-"${BUILDKITE_COMMIT:0:9}".tar.gz | ||
mv target/cov/report.tar.gz "$report" | ||
upload-ci-artifact "$report" | ||
annotate --style success --context lcov-report \ | ||
"lcov report: <a href=\"artifact://$report\">$report</a>" | ||
|
||
echo "--- codecov.io report" | ||
if [[ -z "$CODECOV_TOKEN" ]]; then | ||
echo "^^^ +++" | ||
echo CODECOV_TOKEN undefined, codecov.io upload skipped | ||
else | ||
bash <(curl -s https://codecov.io/bash) -X gcov -f target/cov/lcov.info | ||
|
||
annotate --style success --context codecov.io \ | ||
"CodeCov report: https://codecov.io/github/solana-labs/solana/commit/${BUILDKITE_COMMIT:0:9}" | ||
fi |
This file was deleted.
Oops, something went wrong.
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,79 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Runs all tests and collects code coverage | ||
# | ||
# Warning: this process is a little slow | ||
# | ||
|
||
set -e | ||
cd "$(dirname "$0")/.." | ||
|
||
_() { | ||
echo "--- $*" | ||
"$@" | ||
} | ||
|
||
: "${BUILDKITE_COMMIT:=local}" | ||
reportName="lcov-${BUILDKITE_COMMIT:0:9}" | ||
|
||
export RUSTFLAGS=" | ||
-Zprofile | ||
-Zno-landing-pads | ||
-Ccodegen-units=1 | ||
-Cinline-threshold=0 | ||
-Coverflow-checks=off | ||
" | ||
export CARGO_INCREMENTAL=0 | ||
export RUST_BACKTRACE=1 | ||
|
||
echo "--- remove old coverage results" | ||
|
||
if [[ -d target/cov ]]; then | ||
find target/cov -name \*.gcda -print0 | xargs -0 rm -f | ||
fi | ||
rm -rf target/cov/$reportName | ||
|
||
_ cargo +nightly build --target-dir target/cov --all | ||
_ cargo +nightly test --target-dir target/cov --lib --all | ||
|
||
_ scripts/fetch-grcov.sh | ||
echo "--- grcov" | ||
./grcov target/cov/debug/deps/ > target/cov/lcov_full.info | ||
|
||
echo "--- filter_non_local_files_from_lcov" | ||
filter_non_local_files_from_lcov() { | ||
declare skip=false | ||
while read -r line; do | ||
if [[ $line =~ ^SF:/ ]]; then | ||
skip=true # Skip all absolute paths as these are references into ~/.cargo | ||
elif [[ $line =~ ^SF:(.*) ]]; then | ||
# Skip relative paths that don't exist | ||
declare file="${BASH_REMATCH[1]}" | ||
if [[ -r $file ]]; then | ||
skip=false | ||
else | ||
skip=true | ||
fi | ||
fi | ||
[[ $skip = true ]] || echo "$line" | ||
done | ||
} | ||
|
||
filter_non_local_files_from_lcov < target/cov/lcov_full.info > target/cov/lcov.info | ||
|
||
echo "--- html report" | ||
# ProTip: genhtml comes from |brew install lcov| or |apt-get install lcov| | ||
genhtml --output-directory target/cov/$reportName \ | ||
--show-details \ | ||
--highlight \ | ||
--ignore-errors source \ | ||
--prefix "$PWD" \ | ||
--legend \ | ||
target/cov/lcov.info | ||
|
||
( | ||
cd target/cov | ||
tar zcf report.tar.gz $reportName | ||
) | ||
|
||
ls -l target/cov/$reportName/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
if [[ ! -x ./grcov ]]; then | ||
uname=$(uname | tr '[:upper:]' '[:lower:]') | ||
if [[ $uname = darwin ]]; then | ||
uname="osx" | ||
fi | ||
uname_m=$(uname -m | tr '[:upper:]' '[:lower:]') | ||
name=grcov-${uname}-${uname_m}.tar.bz2 | ||
|
||
wget "https://github.com/mozilla/grcov/releases/download/v0.3.2/$name" | ||
tar xjf "$name" | ||
fi | ||
|
||
ls -lh grcov |
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.
You should be able to use the
-s
option of grcov to achieve the same result (ignore any file which is not in the repository)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.
Oh sweet, thanks.
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.
💔
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'll fix this.
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.
Awesome, thanks! If you can ping me here I'll be able to give it a test drive when ready
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.
Filed mozilla/grcov#239.
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.
Hey @marco-c, what's generally the best way to contact you? Care to join our Discord forum? https://discord.gg/k8Kq58