Skip to content

Commit

Permalink
Set go version to 1.22, tweak coverage (mindersec#2630)
Browse files Browse the repository at this point in the history
We have decided to exclude anything under cmd for coverage since we do
not want to rely on unit testing for the CLI.

Go 1.22 reimplements the coverage tool. Unfortunately, the new
implementation has a bug. Disable the new coverage logic for now.
  • Loading branch information
dmjb authored Mar 14, 2024
1 parent 0ad22ac commit 49b1977
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions .mk/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# in future, we may want to parse these from a file instead of hardcoding them
# in the Makefile
COVERAGE_EXCLUSIONS="internal/db\|/mock/"
COVERAGE_PACKAGES=./internal/...,./cmd/...
COVERAGE_PACKAGES=./internal/...

.PHONY: clean
clean: ## clean up environment
Expand All @@ -33,7 +33,11 @@ test-silent: clean init-examples ## run tests in a silent mode (errors only outp

.PHONY: cover
cover: init-examples ## display test coverage
go test -v -coverpkg=${COVERAGE_PACKAGES} -coverprofile=coverage.out.tmp -race ./...
# There is a bug in the new coverage logic implemented in go 1.22.
# The recommended workaround is to disable the new coverage logic until
# this is fixed.
# See: https://github.com/golang/go/issues/65653
GOEXPERIMENT=nocoverageredesign go test -v -coverpkg=${COVERAGE_PACKAGES} -coverprofile=coverage.out.tmp -race ./...
cat coverage.out.tmp | grep -v ${COVERAGE_EXCLUSIONS} > coverage.out
rm coverage.out.tmp
go tool cover -func=coverage.out
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/stacklok/minder

go 1.21.7
go 1.22.1

require (
github.com/AlecAivazis/survey/v2 v2.3.7
Expand Down

0 comments on commit 49b1977

Please sign in to comment.