Skip to content
Permalink
Browse files

refac(ci/scripts): centralize code and remove duplications

  • Loading branch information
camilamacedo86 committed Nov 9, 2019
1 parent 1705128 commit f8b626c2d6ffe073226af695d33c802ebd6d36a4
Showing with 36 additions and 65 deletions.
  1. +7 −7 .travis.yml
  2. +5 −6 Makefile
  3. +3 −0 golden_test.sh
  4. +4 −0 scripts/generate_dep_manifest.sh
  5. +5 −0 scripts/{install_and_setup.sh → setup.sh}
  6. +7 −2 test.sh
  7. +0 −19 test_ci.sh
  8. +5 −0 test_e2e_v1.sh → test_e2e.sh
  9. +0 −31 test_e2e_v2.sh
@@ -40,9 +40,7 @@ services:

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p /Users/travis/gopath/bin; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then GO111MODULE=on scripts/install_and_setup.sh $KIND_K8S_VERSION; fi
- GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.2
- GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/v3@v3.2.1
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then scripts/setup.sh $KIND_K8S_VERSION; fi

before_script:

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

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

# TBD. Suppressing for now.
notifications:
email: false

@@ -54,7 +54,7 @@ generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/ku
GO111MODULE=on ./generate_golden.sh

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

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

.PHONY: test-project-generation
test-project-generation: ## Run the unit tests (used in the CI)
- go get sigs.k8s.io/kind@v0.5.1
.PHONY: test-ci
test-ci: ## Run the unit tests (used in the CI)
./setup.sh
./test.sh

.PHONY: test-e2e
test-e2e: ## Run the integration tests (used in the CI)
./test_e2e_v1.sh
./test_e2e_v2.sh
./test_e2e.sh
@@ -19,6 +19,9 @@ set -o pipefail

source common.sh

export TRACE=1
export GO111MODULE=on

fetch_tools
install_go_dep
build_kb
@@ -14,6 +14,10 @@
# depManifestOverride variable in cmd/kubebuilder/initproject/dep_manifest.go
#

########################################################################################################
# NOTE: It is deprecated since is valid just for version 1 #
########################################################################################################

tmp_file="/tmp/dep.txt"
dep status -json|jq '.[]|.ProjectRoot,.Revision, .Version' > $tmp_file
while read name ; do
@@ -18,7 +18,12 @@ K8S_VERSION=$1

export GO111MODULE=on

# setup go module to create the cluster
go get sigs.k8s.io/kind@v0.5.1

# 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
kind create cluster --config test/kind-config.yaml --image=kindest/node:$K8S_VERSION

# setup the go modules required
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.2
go get sigs.k8s.io/kustomize/kustomize/v3@v3.2.1
@@ -19,6 +19,10 @@ set -o pipefail

source common.sh

export TRACE=1
export GO111MODULE=on

# This test is used by prow and if the dep not be installed by git then it will face the GOBIN issue.
install_dep_by_git

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

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

# test project v2
GO111MODULE=on test_project project-v2 2

exit $rc

This file was deleted.

@@ -19,6 +19,9 @@ set -o pipefail

source common.sh

export TRACE=1
export GO111MODULE=on

fetch_tools
install_go_dep
build_kb
@@ -28,4 +31,6 @@ setup_envs
docker pull gcr.io/kubebuilder/kube-rbac-proxy:v0.4.1
kind load docker-image gcr.io/kubebuilder/kube-rbac-proxy:v0.4.1

# The v1 is deprecated
go test ./test/e2e/v1
go test ./test/e2e/v2

This file was deleted.

0 comments on commit f8b626c

Please sign in to comment.
You can’t perform that action at this time.