From 47bf0fd19607de2f577898cd51052e7c44a51c4c Mon Sep 17 00:00:00 2001 From: denisonbarbosa Date: Mon, 20 Nov 2023 10:00:06 -0400 Subject: [PATCH] Update CI to run tests with coverage collection We updated the way we collect the test coverage, so the CI workflow should reflect this as well. --- .github/workflows/qa.yaml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 7c6ee1b2f..1eb4e83d0 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -90,17 +90,33 @@ jobs: run: | set -eu cargo install grcov - - name: Run tests + - name: Run tests (with coverage collection) run: | set -eu - go test -coverpkg=./... -coverprofile=/tmp/coverage.out -covermode=set ./... -shuffle=on + # The coverage is not written if the output directory does not exist, so we need to create it. + raw_cov_dir="/tmp/raw_files" + rm -fr "${raw_cov_dir}" + mkdir -p "${raw_cov_dir}" + + # Overriding the default coverage directory is not an exported flag of go test (yet), so + # we need to override it using the test.gocoverdir flag instead. + #TODO: Update when https://go-review.googlesource.com/c/go/+/456595 is merged. + go test -cover -covermode=set ./... -shuffle=on -args -test.gocoverdir="${raw_cov_dir}" + + # Convert the raw coverage data into textfmt so we can merge the Rust one into it + go tool covdata textfmt -i="${raw_cov_dir}" -o="/tmp/coverage.out" + + # Append the Rust coverage data to the Go one + cat "${raw_cov_dir}/rust-cov/rust2go_coverage" >>"/tmp/coverage.out" + + # Filter out the testutils package and the pb.go file + grep -v -e "testutils" -e "pb.go" "/tmp/coverage.out" >"/tmp/coverage.out.filtered" + - name: Run tests (with race detector) run: | go test -race ./... - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - file: /tmp/coverage.combined - - # TODO: rust-tests: + file: /tmp/coverage.out.filtered