diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1d3e7e7f..cc54d6bde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,7 @@ jobs: .github/.cache/buster-for-unit-tests - name: Run Tests - run: make unit-test + run: make unit-test CI=true - name: Upload coverage reports to Codecov uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 diff --git a/Makefile b/Makefile index a7a033433..c3cb86310 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,10 @@ ifneq (,$(findstring plus,$(MAKECMDGOALS))) PLUS_ENABLED = true endif +ifeq ($(CI),true) + GITHUB_OUTPUT := --github-output +endif + .PHONY: help help: Makefile ## Display this help @grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "; printf "Usage:\n\n make \033[36m\033[0m [VARIABLE=value...]\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}' @@ -182,7 +186,7 @@ lint: check-golangci-lint ## Run golangci-lint against code unit-test: ## Run unit tests for the go code # We have to run the tests in the cmd package using `go test` because of a bug with the CLI library cobra. See https://github.com/spf13/cobra/issues/2104. go test -buildvcs ./cmd/... -race -shuffle=on -coverprofile=cmd-coverage.out -covermode=atomic - go run github.com/onsi/ginkgo/v2/ginkgo --randomize-all --randomize-suites --race --keep-going --fail-on-pending --trace --covermode=atomic --coverprofile=coverage.out -r internal + go run github.com/onsi/ginkgo/v2/ginkgo --randomize-all --randomize-suites --race --keep-going --fail-on-pending --trace --covermode=atomic --coverprofile=coverage.out --force-newlines $(GITHUB_OUTPUT) -p -v -r internal go tool cover -html=coverage.out -o cover.html go tool cover -html=cmd-coverage.out -o cmd-cover.html diff --git a/internal/framework/conditions/conditions_test.go b/internal/framework/conditions/conditions_test.go index 7bf69c271..b446a6eca 100644 --- a/internal/framework/conditions/conditions_test.go +++ b/internal/framework/conditions/conditions_test.go @@ -8,6 +8,7 @@ import ( ) func TestDeduplicateConditions(t *testing.T) { + t.Parallel() conds := []Condition{ { Type: "Type1", @@ -61,6 +62,7 @@ func TestDeduplicateConditions(t *testing.T) { } func TestConvertConditions(t *testing.T) { + t.Parallel() conds := []Condition{ { Type: "Type1", diff --git a/internal/framework/events/events_suite_test.go b/internal/framework/events/events_suite_test.go index 1c318a89b..d2b8ee906 100644 --- a/internal/framework/events/events_suite_test.go +++ b/internal/framework/events/events_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestEvents(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Events Suite") } diff --git a/internal/framework/events/events_test.go b/internal/framework/events/events_test.go index e36b53945..6ed5ce8b5 100644 --- a/internal/framework/events/events_test.go +++ b/internal/framework/events/events_test.go @@ -8,6 +8,7 @@ import ( ) func TestEventLoop_SwapBatches(t *testing.T) { + t.Parallel() g := NewWithT(t) eventLoop := NewEventLoop(nil, zap.New(), nil, nil) diff --git a/internal/framework/gatewayclass/validate_test.go b/internal/framework/gatewayclass/validate_test.go index 835936547..d8def4964 100644 --- a/internal/framework/gatewayclass/validate_test.go +++ b/internal/framework/gatewayclass/validate_test.go @@ -13,6 +13,7 @@ import ( ) func TestValidateCRDVersions(t *testing.T) { + t.Parallel() createCRDMetadata := func(version string) *metav1.PartialObjectMetadata { return &metav1.PartialObjectMetadata{ ObjectMeta: metav1.ObjectMeta{ @@ -113,7 +114,9 @@ func TestValidateCRDVersions(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) conds, valid := gatewayclass.ValidateCRDVersions(test.crds) diff --git a/internal/framework/helpers/helpers_test.go b/internal/framework/helpers/helpers_test.go index fbd1498b0..0c4b598a8 100644 --- a/internal/framework/helpers/helpers_test.go +++ b/internal/framework/helpers/helpers_test.go @@ -13,6 +13,7 @@ import ( ) func TestMustCastObject(t *testing.T) { + t.Parallel() g := NewWithT(t) var obj client.Object = &gatewayv1.Gateway{} @@ -27,6 +28,7 @@ func TestMustCastObject(t *testing.T) { } func TestEqualPointers(t *testing.T) { + t.Parallel() tests := []struct { p1 *string p2 *string @@ -78,7 +80,9 @@ func TestEqualPointers(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) val := helpers.EqualPointers(test.p1, test.p2) @@ -88,6 +92,7 @@ func TestEqualPointers(t *testing.T) { } func TestMustExecuteTemplate(t *testing.T) { + t.Parallel() g := NewWithT(t) tmpl := template.Must(template.New("test").Parse(`Hello {{.}}`)) @@ -96,6 +101,7 @@ func TestMustExecuteTemplate(t *testing.T) { } func TestMustExecuteTemplatePanics(t *testing.T) { + t.Parallel() g := NewWithT(t) execute := func() { diff --git a/internal/framework/runnables/cronjob_test.go b/internal/framework/runnables/cronjob_test.go index ca1154c30..310ceef61 100644 --- a/internal/framework/runnables/cronjob_test.go +++ b/internal/framework/runnables/cronjob_test.go @@ -10,6 +10,7 @@ import ( ) func TestCronJob(t *testing.T) { + t.Parallel() g := NewWithT(t) readyChannel := make(chan struct{}) @@ -50,6 +51,7 @@ func TestCronJob(t *testing.T) { } func TestCronJob_ContextCanceled(t *testing.T) { + t.Parallel() g := NewWithT(t) readyChannel := make(chan struct{}) diff --git a/internal/framework/runnables/runnables_test.go b/internal/framework/runnables/runnables_test.go index 28af82930..9f34d9ccb 100644 --- a/internal/framework/runnables/runnables_test.go +++ b/internal/framework/runnables/runnables_test.go @@ -8,6 +8,7 @@ import ( ) func TestLeader(t *testing.T) { + t.Parallel() leader := &Leader{} g := NewWithT(t) @@ -15,6 +16,7 @@ func TestLeader(t *testing.T) { } func TestLeaderOrNonLeader(t *testing.T) { + t.Parallel() leaderOrNonLeader := &LeaderOrNonLeader{} g := NewWithT(t) @@ -22,6 +24,7 @@ func TestLeaderOrNonLeader(t *testing.T) { } func TestEnableAfterBecameLeader(t *testing.T) { + t.Parallel() enabled := false enableAfterBecameLeader := NewEnableAfterBecameLeader(func(_ context.Context) { enabled = true diff --git a/tests/Makefile b/tests/Makefile index ab63c779b..e7bf8a805 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -29,10 +29,6 @@ ifneq ($(GINKGO_LABEL),) override GINKGO_FLAGS += --label-filter "$(GINKGO_LABEL)" endif -ifeq ($(CI),true) - GITHUB_OUTPUT := --github-output -endif - .PHONY: update-go-modules update-go-modules: ## Update the gateway-api go modules to latest main version go get -u sigs.k8s.io/gateway-api@main