test-coverage.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env bash
  2. set -e
  3. here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
  4. # shellcheck source=ci/upload-ci-artifact.sh
  5. source "$here/upload-ci-artifact.sh"
  6. if [[ -z $CI ]]; then
  7. echo "This script is used by CI environment. \
  8. Use \`scripts/coverage.sh\` directly if you only want to obtain the coverage report"
  9. exit 1
  10. fi
  11. annotate() {
  12. ${BUILDKITE:-false} && {
  13. buildkite-agent annotate "$@"
  14. }
  15. }
  16. # run coverage for all
  17. SHORT_CI_COMMIT=${CI_COMMIT:0:9}
  18. COMMIT_HASH=$SHORT_CI_COMMIT "$here/../scripts/coverage.sh" "$@"
  19. # compress coverage reports
  20. HTML_REPORT_TAR_NAME="coverage.tar.gz"
  21. HTML_REPORT_TAR_PATH="$here/../target/cov/${SHORT_CI_COMMIT}/$HTML_REPORT_TAR_NAME"
  22. tar zcf "$HTML_REPORT_TAR_PATH" "$here/../target/cov/${SHORT_CI_COMMIT}/coverage"
  23. # upload reports to buildkite
  24. upload-ci-artifact "$HTML_REPORT_TAR_PATH"
  25. annotate --style success --context lcov-report \
  26. "lcov report: <a href=\"artifact://$HTML_REPORT_TAR_NAME\">$HTML_REPORT_TAR_NAME</a>"
  27. echo "--- codecov.io report"
  28. if [[ -z "$CODECOV_TOKEN" ]]; then
  29. echo "^^^ +++"
  30. echo CODECOV_TOKEN undefined, codecov.io upload skipped
  31. else
  32. codecov -t "${CODECOV_TOKEN}" --dir "$here/../target/cov/${SHORT_CI_COMMIT}"
  33. annotate --style success --context codecov.io \
  34. "CodeCov report: https://codecov.io/github/anza-xyz/agave/commit/$CI_COMMIT"
  35. fi