Skip to content

Commit

Permalink
Merge pull request #1814 from jarrpa/merge-jarrpa-dev
Browse files Browse the repository at this point in the history
Various QoL changes from jarrpa-dev
  • Loading branch information
openshift-merge-robot committed Sep 15, 2022
2 parents 02a8205 + 9c2eb39 commit c78fa54
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 15 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ocs-operator-ci.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions controllers/storagecluster/storagecluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 3 additions & 8 deletions hack/build-functest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down
2 changes: 1 addition & 1 deletion hack/source-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c78fa54

Please sign in to comment.