From 16c859ba94af1f49d0c0cec05039893cf4ffa1c4 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Wed, 22 Nov 2023 08:14:41 +0000 Subject: [PATCH 1/3] chore(github-actions): bump up github action workflow step dependency Signed-off-by: Abhinandan Purkait --- .github/workflows/build.yml | 48 ++++++++++++++++-------------- .github/workflows/pull_request.yml | 33 ++++++++++---------- .github/workflows/release.yml | 16 +++++----- Makefile | 9 +++--- ci/ci-test.sh | 12 ++++---- 5 files changed, 61 insertions(+), 57 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1548d598a..14b38baeb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Shellcheck uses: reviewdog/action-shellcheck@v1 @@ -50,7 +50,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Unit test run: make test @@ -64,22 +64,25 @@ jobs: strategy: fail-fast: false matrix: - kubernetes: [v1.20.1] + kubernetes: [v1.25.16] steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v4 - name: Set up Go 1.16.5 - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: 1.16.5 - name: Setup Minikube-Kubernetes - uses: manusa/actions-setup-minikube@v2.3.0 + uses: medyagh/setup-minikube@latest with: - minikube version: v1.16.0 - kubernetes version: ${{ matrix.kubernetes }} - github token: ${{ secrets.GITHUB_TOKEN }} + cache: false + minikube-version: 1.31.1 + driver: none + kubernetes-version: ${{ matrix.kubernetes }} + cni: calico + start-args: '--install-addons=false' - name: Set tag run: | @@ -105,7 +108,7 @@ jobs: needs: ['lint', 'unit-test', 'e2e-tests'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -116,7 +119,7 @@ jobs: - name: Set Build Date id: date run: | - echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" + echo "DATE=$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" >> $GITHUB_OUTPUT - name: Set Tag run: | @@ -130,17 +133,16 @@ jobs: - name: Docker meta id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 + uses: docker/metadata-action@v4 with: # add each registry to which the image needs to be pushed here images: | ${{ env.IMAGE_ORG }}/cstor-csi-driver quay.io/${{ env.IMAGE_ORG }}/cstor-csi-driver ghcr.io/${{ env.IMAGE_ORG }}/cstor-csi-driver - tag-latest: false - tag-custom-only: true - tag-custom: | - ${{ env.TAG }} + tags: | + type=raw,value=latest,enable=false + type=raw,value=${{ env.TAG }} - name: Print Tag info run: | @@ -148,38 +150,38 @@ jobs: echo "${{ steps.docker_meta.outputs.tags }}" - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 with: platforms: all - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 with: version: v0.5.1 - name: Login to Docker Hub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to Quay - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_TOKEN }} - name: Login to GHCR - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build & Push Image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: context: . file: ./buildscripts/cstor-csi-driver/cstor-csi-driver.Dockerfile @@ -191,4 +193,4 @@ jobs: DBUILD_DATE=${{ steps.date.outputs.DATE }} DBUILD_REPO_URL=https://github.com/openebs/cstor-csi DBUILD_SITE_URL=https://openebs.io - BRANCH=${{ env.BRANCH }} + BRANCH=${{ env.BRANCH }} \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index e570a2bf7..b8b143aab 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Shellcheck uses: reviewdog/action-shellcheck@v1 @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Unit test run: make test @@ -61,22 +61,25 @@ jobs: strategy: fail-fast: false matrix: - kubernetes: [v1.20.1] + kubernetes: [v1.25.16] steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v4 - - name: Set up Go 1.16 - uses: actions/setup-go@v2 + - name: Set up Go 1.16.5 + uses: actions/setup-go@v4 with: go-version: 1.16.5 - name: Setup Minikube-Kubernetes - uses: manusa/actions-setup-minikube@v2.3.0 + uses: medyagh/setup-minikube@latest with: - minikube version: v1.16.0 - kubernetes version: ${{ matrix.kubernetes }} - github token: ${{ secrets.GITHUB_TOKEN }} + cache: false + minikube-version: 1.31.1 + driver: none + kubernetes-version: ${{ matrix.kubernetes }} + cni: calico + start-args: '--install-addons=false' - name: Set tag run: | @@ -102,25 +105,25 @@ jobs: needs: ['lint', 'unit-test', 'e2e-tests'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 with: platforms: all - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 with: version: v0.5.1 - name: Build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: context: . file: ./buildscripts/cstor-csi-driver/cstor-csi-driver.Dockerfile push: false platforms: linux/amd64, linux/arm64 tags: | - openebs/cstor-csi-driver:ci + openebs/cstor-csi-driver:ci \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e71e2fdea..0b652d553 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Set Image Org # sets the default IMAGE_ORG to openebs @@ -63,38 +63,38 @@ jobs: echo "RELEASE TAG: ${RELEASE_TAG}" - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 with: platforms: all - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 with: version: v0.5.1 - name: Login to Docker Hub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to Quay - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_TOKEN }} - name: Login to GHCR - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build & Push Image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: context: . file: ./buildscripts/cstor-csi-driver/cstor-csi-driver.Dockerfile @@ -106,4 +106,4 @@ jobs: DBUILD_DATE=${{ steps.date.outputs.DATE }} DBUILD_REPO_URL=https://github.com/openebs/cstor-csi DBUILD_SITE_URL=https://openebs.io - RELEASE_TAG=${{ env.RELEASE_TAG }} + RELEASE_TAG=${{ env.RELEASE_TAG }} \ No newline at end of file diff --git a/Makefile b/Makefile index 750a6bca2..52f738b50 100644 --- a/Makefile +++ b/Makefile @@ -22,11 +22,10 @@ VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods \ # Tools required for different make # targets or for development purposes EXTERNAL_TOOLS=\ - golang.org/x/tools/cmd/cover \ - github.com/axw/gocov/gocov \ - gopkg.in/matm/v1/gocov-html \ - github.com/onsi/ginkgo/ginkgo \ - github.com/onsi/gomega/... + golang.org/x/tools/cmd/cover@latest \ + github.com/axw/gocov/gocov@latest \ + github.com/matm/gocov-html/cmd/gocov-html@latest \ + github.com/onsi/ginkgo/ginkgo@v1.16.4 # The images can be pushed to any docker/image registeries # like docker hub, quay. The registries are specified in diff --git a/ci/ci-test.sh b/ci/ci-test.sh index 26103cde1..c9ef6e4b8 100755 --- a/ci/ci-test.sh +++ b/ci/ci-test.sh @@ -15,10 +15,10 @@ #!/usr/bin/env bash #OPENEBS_OPERATOR=https://raw.githubusercontent.com/openebs/openebs/HEAD/k8s/openebs-operator.yaml -NDM_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/ndm-operator.yaml -CSTOR_RBAC=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/rbac.yaml +# NDM_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/ndm-operator.yaml +# CSTOR_RBAC=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/rbac.yaml CSTOR_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/cstor-operator.yaml -ALL_CRD=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/crds/all_cstor_crds.yaml +# ALL_CRD=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/crds/all_cstor_crds.yaml CSI_OPERATOR="$GOPATH/src/github.com/openebs/cstor-csi/deploy/csi-operator.yaml" SNAPSHOT_CLASS="$GOPATH/src/github.com/openebs/cstor-csi/deploy/snapshot-class.yaml" @@ -27,9 +27,9 @@ SNAPSHOT_CLASS="$GOPATH/src/github.com/openebs/cstor-csi/deploy/snapshot-class.y # Prepare env for runnging BDD tests # Minikube is already running -kubectl apply -f $CSTOR_RBAC -kubectl apply -f $NDM_OPERATOR -kubectl apply -f $ALL_CRD +# kubectl apply -f $CSTOR_RBAC +# kubectl apply -f $NDM_OPERATOR +# kubectl apply -f $ALL_CRD kubectl apply -f $CSTOR_OPERATOR kubectl apply -f ./deploy/csi-operator.yaml kubectl apply -f ./deploy/snapshot-class.yaml From a49c9531a106aedcd246788a5cff374ccea30743 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Wed, 22 Nov 2023 08:36:33 +0000 Subject: [PATCH 2/3] fix(build): fix shellcheck review comments Signed-off-by: Niladri Halder Signed-off-by: Abhinandan Purkait --- .bettercodehub.yml | 1 - .github/workflows/build.yml | 2 +- .github/workflows/pull_request.yml | 1 - buildscripts/test-cov.sh | 2 +- buildscripts/test.sh | 4 ++-- ci/ci-test.sh | 33 ++++++++---------------------- tests/e2e/Makefile | 8 ++++---- 7 files changed, 16 insertions(+), 35 deletions(-) diff --git a/.bettercodehub.yml b/.bettercodehub.yml index 1de4a1ee8..b7b243086 100644 --- a/.bettercodehub.yml +++ b/.bettercodehub.yml @@ -3,4 +3,3 @@ languages: - go exclude: - /pkg/generated/.* -- /vendor/.* diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14b38baeb..7684bf952 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: reporter: github-pr-review path: '.' pattern: '*.sh' - exclude: './.git/*,./vendor/*' + exclude: './.git/*' unit-test: # to ignore builds on release diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b8b143aab..e9db4c186 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -41,7 +41,6 @@ jobs: reporter: github-pr-review path: '.' pattern: '*.sh' - exclude: './vendor/*' unit-test: runs-on: ubuntu-latest diff --git a/buildscripts/test-cov.sh b/buildscripts/test-cov.sh index f4b23f25d..0f1206c44 100755 --- a/buildscripts/test-cov.sh +++ b/buildscripts/test-cov.sh @@ -17,7 +17,7 @@ set -e echo "" > coverage.txt -for d in $(go list ./... | grep -v 'vendor\|pkg/apis\|pkg/client\|tests'); do +for d in $(go list ./... | grep -v 'pkg/apis\|pkg/client\|tests'); do #TODO - Include -race while creating the coverage profile. go test -coverprofile=profile.out -covermode=atomic $d if [ -f profile.out ]; then diff --git a/buildscripts/test.sh b/buildscripts/test.sh index 24e367ef6..90fbc64b0 100755 --- a/buildscripts/test.sh +++ b/buildscripts/test.sh @@ -17,7 +17,7 @@ set -e # Create a temp dir and clean it up on exit -TEMPDIR=`mktemp -d -t csi-test.XXX` +TEMPDIR=$(mktemp -d -t csi-test.XXX) trap "rm -rf $TEMPDIR" EXIT HUP INT QUIT TERM # Build the Maya binary for the tests @@ -26,7 +26,7 @@ go build -o $TEMPDIR/maya || exit 1 # Run the tests echo "--> Running tests" -GOBIN="`which go`" +GOBIN="$(which go)" PATH=$TEMPDIR:$PATH \ $GOBIN test ${GOTEST_FLAGS:--cover -timeout=900s} $($GOBIN list ./... | grep -v 'vendor\|pkg/apis\|pkg/generated\|tests') diff --git a/ci/ci-test.sh b/ci/ci-test.sh index c9ef6e4b8..20a630d9a 100755 --- a/ci/ci-test.sh +++ b/ci/ci-test.sh @@ -12,43 +12,30 @@ # See the License for the specific language governing permissions and # limitations under the License. +# shellcheck disable=SC1128 #!/usr/bin/env bash -#OPENEBS_OPERATOR=https://raw.githubusercontent.com/openebs/openebs/HEAD/k8s/openebs-operator.yaml -# NDM_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/ndm-operator.yaml -# CSTOR_RBAC=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/rbac.yaml -CSTOR_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/cstor-operator.yaml -# ALL_CRD=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/crds/all_cstor_crds.yaml +CSTOR_OPERATOR="https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/cstor-operator.yaml" -CSI_OPERATOR="$GOPATH/src/github.com/openebs/cstor-csi/deploy/csi-operator.yaml" -SNAPSHOT_CLASS="$GOPATH/src/github.com/openebs/cstor-csi/deploy/snapshot-class.yaml" - -#DST_PATH="$GOPATH/src/github.com/openebs" - -# Prepare env for runnging BDD tests -# Minikube is already running -# kubectl apply -f $CSTOR_RBAC -# kubectl apply -f $NDM_OPERATOR -# kubectl apply -f $ALL_CRD -kubectl apply -f $CSTOR_OPERATOR +kubectl apply -f "$CSTOR_OPERATOR" kubectl apply -f ./deploy/csi-operator.yaml kubectl apply -f ./deploy/snapshot-class.yaml function dumpCSINodeLogs() { LC=$1 CSINodePOD=$(kubectl get pods -l app=openebs-csi-node -o jsonpath='{.items[0].metadata.name}' -n kube-system) - kubectl describe po $CSINodePOD -n openebs + kubectl describe po "$CSINodePOD" -n openebs printf "\n\n" - kubectl logs --tail=${LC} $CSINodePOD -n openebs -c openebs-csi-plugin + kubectl logs --tail="${LC}" "$CSINodePOD" -n openebs -c openebs-csi-plugin printf "\n\n" } function dumpCSIControllerLogs() { LC=$1 CSIControllerPOD=$(kubectl get pods -l app=openebs-csi-controller -o jsonpath='{.items[0].metadata.name}' -n kube-system) - kubectl describe po $CSIControllerPOD -n openebs + kubectl describe po "$CSIControllerPOD" -n openebs printf "\n\n" - kubectl logs --tail=${LC} $CSIControllerPOD -n openebs -c openebs-csi-plugin + kubectl logs --tail="${LC}" "$CSIControllerPOD" -n openebs -c openebs-csi-plugin printf "\n\n" } @@ -57,18 +44,14 @@ kubectl wait --for=condition=Ready --timeout=300s pods/openebs-cstor-csi-control # Run e2e tests for csi volumes cd ./tests/e2e -make e2e-test -if [ $? -ne 0 ]; then +if ! make e2e-test; then echo "******************** CSI Controller logs***************************** " dumpCSIControllerLogs 1000 echo "********************* CSI Node logs *********************************" dumpCSINodeLogs 1000 -#echo "******************CSI Maya-apiserver logs ********************" -#dumpMayaAPIServerLogs 1000 - echo "get all the pods" kubectl get pods --all-namespaces diff --git a/tests/e2e/Makefile b/tests/e2e/Makefile index 5c3be3af3..40183f5eb 100644 --- a/tests/e2e/Makefile +++ b/tests/e2e/Makefile @@ -19,11 +19,11 @@ KUBECTL=/usr/local/bin/kubectl # If you want to change the Kubernetes version for e2e test, specify this variable from command line. -# e.g. $ make TEST_KUBERNETES_VERSION=1.17 test -TEST_KUBERNETES_VERSION=1.17 +# e.g. $ make TEST_KUBERNETES_VERSION=1.25.16 test +TEST_KUBERNETES_VERSION=1.25.16 -ifeq ($(TEST_KUBERNETES_VERSION),1.17) -KUBERNETES_VERSION=1.17.2 +ifeq ($(TEST_KUBERNETES_VERSION),1.25.16) +KUBERNETES_VERSION=1.25.16.2 endif From e8f29b328d03921f6daef3d7e5ee6286beeeb049 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Wed, 22 Nov 2023 12:49:43 +0000 Subject: [PATCH 3/3] chore(ci): revert ci-test.sh changes Signed-off-by: Abhinandan Purkait --- ci/ci-test.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ci/ci-test.sh b/ci/ci-test.sh index 20a630d9a..e15ce0435 100755 --- a/ci/ci-test.sh +++ b/ci/ci-test.sh @@ -15,10 +15,24 @@ # shellcheck disable=SC1128 #!/usr/bin/env bash -CSTOR_OPERATOR="https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/cstor-operator.yaml" +#OPENEBS_OPERATOR=https://raw.githubusercontent.com/openebs/openebs/HEAD/k8s/openebs-operator.yaml +NDM_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/ndm-operator.yaml +CSTOR_RBAC=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/rbac.yaml +CSTOR_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/cstor-operator.yaml +ALL_CRD=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/crds/all_cstor_crds.yaml -kubectl apply -f "$CSTOR_OPERATOR" -kubectl apply -f ./deploy/csi-operator.yaml +CSI_OPERATOR="$GOPATH/src/github.com/openebs/cstor-csi/deploy/csi-operator.yaml" +SNAPSHOT_CLASS="$GOPATH/src/github.com/openebs/cstor-csi/deploy/snapshot-class.yaml" + +#DST_PATH="$GOPATH/src/github.com/openebs" + +# Prepare env for runnging BDD tests +# Minikube is already running +kubectl apply -f $CSTOR_RBAC +kubectl apply -f $NDM_OPERATOR +kubectl apply -f $ALL_CRD +kubectl apply -f $CSTOR_OPERATOR +kubectl apply -f ./deploy/csi-operator.yaml kubectl apply -f ./deploy/snapshot-class.yaml function dumpCSINodeLogs() {