From bab2bf63fa82e828ee9fee2ec2e6481a60979af1 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Tue, 6 Apr 2021 20:18:57 -0500 Subject: [PATCH 1/5] hack: add SKIP_CSV_DUMP variable Signed-off-by: Jose A. Rivera --- hack/source-manifests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/source-manifests.sh b/hack/source-manifests.sh index dfe753fc82..4acb46397d 100755 --- a/hack/source-manifests.sh +++ b/hack/source-manifests.sh @@ -94,7 +94,7 @@ function gen_ocs_csv() { cp config/crd/bases/* $ocs_crds_outdir } -if [ -z "$OPENSHIFT_BUILD_NAMESPACE" ]; then +if [ -z "$OPENSHIFT_BUILD_NAMESPACE" ] && [ -z "$SKIP_CSV_DUMP" ]; then source hack/docker-common.sh dump_noobaa_csv dump_rook_csv From 547d7d7b6e3663f0f70928dadee84800aed8fd22 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Thu, 15 Sep 2022 08:32:36 -0500 Subject: [PATCH 2/5] hack: new make target for containerized golangci-lint Signed-off-by: Jose A. Rivera --- Makefile | 4 ++++ hack/common.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 186d69736f..5de145a19d 100644 --- a/Makefile +++ b/Makefile @@ -161,6 +161,10 @@ golangci-lint: @echo "Running golangci-lint run" hack/golangci_lint.sh +lint: ## Run golangci-lint inside a container + source hack/common.sh; source hack/docker-common.sh; \ + $${IMAGE_BUILD_CMD} run --rm -v $${PROJECT_DIR}:/app:Z -w /app $${GO_LINT_IMG} golangci-lint run ./... + # ignoring the functest dir since it requires an active cluster # use 'make functest' to run just the functional tests unit-test: diff --git a/hack/common.sh b/hack/common.sh index b1d062712f..2258f861ad 100644 --- a/hack/common.sh +++ b/hack/common.sh @@ -9,6 +9,10 @@ GOROOT="${GOROOT:-go env GOROOT}" GOOS="${GOOS:-linux}" GOARCH="${GOARCH:-amd64}" +GO_LINT_IMG_LOCATION="${GO_LINT_IMG_LOCATION:-golangci/golangci-lint}" +GO_LINT_IMG_TAG="${GO_LINT_IMG_TAG:-v1.49.0}" +GO_LINT_IMG="${GO_LINT_IMG:-${GO_LINT_IMG_LOCATION}:${GO_LINT_IMG_TAG}}" + # Current DEV version of the CSV DEFAULT_CSV_VERSION="4.12.0" CSV_VERSION="${CSV_VERSION:-${DEFAULT_CSV_VERSION}}" From 853d160ddd8246736eb31d35b2bd79bc270f706c Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Wed, 22 Jun 2022 09:09:17 -0500 Subject: [PATCH 3/5] actions: add GitHub Action for sanity checks Signed-off-by: Jose A. Rivera --- .github/workflows/ocs-operator-ci.yaml | 84 ++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/ocs-operator-ci.yaml diff --git a/.github/workflows/ocs-operator-ci.yaml b/.github/workflows/ocs-operator-ci.yaml new file mode 100644 index 0000000000..686eae9bea --- /dev/null +++ b/.github/workflows/ocs-operator-ci.yaml @@ -0,0 +1,84 @@ +--- +name: ocs-operator sanity checks + +on: + push: + branches: ['*'] + pull_request: + branches: ['*'] + +jobs: + shellcheck: + name: shellcheck + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run shellcheck + run: make shellcheck + + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go: ["1.17", "1.18"] + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + go-version-file: go.mod + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: golangci/golangci-lint-action@v3 + with: + version: v1.49.0 + args: -E gosec --timeout=6m + + go-test: + name: go-test unit tests + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go: ["1.17", "1.18"] + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run go test + run: make unit-test + + verify-changes: + name: verify generated changes + runs-on: ubuntu-latest + continue-on-error: true + strategy: + fail-fast: false + matrix: + go: ["1.17", "1.18"] + make-target: ["verify-deps", "verify-generated", "verify-latest-csv", "verify-operator-bundle", "verify-latest-deploy-yaml"] + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run ${{ matrix.make-target }} make target + run: make ${{ matrix.make-target }} From 7cf3b1062ee3101b4ea6b139ceaac6ae6f8bbe96 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Fri, 17 Jun 2022 10:57:39 -0500 Subject: [PATCH 4/5] e2e: update to use 'go install' and be more verbose Signed-off-by: Jose A. Rivera --- hack/build-functest.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hack/build-functest.sh b/hack/build-functest.sh index 6be9daca5a..7e1fea5a7d 100755 --- a/hack/build-functest.sh +++ b/hack/build-functest.sh @@ -10,19 +10,14 @@ GINKGO=$GOBIN/ginkgo if ! [ -x "$GINKGO" ]; then echo "Retrieving ginkgo and gomega build dependencies" - # TODO: Move to `go install` while upgrading to Go 1.16 - # Currently, `go install` is unable to install ginkgo which - # causes build failures during E2E tests. The workaround is - # to install ginkgo and gomega using `go get` and turn off - # the modules so that it doesn't update go.mod and go.sum files - GO111MODULE=off go get github.com/onsi/ginkgo/ginkgo - GO111MODULE=off go get github.com/onsi/gomega/... + go install -v github.com/onsi/ginkgo/v2/ginkgo@latest + go install -v github.com/onsi/gomega/... else echo "GINKO binary found at $GINKGO" fi -"$GOBIN"/ginkgo build "functests/${suite}/" +"${GINKGO}" build "functests/${suite}/" mkdir -p $OUTDIR_BIN mv "functests/${suite}/${suite}.test" "${OUTDIR_BIN}/${suite}_tests" From 9c2eb3930f8646a1492e235b2cf503693935d0f2 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Tue, 16 Aug 2022 12:35:59 -0500 Subject: [PATCH 5/5] controllers: update one import of NooBaa API to match the rest Signed-off-by: Jose A. Rivera --- .../storagecluster/storagecluster_controller_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/controllers/storagecluster/storagecluster_controller_test.go b/controllers/storagecluster/storagecluster_controller_test.go index 15262ec196..4f5994f332 100644 --- a/controllers/storagecluster/storagecluster_controller_test.go +++ b/controllers/storagecluster/storagecluster_controller_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/blang/semver" - "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1" configv1 "github.com/openshift/api/config/v1" quotav1 "github.com/openshift/api/quota/v1" routev1 "github.com/openshift/api/route/v1" @@ -33,6 +32,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" + nbv1 "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1" api "github.com/red-hat-storage/ocs-operator/api/v1" ocsv1alpha1 "github.com/red-hat-storage/ocs-operator/api/v1alpha1" "github.com/red-hat-storage/ocs-operator/controllers/defaults" @@ -862,7 +862,7 @@ func TestStorageClusterFinalizer(t *testing.T) { Name: "noobaa", Namespace: mockStorageClusterRequest.NamespacedName.Namespace, } - noobaaMock := &v1alpha1.NooBaa{ + noobaaMock := &nbv1.NooBaa{ ObjectMeta: metav1.ObjectMeta{ Name: namespacedName.Name, Namespace: mockStorageClusterRequest.NamespacedName.Namespace, @@ -881,7 +881,7 @@ func TestStorageClusterFinalizer(t *testing.T) { assert.NoError(t, err) assert.Len(t, sc.ObjectMeta.GetFinalizers(), 1) - noobaa := &v1alpha1.NooBaa{} + noobaa := &nbv1.NooBaa{} err = reconciler.Client.Get(context.TODO(), namespacedName, noobaa) assert.NoError(t, err) assert.Equal(t, noobaa.Name, noobaaMock.Name) @@ -916,7 +916,7 @@ func TestStorageClusterFinalizer(t *testing.T) { assert.Len(t, sc.ObjectMeta.GetFinalizers(), 0) } - noobaa = &v1alpha1.NooBaa{} + noobaa = &nbv1.NooBaa{} err = reconciler.Client.Get(context.TODO(), namespacedName, noobaa) assert.True(t, errors.IsNotFound(err)) } @@ -1023,9 +1023,9 @@ func createFakeScheme(t *testing.T) *runtime.Scheme { assert.Fail(t, "failed to add routev1 scheme") } - err = v1alpha1.SchemeBuilder.AddToScheme(scheme) + err = nbv1.SchemeBuilder.AddToScheme(scheme) if err != nil { - assert.Fail(t, "failed to add v1alpha1 scheme") + assert.Fail(t, "failed to add nbv1 scheme") } err = appsv1.AddToScheme(scheme)