Skip to content

Commit

Permalink
use ginkgo cli to execute tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schrej committed Aug 12, 2022
1 parent 27ecd22 commit ccc9e3d
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 107 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# Test binary, build with `go test -c`
*.test
test-report.xml

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint)
GO_APIDIFF := $(TOOLS_BIN_DIR)/go-apidiff
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
GINKGO := $(TOOLS_BIN_DIR)/ginkgo
ENVTEST_DIR := $(abspath tools/setup-envtest)

# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
Expand All @@ -55,12 +56,12 @@ help: ## Display this help
## --------------------------------------

.PHONY: test
test: test-tools ## Run the script check-everything.sh which will check all.
test: test-tools $(GINKGO) ## Run the script check-everything.sh which will check all.
TRACE=1 ./hack/check-everything.sh

.PHONY: test-tools
test-tools: ## tests the tools codebase (setup-envtest)
cd tools/setup-envtest && go test ./...
test-tools: $(GINKGO) ## tests the tools codebase (setup-envtest)
$(GINKGO) tools/setup-envtest/...

## --------------------------------------
## Binaries
Expand All @@ -72,6 +73,9 @@ $(GO_APIDIFF): $(TOOLS_DIR)/go.mod # Build go-apidiff from tools folder.
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
cd $(TOOLS_DIR) && go build -tags=tools -o bin/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen

$(GINKGO): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && go build -tags=tools -o bin/ginkgo github.com/onsi/ginkgo/v2/ginkgo

$(GOLANGCI_LINT): .github/workflows/golangci-lint.yml # Download golanci-lint using hack script into tools folder.
hack/ensure-golangci-lint.sh \
-b $(TOOLS_BIN_DIR) \
Expand Down
12 changes: 9 additions & 3 deletions hack/test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

set -e

source $(dirname ${BASH_SOURCE})/common.sh
hack_dir=$(dirname ${BASH_SOURCE})
source ${hack_dir}/common.sh

header_text "running go test"
(
cd tools
go build -tags=tools -o bin/ginkgo github.com/onsi/ginkgo/v2/ginkgo
)

go test -race ${P_FLAG} ${MOD_OPT} ./...
header_text "running tests using ginkgo"

$hack_dir/tools/bin/ginkgo --junit-report test-report.xml --keep-going --race -r ${P_FLAG} ${MOD_OPT}

if [[ -n ${ARTIFACTS:-} ]]; then
if grep -Rin '<failure type="Failure">' ${ARTIFACTS}/*; then exit 1; fi
Expand Down
5 changes: 3 additions & 2 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module sigs.k8s.io/controller-runtime/hack/tools
go 1.16

require (
github.com/joelanford/go-apidiff v0.1.0
sigs.k8s.io/controller-tools v0.7.0
github.com/joelanford/go-apidiff v0.4.0
github.com/onsi/ginkgo/v2 v2.1.4
sigs.k8s.io/controller-tools v0.9.2
)
Loading

0 comments on commit ccc9e3d

Please sign in to comment.