From a4ca8b16be66bc41a1f1cd9aae4b057d8fa85817 Mon Sep 17 00:00:00 2001 From: taylan isikdemir Date: Mon, 4 Mar 2024 11:33:24 -0800 Subject: [PATCH] Generate a metadata file artifact in unit test buildkite job --- .buildkite/pipeline-master.yml | 5 ++++- .buildkite/pipeline-pull-request.yml | 2 ++ scripts/buildkite/gen_coverage_metadata.sh | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 scripts/buildkite/gen_coverage_metadata.sh diff --git a/.buildkite/pipeline-master.yml b/.buildkite/pipeline-master.yml index 95e372c0b5c..a030c3068b0 100644 --- a/.buildkite/pipeline-master.yml +++ b/.buildkite/pipeline-master.yml @@ -8,9 +8,12 @@ steps: agents: queue: "workers" docker: "*" - command: "CASSANDRA_HOST=cassandra make install-schema && make cover_profile" # make install-schema is needed for a server startup test. See main_test.go + commands: + - "CASSANDRA_HOST=cassandra make install-schema && make cover_profile" # make install-schema is needed for a server startup test. See main_test.go + - "./scripts/buildkite/gen_coverage_metadata.sh .build/coverage/metadata.txt" artifact_paths: - ".build/coverage/*.out" + - ".build/coverage/metadata.txt" retry: automatic: limit: 1 diff --git a/.buildkite/pipeline-pull-request.yml b/.buildkite/pipeline-pull-request.yml index 1ff3a621119..b4dc060ad20 100644 --- a/.buildkite/pipeline-pull-request.yml +++ b/.buildkite/pipeline-pull-request.yml @@ -11,8 +11,10 @@ steps: commands: - "make .just-build" # ensure that we are not rebuilding binaries and not regenerating code - "CASSANDRA_HOST=cassandra make install-schema && make cover_profile" # make install-schema is needed for a server startup test. See main_test.go + - "./scripts/buildkite/gen_coverage_metadata.sh .build/coverage/metadata.txt" artifact_paths: - ".build/coverage/*.out" + - ".build/coverage/metadata.txt" retry: automatic: limit: 1 diff --git a/scripts/buildkite/gen_coverage_metadata.sh b/scripts/buildkite/gen_coverage_metadata.sh new file mode 100755 index 00000000000..3eedf2357ff --- /dev/null +++ b/scripts/buildkite/gen_coverage_metadata.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -ex + +# This script generates coverage metadata for the coverage report. +# Output is used by SonarQube integration in Uber and not used by OS repo coverage tool itself. + +# Example output: +# commit-sha: 6953daa563e8e44512bc349c9608484cfd4ec4ff +# timestamp: 2024-03-04T19:29:16Z + +output_path="$1" + +echo "commit-sha: $(git rev-parse HEAD)" > "$output_path" +echo "timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$output_path" + +echo "Coverage metadata written to $output_path"