Skip to content

Commit c78fa54

Browse files
Merge pull request #1814 from jarrpa/merge-jarrpa-dev
Various QoL changes from jarrpa-dev
2 parents 02a8205 + 9c2eb39 commit c78fa54

File tree

6 files changed

+102
-15
lines changed

6 files changed

+102
-15
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
name: ocs-operator sanity checks
3+
4+
on:
5+
push:
6+
branches: ['*']
7+
pull_request:
8+
branches: ['*']
9+
10+
jobs:
11+
shellcheck:
12+
name: shellcheck
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Run shellcheck
22+
run: make shellcheck
23+
24+
golangci-lint:
25+
name: golangci-lint
26+
runs-on: ubuntu-latest
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
go: ["1.17", "1.18"]
31+
steps:
32+
- uses: actions/setup-go@v3
33+
with:
34+
go-version: ${{ matrix.go }}
35+
go-version-file: go.mod
36+
37+
- uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 0
40+
41+
- uses: golangci/golangci-lint-action@v3
42+
with:
43+
version: v1.49.0
44+
args: -E gosec --timeout=6m
45+
46+
go-test:
47+
name: go-test unit tests
48+
runs-on: ubuntu-latest
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
go: ["1.17", "1.18"]
53+
steps:
54+
- uses: actions/setup-go@v3
55+
with:
56+
go-version: ${{ matrix.go }}
57+
58+
- uses: actions/checkout@v3
59+
with:
60+
fetch-depth: 0
61+
62+
- name: Run go test
63+
run: make unit-test
64+
65+
verify-changes:
66+
name: verify generated changes
67+
runs-on: ubuntu-latest
68+
continue-on-error: true
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
go: ["1.17", "1.18"]
73+
make-target: ["verify-deps", "verify-generated", "verify-latest-csv", "verify-operator-bundle", "verify-latest-deploy-yaml"]
74+
steps:
75+
- uses: actions/setup-go@v3
76+
with:
77+
go-version: ${{ matrix.go }}
78+
79+
- uses: actions/checkout@v3
80+
with:
81+
fetch-depth: 0
82+
83+
- name: Run ${{ matrix.make-target }} make target
84+
run: make ${{ matrix.make-target }}

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ golangci-lint:
161161
@echo "Running golangci-lint run"
162162
hack/golangci_lint.sh
163163

164+
lint: ## Run golangci-lint inside a container
165+
source hack/common.sh; source hack/docker-common.sh; \
166+
$${IMAGE_BUILD_CMD} run --rm -v $${PROJECT_DIR}:/app:Z -w /app $${GO_LINT_IMG} golangci-lint run ./...
167+
164168
# ignoring the functest dir since it requires an active cluster
165169
# use 'make functest' to run just the functional tests
166170
unit-test:

controllers/storagecluster/storagecluster_controller_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"testing"
99

