From 80e19e98e59af472a8d5853e1e8456aab94471b8 Mon Sep 17 00:00:00 2001 From: Mayank Shah Date: Thu, 5 Nov 2020 12:29:30 +0530 Subject: [PATCH] Refactor for GH Actions Signed-off-by: Mayank Shah --- .github/workflows/e2e.yaml | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 33 +++++++-------------------------- test/e2e/e2e_suite_test.go | 4 ++-- 3 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/e2e.yaml diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 00000000..2a898d26 --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,37 @@ +name: E2E Tests +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + test: + name: E2E Tests + runs-on: ubuntu-latest + env: + REGISTRY: k8s.gcr.io/sig-storage + IMAGE_VERSION: ci-build + IMAGE_NAME: nfsplugin + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + id: go + - name: Build image + run: | + make build + docker build -t $REGISTRY/$IMAGE_NAME:$IMAGE_VERSION . + - uses: engineerd/setup-kind@v0.4.0 + name: Setting up KinD cluster + with: + version: "v0.9.0" + - name: Push image to KinD + run: | + kind load docker-image --name=kind $REGISTRY/$IMAGE_NAME:$IMAGE_VERSION + - name: Run E2E Tests + run: | + make e2e-test + diff --git a/Makefile b/Makefile index 718bc898..0bc2a248 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,7 @@ LDFLAGS ?= "-X ${PKG}/pkg/nfs.driverVersion=${IMAGE_VERSION} -X -s -w -extldflag IMAGE_NAME ?= nfsplugin REGISTRY ?= andyzhangx IMAGE_TAG = $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION) - - +GINKGO_FLAGS = -ginkgo.v all: build include release-tools/build.make @@ -57,19 +56,6 @@ local-k8s-uninstall: nfs: CGO_ENABLED=0 GOOS=linux go build -a -ldflags ${LDFLAGS} -o _output/nfsplugin ./cmd/nfsplugin -.PHONY: nfs-container -nfs-container: - docker buildx rm container-builder || true - docker buildx create --use --name=container-builder -ifdef CI - make nfs - docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG)-linux-amd64 . --platform="linux/amd64" --push . -ifdef PUBLISH - docker manifest create $(IMAGE_TAG_LATEST) $(IMAGE_TAG)-linux-amd64 - docker manifest inspect $(IMAGE_TAG_LATEST) -endif -endif - .PHONY: install-nfs-server install-nfs-server: kubectl apply -f ./examples/kubernetes/nfs-server/nfs-server.yaml @@ -78,21 +64,16 @@ install-nfs-server: install-helm: curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash -.PHONY: push -push: -ifdef CI - docker manifest push --purge $(IMAGE_TAG) -else - docker push $(IMAGE_TAG) -endif - .PHONY: e2e-bootstrap e2e-bootstrap: install-helm - docker pull $(IMAGE_TAG) || make nfs-container push helm install -n csi-driver-nfs ./charts/csi-driver-nfs --namespace kube-system --wait --timeout=15m -v=5 --debug \ --set image.nfs.repository=$(REGISTRY)/$(IMAGE_NAME) \ - --set image.smb.tag=$(IMAGE_VERSION) + --set image.nfs.tag=$(IMAGE_VERSION) .PHONY: e2e-teardown e2e-teardown: - helm delete csi-driver-nfs --namespace kube-system \ No newline at end of file + helm delete csi-driver-nfs --namespace kube-system + +.PHONY: e2e-test +e2e-test: + go test -v -timeout=0 ./test/e2e ${GINKGO_FLAGS} \ No newline at end of file diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 5762a575..93745f29 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -28,7 +28,7 @@ var ( perm *uint32 nfsDriver = nfs.NewNFSdriver(nodeID, "unix:///csi/csi.sock", perm) defaultStorageClassParameters = map[string]string{ - "server": "nfs-server.default.svc.cluster.loca", + "server": "nfs-server.default.svc.cluster.local", "share": "/", } ) @@ -120,5 +120,5 @@ func execTestCmd(cmds []testCmd) { func TestE2E(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) - ginkgo.RunSpecs(t, "E2e Suite") + ginkgo.RunSpecs(t, "E2E Suite") }