Skip to content

Commit

Permalink
Update CI to run tests with coverage collection
Browse files Browse the repository at this point in the history
We updated the way we collect the test coverage, so the CI workflow
should reflect this as well.
  • Loading branch information
denisonbarbosa committed Nov 20, 2023
1 parent 6a09616 commit 47bf0fd
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 47bf0fd

Please sign in to comment.