1010
"github.com/blang/semver"
11-
"github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1"
1211
configv1 "github.com/openshift/api/config/v1"
1312
quotav1 "github.com/openshift/api/quota/v1"
1413
routev1 "github.com/openshift/api/route/v1"
@@ -33,6 +32,7 @@ import (
3332
logf "sigs.k8s.io/controller-runtime/pkg/log"
3433
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3534

35+
nbv1 "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1"
3636
api "github.com/red-hat-storage/ocs-operator/api/v1"
3737
ocsv1alpha1 "github.com/red-hat-storage/ocs-operator/api/v1alpha1"
3838
"github.com/red-hat-storage/ocs-operator/controllers/defaults"
@@ -862,7 +862,7 @@ func TestStorageClusterFinalizer(t *testing.T) {
862862
Name: "noobaa",
863863
Namespace: mockStorageClusterRequest.NamespacedName.Namespace,
864864
}
865-
noobaaMock := &v1alpha1.NooBaa{
865+
noobaaMock := &nbv1.NooBaa{
866866
ObjectMeta: metav1.ObjectMeta{
867867
Name: namespacedName.Name,
868868
Namespace: mockStorageClusterRequest.NamespacedName.Namespace,
@@ -881,7 +881,7 @@ func TestStorageClusterFinalizer(t *testing.T) {
881881
assert.NoError(t, err)
882882
assert.Len(t, sc.ObjectMeta.GetFinalizers(), 1)
883883

884-
noobaa := &v1alpha1.NooBaa{}
884+
noobaa := &nbv1.NooBaa{}
885885
err = reconciler.Client.Get(context.TODO(), namespacedName, noobaa)
886886
assert.NoError(t, err)
887887
assert.Equal(t, noobaa.Name, noobaaMock.Name)
@@ -916,7 +916,7 @@ func TestStorageClusterFinalizer(t *testing.T) {
916916
assert.Len(t, sc.ObjectMeta.GetFinalizers(), 0)
917917
}
918918

919-
noobaa = &v1alpha1.NooBaa{}
919+
noobaa = &nbv1.NooBaa{}
920920
err = reconciler.Client.Get(context.TODO(), namespacedName, noobaa)
921921
assert.True(t, errors.IsNotFound(err))
922922
}
@@ -1023,9 +1023,9 @@ func createFakeScheme(t *testing.T) *runtime.Scheme {
10231023
assert.Fail(t, "failed to add routev1 scheme")
10241024
}
10251025

1026-
err = v1alpha1.SchemeBuilder.AddToScheme(scheme)
1026+
err = nbv1.SchemeBuilder.AddToScheme(scheme)
10271027
if err != nil {
1028-
assert.Fail(t, "failed to add v1alpha1 scheme")
1028+
assert.Fail(t, "failed to add nbv1 scheme")
10291029
}
10301030

10311031
err = appsv1.AddToScheme(scheme)

hack/build-functest.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ GINKGO=$GOBIN/ginkgo
1010

1111
if ! [ -x "$GINKGO" ]; then
1212
echo "Retrieving ginkgo and gomega build dependencies"
13-
# TODO: Move to `go install` while upgrading to Go 1.16
14-
# Currently, `go install` is unable to install ginkgo which
15-
# causes build failures during E2E tests. The workaround is
16-
# to install ginkgo and gomega using `go get` and turn off
17-
# the modules so that it doesn't update go.mod and go.sum files
18-
GO111MODULE=off go get github.com/onsi/ginkgo/ginkgo
19-
GO111MODULE=off go get github.com/onsi/gomega/...
13+
go install -v github.com/onsi/ginkgo/v2/ginkgo@latest
14+
go install -v github.com/onsi/gomega/...
2015
else
2116
echo "GINKO binary found at $GINKGO"
2217
fi
2318

2419

25-
"$GOBIN"/ginkgo build "functests/${suite}/"
20+
"${GINKGO}" build "functests/${suite}/"
2621

2722
mkdir -p $OUTDIR_BIN
2823
mv "functests/${suite}/${suite}.test" "${OUTDIR_BIN}/${suite}_tests"

hack/common.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ GOROOT="${GOROOT:-go env GOROOT}"
99
GOOS="${GOOS:-linux}"
1010
GOARCH="${GOARCH:-amd64}"
1111

12+
GO_LINT_IMG_LOCATION="${GO_LINT_IMG_LOCATION:-golangci/golangci-lint}"
13+
GO_LINT_IMG_TAG="${GO_LINT_IMG_TAG:-v1.49.0}"
14+
GO_LINT_IMG="${GO_LINT_IMG:-${GO_LINT_IMG_LOCATION}:${GO_LINT_IMG_TAG}}"
15+
1216
# Current DEV version of the CSV
1317
DEFAULT_CSV_VERSION="4.12.0"
1418
CSV_VERSION="${CSV_VERSION:-${DEFAULT_CSV_VERSION}}"

hack/source-manifests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function gen_ocs_csv() {
9494
cp config/crd/bases/* $ocs_crds_outdir
9595
}
9696

97-
if [ -z "$OPENSHIFT_BUILD_NAMESPACE" ]; then
97+
if [ -z "$OPENSHIFT_BUILD_NAMESPACE" ] && [ -z "$SKIP_CSV_DUMP" ]; then
9898
source hack/docker-common.sh
9999
dump_noobaa_csv
100100
dump_rook_csv

0 commit comments

Comments
 (0)