Skip to content

Commit 17da8c9

Browse files
authored
Merge pull request #1151 from camilamacedo86/refac-scripts
Refac scripts used in the CI and Makefile to test and generated mock data
2 parents 1705128 + f8b626c commit 17da8c9

File tree

9 files changed

+36
-65
lines changed

9 files changed

+36
-65
lines changed

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ services:
4040

4141
before_install:
4242
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p /Users/travis/gopath/bin; fi
43-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then GO111MODULE=on scripts/install_and_setup.sh $KIND_K8S_VERSION; fi
44-
- GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected]
45-
- GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/[email protected]
43+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then scripts/setup.sh $KIND_K8S_VERSION; fi
4644

4745
before_script:
4846

@@ -53,11 +51,13 @@ install:
5351
-
5452

5553
script:
56-
- GO111MODULE=on TRACE=1 ./golden_test.sh
57-
- GO111MODULE=on TRACE=1 ./test.sh
58-
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then GO111MODULE=on TRACE=1 PATH=$PATH:$(pwd) ./test_e2e_v1.sh ; fi
59-
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then GO111MODULE=on TRACE=1 PATH=$PATH:$(pwd) ./test_e2e_v2.sh ; fi
54+
# The golden_test.sh check if the the testdata is updated according to the current changes
55+
# To update the testdata use the Makefile targets `make generate-setup` then `make generate-testdata`
56+
- ./golden_test.sh
57+
- ./test.sh
58+
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then PATH=$PATH:$(pwd) ./test_e2e.sh; fi
6059

6160
# TBD. Suppressing for now.
6261
notifications:
6362
email: false
63+

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/ku
5454
GO111MODULE=on ./generate_golden.sh
5555

5656
.PHONY: generate-vendor
57-
generate-vendor: ## (deprecated) - Update/generate the vendor by using the path $GOPATH/src/sigs.k8s.io/kubebuilder-test
57+
generate-vendor: ## (Deprecated) Update/generate the vendor by using the path $GOPATH/src/sigs.k8s.io/kubebuilder-test
5858
GO111MODULE=off ./generate_vendor.sh
5959

6060
.PHONY: generate-setup
@@ -68,12 +68,11 @@ generate-setup: ## Current workarround to generate the testdata with the correct
6868
test: ## Run the go tests ($ go test -v ./cmd/... ./pkg/...)
6969
go test -v ./cmd/... ./pkg/...
7070

71-
.PHONY: test-project-generation
72-
test-project-generation: ## Run the unit tests (used in the CI)
73-
- go get sigs.k8s.io/[email protected]
71+
.PHONY: test-ci
72+
test-ci: ## Run the unit tests (used in the CI)
73+
./setup.sh
7474
./test.sh
7575

7676
.PHONY: test-e2e
7777
test-e2e: ## Run the integration tests (used in the CI)
78-
./test_e2e_v1.sh
79-
./test_e2e_v2.sh
78+
./test_e2e.sh

golden_test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ set -o pipefail
1919

2020
source common.sh
2121

22+
export TRACE=1
23+
export GO111MODULE=on
24+
2225
fetch_tools
2326
install_go_dep
2427
build_kb

scripts/generate_dep_manifest.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
# depManifestOverride variable in cmd/kubebuilder/initproject/dep_manifest.go
1515
#
1616

17+
########################################################################################################
18+
# NOTE: It is deprecated since is valid just for version 1 #
19+
########################################################################################################
20+
1721
tmp_file="/tmp/dep.txt"
1822
dep status -json|jq '.[]|.ProjectRoot,.Revision, .Version' > $tmp_file
1923
while read name ; do

scripts/install_and_setup.sh renamed to scripts/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ K8S_VERSION=$1
1818

1919
export GO111MODULE=on
2020

21+
# setup go module to create the cluster
2122
go get sigs.k8s.io/[email protected]
2223

2324
# You can use --image flag to specify the cluster version you want, e.g --image=kindest/node:v1.13.6, the supported version are listed at https://hub.docker.com/r/kindest/node/tags
2425
kind create cluster --config test/kind-config.yaml --image=kindest/node:$K8S_VERSION
26+
27+
# setup the go modules required
28+
go get sigs.k8s.io/controller-tools/cmd/[email protected]
29+
go get sigs.k8s.io/kustomize/kustomize/[email protected]

test.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ set -o pipefail
1919

2020
source common.sh
2121

22+
export TRACE=1
23+
export GO111MODULE=on
24+
25+
# This test is used by prow and if the dep not be installed by git then it will face the GOBIN issue.
2226
install_dep_by_git
2327

2428
function test_init_project {
@@ -100,7 +104,7 @@ function test_project {
100104
fi
101105
cd testdata/$project_dir
102106
# v2 uses modules, and thus doesn't have a vendor directory
103-
[[ -e ${vendor_tarball} ]] && tar -zxf $vendor_tarball
107+
[[ -e ${vendor_tarball} ]] && tar -zxf $vendor_tarball
104108
make all test # v2 doesn't test on all by default
105109
[[ -e ${vendor_tarball} ]] && rm -rf ./vendor && rm -f Gopkg.lock
106110
cd -
@@ -153,11 +157,12 @@ export GO111MODULE=on
153157
go test ./cmd/... ./pkg/...
154158

155159
# test project v1
156-
# auto is roughly equivalent to off in our case,
160+
# auto is roughly equivalent to off in our case,
157161
# since we'll be in a gopath (basically, reset to default)
158162
GO111MODULE=off test_project gopath/src/project 1
159163

160164
# test project v2
161165
GO111MODULE=on test_project project-v2 2
162166

163167
exit $rc
168+

test_ci.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

test_e2e_v1.sh renamed to test_e2e.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ set -o pipefail
1919

2020
source common.sh
2121

22+
export TRACE=1
23+
export GO111MODULE=on
24+
2225
fetch_tools
2326
install_go_dep
2427
build_kb
@@ -28,4 +31,6 @@ setup_envs
2831
docker pull gcr.io/kubebuilder/kube-rbac-proxy:v0.4.1
2932
kind load docker-image gcr.io/kubebuilder/kube-rbac-proxy:v0.4.1
3033

34+
# The v1 is deprecated
3135
go test ./test/e2e/v1
36+
go test ./test/e2e/v2

test_e2e_v2.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)