Skip to content

Commit

Permalink
Refactor for GH Actions
Browse files Browse the repository at this point in the history
Signed-off-by: Mayank Shah <[email protected]>
  • Loading branch information
mayankshah1607 committed Nov 5, 2020
1 parent 21db7fa commit 80e19e9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 28 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
33 changes: 7 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
helm delete csi-driver-nfs --namespace kube-system

.PHONY: e2e-test
e2e-test:
go test -v -timeout=0 ./test/e2e ${GINKGO_FLAGS}
4 changes: 2 additions & 2 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": "/",
}
)
Expand Down Expand Up @@ -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")
}

0 comments on commit 80e19e9

Please sign in to comment.