diff --git a/ci/test-nightly.sh b/ci/test-nightly.sh index 7727a20d499c60..4aafa21913ced9 100755 --- a/ci/test-nightly.sh +++ b/ci/test-nightly.sh @@ -2,8 +2,21 @@ set -e cd "$(dirname "$0")/.." -source ci/upload-ci-artifact.sh + +if ci/is-pr.sh; then + affectedFiles="$(buildkite-agent meta-data get affected_files)" + echo "Affected files in this PR: $affectedFiles" + if [[ ! ":$affectedFiles:" =~ \.rs: ]]; then + echo "Skipping coverage build as no Rust files were modified" + exit 0 + else + echo "Modification to one or more Rust files detected" + fi +fi + + +source ci/upload-ci-artifact.sh ci/version-check.sh stable export RUST_BACKTRACE=1 @@ -25,31 +38,68 @@ cargo_install_unless() { cargo_install_unless cargo-cov cargo cov --help -# Generate coverage data and report via unit-test suite. _ cargo cov clean _ cargo cov build --all -_ cargo cov test --lib -_ cargo cov report +_ cargo cov test --all --lib _ ./scripts/fetch-grcov.sh -_ ./grcov . -t lcov > lcov.info -_ genhtml -o target/cov/report-lcov --show-details --highlight --ignore-errors source --legend lcov.info -# Upload to tarballs to buildkite. -_ cd target/cov && tar -cjf cov-report.tar.bz2 report/* && cd - -_ upload-ci-artifact "target/cov/cov-report.tar.bz2" +echo "--- grcov" +./grcov . -t lcov > lcov.info -_ cd target/cov && tar -cjf lcov-report.tar.bz2 report-lcov/* && cd - -_ upload-ci-artifact "target/cov/lcov-report.tar.bz2" +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 +} -# Upload coverage files to buildkite for grcov debugging -#_ cd target/cov/build && tar -cjf cov-gcda.tar.bz2 gcda/* && cd - -#_ upload-ci-artifact "target/cov/build/cov-gcda.tar.bz2" -# -#_ cd target/cov/build && tar -cjf cov-gcno.tar.bz2 gcno/* && cd - -#_ upload-ci-artifact "target/cov/build/cov-gcno.tar.bz2" +filter_non_local_files_from_lcov < lcov.info > lcov_local.info +echo "--- codecov.io report" if [[ -z "$CODECOV_TOKEN" ]]; then - echo CODECOV_TOKEN undefined + echo "^^^ +++" + echo CODECOV_TOKEN undefined, codecov.io upload skipped else - bash <(curl -s https://codecov.io/bash) -X gcov + bash <(curl -s https://codecov.io/bash) -X gcov -f lcov_info.info fi + + +echo "--- html report" +: "${BUILDKITE_COMMIT:=local}" +reportName="report-lcov-${BUILDKITE_COMMIT:0:9}" + +# Tip: genhtml comes from |brew install lcov| or |apt-get install lcov| +genhtml \ + --output-directory target/cov/$reportName \ + --show-details \ + --highlight \ + --ignore-errors source \ + --legend \ + --prefix "$PWD" \ + lcov_local.info + +ls -l target/cov/$reportName/index.html +( + set -x + cd target/cov + tar zcf $reportName.tar.gz $reportName +) +_ upload-ci-artifact "target/cov/$reportName.tar.gz" + +gzip lcov.info +_ upload-ci-artifact "lcov.info.gz" + +gzip lcov_local.info +_ upload-ci-artifact "lcov_local.info.gz"