Skip to content

Commit

Permalink
coverage: Fix empty services.log
Browse files Browse the repository at this point in the history
  • Loading branch information
def- committed Dec 21, 2023
1 parent 6c48bbe commit 7998a64
Showing 1 changed file with 42 additions and 43 deletions.
85 changes: 42 additions & 43 deletions ci/plugins/mzcompose/hooks/post-command
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,10 @@ run() {
bin/ci-builder run stable bin/mzcompose --mz-quiet --find "$BUILDKITE_PLUGIN_MZCOMPOSE_COMPOSITION" "$@"
}

# Run before potential "run down" in coverage
docker ps --all --quiet | xargs --no-run-if-empty docker inspect > docker-inspect.log

export_cov() {
bin/ci-builder run stable rust-cov export \
--ignore-filename-regex=.cargo/ \
--ignore-filename-regex=target/release/ \
--ignore-filename-regex=/cargo/ \
--ignore-filename-regex=/mnt/build/ \
--ignore-filename-regex=/rustc/ \
--format=lcov "$1" --instr-profile=coverage/"$BUILDKITE_JOB_ID".profdata src/ \
> coverage/"$BUILDKITE_JOB_ID"-"$(basename "$1")".lcov
}

if [ -n "${CI_COVERAGE_ENABLED:-}" ] && [ -z "${BUILDKITE_MZCOMPOSE_PLUGIN_SKIP_COVERAGE:-}" ]; then
ci_unimportant_heading "Generate coverage information"
run --mz-quiet down --volumes

if [ -n "$(find . -name '*.profraw')" ]; then
# Workaround for "invalid instrumentation profile data (file header is corrupt)"
find . -name '*.profraw' | while read -r i; do
bin/ci-builder run stable rust-profdata show "$i" > /dev/null || rm "$i"
done
find . -name '*.profraw' -exec bin/ci-builder run stable rust-profdata merge -sparse -o coverage/"$BUILDKITE_JOB_ID".profdata {} +
find . -name '*.profraw' -delete

ARGS=()
for program in clusterd environmentd balancerd sqllogictest testdrive; do
if [ -f coverage/"$program" ]; then
export_cov coverage/"$program"
ARGS+=("-a" coverage/"$BUILDKITE_JOB_ID"-"$program".lcov)
fi
done
rm coverage/"$BUILDKITE_JOB_ID".profdata
if [ "${#ARGS[@]}" != 0 ]; then
bin/ci-builder run stable lcov "${ARGS[@]}" -o coverage/"$BUILDKITE_JOB_ID".lcov
rm coverage/"$BUILDKITE_JOB_ID"-*.lcov
bin/ci-builder run stable zstd coverage/"$BUILDKITE_JOB_ID".lcov
buildkite-agent artifact upload coverage/"$BUILDKITE_JOB_ID".lcov.zst
fi
fi
fi

ci_unimportant_heading "Upload log artifacts"

# Run before potential "run down" in coverage
docker ps --all --quiet | xargs --no-run-if-empty docker inspect > docker-inspect.log
# services.log might already exist and contain logs from before composition was downed
run logs --no-color >> services.log
# shellcheck disable=SC2024
Expand Down Expand Up @@ -112,3 +71,43 @@ if [ ! -s services.log ] && [ "$BUILDKITE_LABEL" != "Maelstrom coverage of persi
echo "+++ services.log is empty, failing"
exit 1
fi

export_cov() {
bin/ci-builder run stable rust-cov export \
--ignore-filename-regex=.cargo/ \
--ignore-filename-regex=target/release/ \
--ignore-filename-regex=/cargo/ \
--ignore-filename-regex=/mnt/build/ \
--ignore-filename-regex=/rustc/ \
--format=lcov "$1" --instr-profile=coverage/"$BUILDKITE_JOB_ID".profdata src/ \
> coverage/"$BUILDKITE_JOB_ID"-"$(basename "$1")".lcov
}

if [ -n "${CI_COVERAGE_ENABLED:-}" ] && [ -z "${BUILDKITE_MZCOMPOSE_PLUGIN_SKIP_COVERAGE:-}" ]; then
ci_unimportant_heading "Generate coverage information"
run --mz-quiet down --volumes

if [ -n "$(find . -name '*.profraw')" ]; then
# Workaround for "invalid instrumentation profile data (file header is corrupt)"
find . -name '*.profraw' | while read -r i; do
bin/ci-builder run stable rust-profdata show "$i" > /dev/null || rm "$i"
done
find . -name '*.profraw' -exec bin/ci-builder run stable rust-profdata merge -sparse -o coverage/"$BUILDKITE_JOB_ID".profdata {} +
find . -name '*.profraw' -delete

ARGS=()
for program in clusterd environmentd balancerd sqllogictest testdrive; do
if [ -f coverage/"$program" ]; then
export_cov coverage/"$program"
ARGS+=("-a" coverage/"$BUILDKITE_JOB_ID"-"$program".lcov)
fi
done
rm coverage/"$BUILDKITE_JOB_ID".profdata
if [ "${#ARGS[@]}" != 0 ]; then
bin/ci-builder run stable lcov "${ARGS[@]}" -o coverage/"$BUILDKITE_JOB_ID".lcov
rm coverage/"$BUILDKITE_JOB_ID"-*.lcov
bin/ci-builder run stable zstd coverage/"$BUILDKITE_JOB_ID".lcov
buildkite-agent artifact upload coverage/"$BUILDKITE_JOB_ID".lcov.zst
fi
fi
fi

0 comments on commit 7998a64

Please sign in to comment.