Skip to content

Commit

Permalink
wip test-nightly.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Dec 18, 2018
1 parent 63787e2 commit 8727dc1
Showing 1 changed file with 67 additions and 19 deletions.
86 changes: 67 additions & 19 deletions ci/test-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@
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 .rs files were modified"
exit 0
fi
fi


source ci/upload-ci-artifact.sh
ci/version-check.sh stable
export RUST_BACKTRACE=1

Expand All @@ -25,31 +36,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"

0 comments on commit 8727dc1

Please sign in to comment.