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 16, 2022
1 parent 27ecd22 commit ccc5b15
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 108 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 ${hack_dir}/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
58 changes: 55 additions & 3 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,60 @@
module sigs.k8s.io/controller-runtime/hack/tools

go 1.16
go 1.17

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
)

require (
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-git/go-git/v5 v5.4.2 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/gobuffalo/flect v0.2.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/spf13/cobra v1.4.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
golang.org/x/exp v0.0.0-20220328175248-053ad81199eb // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.24.0 // indirect
k8s.io/apiextensions-apiserver v0.24.0 // indirect
k8s.io/apimachinery v0.24.0 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit ccc5b15

Please sign in to comment.