From 7df84f0f9274168b77589a4d35502fa9eba12a65 Mon Sep 17 00:00:00 2001 From: Markus Wennrich Date: Fri, 9 Sep 2022 07:40:18 +0200 Subject: [PATCH] fix release build --- Makefile | 11 ++++++----- tests/Dockerfile | 4 +++- tests/bats/start.bats | 13 ++++++------- tests/files/controller.yaml | 4 ++-- tests/files/reviver.yaml | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 78607a8..e682d04 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ GO111MODULE := on -DOCKER_TAG := $(or $(subst .,-,$(subst _,-,$(GIT_TAG_NAME))), latest) +DOCKER_TAG := $(or $(subst _,-,$(GIT_TAG_NAME)), latest) +PR_TAG := $(or $(subst .,-,$(subst _,-,$(GIT_TAG_NAME))), latest) all: provisioner controller @@ -36,13 +37,13 @@ tests: @minikube docker-env > tests/files/.dockerenv @sh -c '. ./tests/files/.dockerenv && docker build -t ghcr.io/metal-stack/csi-lvm-provisioner:${DOCKER_TAG} . -f cmd/provisioner/Dockerfile' @sh -c '. ./tests/files/.dockerenv && docker build -t ghcr.io/metal-stack/csi-lvm-controller:${DOCKER_TAG} . -f cmd/controller/Dockerfile' - @sh -c '. ./tests/files/.dockerenv && docker build -t csi-lvm-tests:${DOCKER_TAG} --build-arg prtag=${DOCKER_TAG} --build-arg prpullpolicy="IfNotPresent" --build-arg prdevicepattern="loop[0-1]" tests' >/dev/null - @sh -c '. ./tests/files/.dockerenv && docker run --rm csi-lvm-tests:${DOCKER_TAG} bats /bats/start.bats /bats/revive.bats /bats/end.bats' + @sh -c '. ./tests/files/.dockerenv && docker build -t csi-lvm-tests:${PR_TAG} --build-arg prtag=${PR_TAG} --build-arg dockertag=${DOCKER_TAG} --build-arg prpullpolicy="IfNotPresent" --build-arg prdevicepattern="loop[0-1]" tests' >/dev/null + @sh -c '. ./tests/files/.dockerenv && docker run --rm csi-lvm-tests:${PR_TAG} bats /bats/start.bats /bats/revive.bats /bats/end.bats' @rm tests/files/.dockerenv @rm tests/files/.kubeconfig @minikube delete .PHONY: metalci metalci: - docker build -t csi-lvm-tests:${DOCKER_TAG} --build-arg prtag=${DOCKER_TAG} --build-arg prpullpolicy="Always" --build-arg prdevicepattern='nvme[0-9]n[0-9]' tests > /dev/null - docker run --rm csi-lvm-tests:${DOCKER_TAG} bats /bats/start.bats /bats/cycle.bats /bats/end.bats + docker build -t csi-lvm-tests:${PR_TAG} --build-arg prtag=${PR_TAG} --build-arg dockertag=${DOCKER_TAG} --build-arg prpullpolicy="Always" --build-arg prdevicepattern='nvme[0-1]n[0-9]' tests > /dev/null + docker run --rm csi-lvm-tests:${PR_TAG} bats /bats/start.bats /bats/cycle.bats /bats/end.bats diff --git a/tests/Dockerfile b/tests/Dockerfile index 3f2ea39..6b7c9fd 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -3,6 +3,9 @@ FROM alpine ARG prtag ENV PRTAG=$prtag +ARG dockertag +ENV DOCKERTAG=$dockertag + ARG prpullpolicy ENV PRPULLPOLICY=$prpullpolicy @@ -20,4 +23,3 @@ RUN apk add --update ca-certificates \ COPY bats /bats COPY files /files - diff --git a/tests/bats/start.bats b/tests/bats/start.bats index 18736e9..c7d6318 100644 --- a/tests/bats/start.bats +++ b/tests/bats/start.bats @@ -1,7 +1,7 @@ #!/usr/bin/env bats -p @test "prepare test files" { - run sed -i "s/PRTAG/${PRTAG}/g;s/PRPULLPOLICY/${PRPULLPOLICY}/g;s/PRDEVICEPATTERN/${PRDEVICEPATTERN}/g" /files/* + run sed -i "s/PRTAG/${PRTAG}/g;s/PRPULLPOLICY/${PRPULLPOLICY}/g;s/PRDEVICEPATTERN/${PRDEVICEPATTERN}/g;s/DOCKERTAG/${DOCKERTAG}/g" /files/* [ "$status" -eq 0 ] } @@ -32,21 +32,21 @@ run kubectl apply -f /files/linear.yaml [ "$status" -eq 0 ] [ "${lines[0]}" = "pod/volume-test created" ] -} +} @test "deploy block pod" { run sleep 30 run kubectl apply -f /files/block.yaml [ "$status" -eq 0 ] [ "${lines[0]}" = "pod/volume-test-block created" ] -} +} @test "linear pvc bound" { run kubectl wait -n ${PRTAG} --for=condition=ready pod/volume-test --timeout=80s - run kubectl get pvc -n ${PRTAG} lvm-pvc-linear -o jsonpath="{.metadata.name},{.status.phase}" + run kubectl get pvc -n ${PRTAG} lvm-pvc-linear -o jsonpath="{.metadata.name},{.status.phase}" [ "$status" -eq 0 ] [ "$output" = "lvm-pvc-linear,Bound" ] -} +} @test "linear pod running" { run kubectl get pods -n ${PRTAG} volume-test -o jsonpath="{.metadata.name},{.status.phase}" @@ -59,11 +59,10 @@ run kubectl get pvc -n ${PRTAG} lvm-pvc-block -o jsonpath="{.metadata.name},{.status.phase}" [ "$status" -eq 0 ] [ "$output" = "lvm-pvc-block,Bound" ] -} +} @test "block pod running" { run kubectl get pods -n ${PRTAG} volume-test-block -o jsonpath="{.metadata.name},{.status.phase}" [ "$status" -eq 0 ] [ "$output" = "volume-test-block,Running" ] } - diff --git a/tests/files/controller.yaml b/tests/files/controller.yaml index a22c239..6b65704 100644 --- a/tests/files/controller.yaml +++ b/tests/files/controller.yaml @@ -111,7 +111,7 @@ spec: serviceAccountName: csi-lvm-controller-PRTAG containers: - name: csi-lvm-controller - image: ghcr.io/metal-stack/csi-lvm-controller:PRTAG + image: ghcr.io/metal-stack/csi-lvm-controller:DOCKERTAG imagePullPolicy: PRPULLPOLICY command: - /csi-lvm-controller @@ -125,7 +125,7 @@ spec: - name: CSI_LVM_PULL_POLICY value: "PRPULLPOLICY" - name: CSI_LVM_PROVISIONER_IMAGE - value: "ghcr.io/metal-stack/csi-lvm-provisioner:PRTAG" + value: "ghcr.io/metal-stack/csi-lvm-provisioner:DOCKERTAG" - name: CSI_LVM_DEVICE_PATTERN value: "/dev/PRDEVICEPATTERN" - name: PROVISIONER_NAME diff --git a/tests/files/reviver.yaml b/tests/files/reviver.yaml index 9fc5dde..3045213 100644 --- a/tests/files/reviver.yaml +++ b/tests/files/reviver.yaml @@ -98,7 +98,7 @@ spec: serviceAccountName: csi-lvm-reviver-PRTAG containers: - name: csi-lvm-reviver - image: ghcr.io/metal-stack/csi-lvm-provisioner:PRTAG + image: ghcr.io/metal-stack/csi-lvm-provisioner:DOCKERTAG imagePullPolicy: PRPULLPOLICY securityContext: privileged: true