coverage_report.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. set -euo pipefail
  11. . misc/shlib/shlib.bash
  12. STEP_START_TIMESTAMP_WITH_TZ=$(date +"%Y-%m-%d %H:%M:%S%z")
  13. export STEP_START_TIMESTAMP_WITH_TZ
  14. ci_unimportant_heading "Download coverage data from run"
  15. mkdir -p coverage
  16. buildkite-agent artifact download 'coverage/*.zst' coverage/
  17. find coverage -name '*.zst' -exec zstd -d {} \;
  18. ci_uncollapsed_heading "Uncovered Lines in Pull Request"
  19. find coverage -name '*.lcov' -not -name 'cargotest.lcov' -exec bin/ci-coverage-pr-report --unittests=coverage/cargotest.lcov {} +
  20. buildkite-agent artifact upload junit_coverage*.xml
  21. bin/ci-annotate-errors junit_coverage*.xml
  22. ci_unimportant_heading "Create coverage report"
  23. REPORT=coverage_without_unittests_"$BUILDKITE_BUILD_ID"
  24. REPORT_UNITTESTS=coverage_with_unittests_"$BUILDKITE_BUILD_ID"
  25. find coverage -name '*.lcov' -exec sed -i "s#SF:/var/lib/buildkite-agent/builds/buildkite-.*/materialize/coverage/#SF:#" {} +
  26. find coverage -name '*.lcov' -not -name 'cargotest.lcov' -exec genhtml -o "$REPORT" {} +
  27. find coverage -name '*.lcov' -exec genhtml -o "$REPORT_UNITTESTS" {} +
  28. tar -I zstd -cf "$REPORT".tar.zst "$REPORT"
  29. tar -I zstd -cf "$REPORT_UNITTESTS".tar.zst "$REPORT_UNITTESTS"
  30. buildkite-agent artifact upload "$REPORT".tar.zst
  31. buildkite-agent artifact upload "$REPORT_UNITTESTS".tar.zst