Skip to content

Commit

Permalink
Merge branch 'main' into chore/linters
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome authored Sep 26, 2024
2 parents e9bbbc8 + 4f0e3a6 commit 08c90df
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ coverage:
informational: true
comment:
require_changes: true
ignore:
- "**/fake_*.go"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
.github/.cache/buster-for-unit-tests
- name: Run Tests
run: make unit-test CI=true
run: make unit-test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Lint Actions
uses: reviewdog/action-actionlint@05c9d7bef25a46caf572df3497afa7082fc111df # v1.55.0
uses: reviewdog/action-actionlint@15a7a477ab5ab768a41c39b2c53970bf151c73f3 # v1.56.0
with:
actionlint_flags: -shellcheck ""

Expand Down
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ 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<target>\033[0m [VARIABLE=value...]\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -191,11 +187,8 @@ lint: ## Run golangci-lint against code

.PHONY: unit-test
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 --fail-fast --trace --covermode=atomic --coverprofile=coverage.out --force-newlines $(GITHUB_OUTPUT) -p -v -r internal
go test ./cmd/... ./internal/... -buildvcs -race -shuffle=on -coverprofile=coverage.out -covermode=atomic
go tool cover -html=coverage.out -o cover.html
go tool cover -html=cmd-coverage.out -o cmd-cover.html

.PHONY: njs-unit-test
njs-unit-test: ## Run unit tests for the njs httpmatches module
Expand Down
30 changes: 0 additions & 30 deletions cmd/gateway/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,6 @@ func testFlag(t *testing.T, cmd *cobra.Command, test flagTestCase) {
}
}

/*
This test cannot be run with ginkgo. Ginkgo reports the following error:
* Unexpected error:
* <*errors.errorString | 0xc0004746b0>:
* unknown flag: --test.v
* {
* s: "unknown flag: --test.v",
* }
* occurred
*
* This is because cobra sets the args of the command to the OS args when args are nil, and adds the testing flags
* that ginkgo passes to the testing binary as flags on the command. This does not happen with the `go test` flags
* because those only have one dash (e.g. -test) and are ignored by cobra.
* See https://github.com/spf13/cobra/issues/2104.
*/
func TestRootCmd(t *testing.T) {
t.Parallel()
testCase := flagTestCase{
Expand Down Expand Up @@ -410,21 +395,6 @@ func TestProvisionerModeCmdFlagValidation(t *testing.T) {
testFlag(t, createProvisionerModeCommand(), testCase)
}

/*
This test cannot be run with ginkgo. Ginkgo reports the following error for the "omitted flag" case:
* Unexpected error:
* <*errors.errorString | 0xc0004746b0>:
* unknown flag: --test.v
* {
* s: "unknown flag: --test.v",
* }
* occurred
*
* This is because cobra sets the args of the command to the OS args when args are nil, and adds the testing flags
* that ginkgo passes to the testing binary as flags on the command. This does not happen with the `go test` flags
* because those only have one dash (e.g. -test) and are ignored by cobra.
* See https://github.com/spf13/cobra/issues/2104.
*/
func TestSleepCmdFlagValidation(t *testing.T) {
t.Parallel()
tests := []flagTestCase{
Expand Down
4 changes: 4 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ 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
Expand Down

0 comments on commit 08c90df

Please sign in to comment.