Skip to content

Commit 851c5e4

Browse files
authored
Merge pull request #2346 from timflannagan/add-sanity-check
Introduce a sanity workflow for checking static linting violations in CI
2 parents 2fd0140 + 2246f8a commit 851c5e4

File tree

19 files changed

+50
-19
lines changed

19 files changed

+50
-19
lines changed

Diff for: .github/workflows/sanity.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
paths:
9+
- '**'
10+
- '!doc/**'
11+
12+
jobs:
13+
sanity:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-go@v2
18+
with:
19+
go-version: '~1.16'
20+
- name: Install goimports
21+
run: go install golang.org/x/tools/cmd/goimports@latest
22+
- name: Run sanity checks
23+
run: make vendor && make lint && make diff

Diff for: Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ clean:
184184
@rm -rf test/e2e/log
185185
@rm -rf e2e.namespace
186186

187+
lint:
188+
find . -name '*.go' -not -path "./vendor/*" -not -path "./pkg/lib/operatorclient/operatorclientmocks/*" | xargs gofmt -w
189+
find . -name '*.go' -not -path "./vendor/*" -not -path "./pkg/lib/operatorclient/operatorclientmocks/*" | xargs goimports -w
187190

188191
# Copy CRD manifests
189192
manifests: vendor

Diff for: pkg/controller/certs/certs.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import (
1616
)
1717

1818
type CertGenerator interface {
19-
Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)
19+
Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)
2020
}
2121

2222
type CertGeneratorFunc func(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)
2323

24-
func (f CertGeneratorFunc) Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error) {
24+
func (f CertGeneratorFunc) Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error) {
2525
return f(notAfter, organization, ca, hosts)
2626
}
2727

Diff for: pkg/controller/operators/catalog/installplan_sync.go

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66

7-
87
"github.com/sirupsen/logrus"
98
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
109
"k8s.io/apimachinery/pkg/labels"

Diff for: pkg/controller/operators/openshift/clusteroperator_controller_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package openshift
22

33
import (
44
"fmt"
5+
56
semver "github.com/blang/semver/v4"
67
. "github.com/onsi/ginkgo"
78
. "github.com/onsi/gomega"

Diff for: pkg/controller/operators/operatorcondition_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66

77
. "github.com/onsi/ginkgo"
88
. "github.com/onsi/gomega"
9-
operatorsv2 "github.com/operator-framework/api/pkg/operators/v2"
109
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
10+
operatorsv2 "github.com/operator-framework/api/pkg/operators/v2"
1111
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
1212

1313
appsv1 "k8s.io/api/apps/v1"

Diff for: pkg/controller/operators/operatorconditiongenerator_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
. "github.com/onsi/ginkgo"
1616
. "github.com/onsi/gomega"
17-
operatorsv2 "github.com/operator-framework/api/pkg/operators/v2"
1817
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
18+
operatorsv2 "github.com/operator-framework/api/pkg/operators/v2"
1919
)
2020

2121
var _ = Describe("The OperatorConditionsGenerator Controller", func() {

Diff for: pkg/controller/registry/grpc/source.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package grpc
22

33
import (
44
"context"
5-
"github.com/operator-framework/operator-registry/pkg/client"
65
"sync"
76
"time"
87

8+
"github.com/operator-framework/operator-registry/pkg/client"
9+
910
"github.com/sirupsen/logrus"
1011
"google.golang.org/grpc"
1112
"google.golang.org/grpc/connectivity"
@@ -225,4 +226,4 @@ func (s *SourceStore) ClientsForNamespaces(namespaces ...string) map[registry.Ca
225226

226227
// TODO : remove unhealthy
227228
return refs
228-
}
229+
}

Diff for: pkg/controller/registry/resolver/rbac.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func generateName(base string, o interface{}) string {
2222
hashutil.DeepHashObject(hasher, o)
2323
hash := utilrand.SafeEncodeString(fmt.Sprint(hasher.Sum32()))
2424
if len(base)+len(hash) > maxNameLength {
25-
base = base[:maxNameLength - len(hash) - 1]
25+
base = base[:maxNameLength-len(hash)-1]
2626
}
2727

2828
return fmt.Sprintf("%s-%s", base, hash)

Diff for: pkg/controller/registry/resolver/rbac_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ func TestGenerateName(t *testing.T) {
2929
name: "generate",
3030
args: args{
3131
base: "myname",
32-
o: []string{"something"},
32+
o: []string{"something"},
3333
},
3434
want: "myname-9c895f74f",
3535
},
3636
{
3737
name: "truncated",
3838
args: args{
3939
base: strings.Repeat("name", 100),
40-
o: []string{"something", "else"},
40+
o: []string{"something", "else"},
4141
},
4242
want: "namenamenamenamenamenamenamenamenamenamenamenamename-78fd8b4d6b",
4343
},

Diff for: pkg/lib/controller-runtime/client/ssa_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package client
22

33
import (
44
"context"
5-
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
65
"testing"
76

7+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
8+
89
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/testobj"
910
"github.com/stretchr/testify/require"
1011
corev1 "k8s.io/api/core/v1"

Diff for: pkg/lib/crd/storage.go

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package crd
22

33
import (
44
"fmt"
5+
56
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
67
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
78
"k8s.io/apimachinery/pkg/runtime"

Diff for: pkg/lib/crd/storage_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package crd
22

33
import (
4+
"testing"
5+
46
"github.com/stretchr/testify/require"
57
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
68
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7-
"testing"
89
)
910

1011
const crdName = "test"
@@ -152,4 +153,4 @@ func TestSafeStorageVersionUpgradeSuccess(t *testing.T) {
152153
require.True(t, safe)
153154
// expect no error, since crd upgrade is safe
154155
require.NoError(t, err, "did not expect error for safe CRD upgrade")
155-
}
156+
}

Diff for: pkg/lib/crd/version.go

-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ func Version(manifest *string) (string, error) {
3838

3939
return v, nil
4040
}
41-

Diff for: pkg/lib/operatorlister/configmap.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"sync"
66

7-
"k8s.io/api/core/v1"
7+
v1 "k8s.io/api/core/v1"
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
"k8s.io/apimachinery/pkg/labels"
1010
"k8s.io/apimachinery/pkg/types"

Diff for: pkg/lib/operatorlister/operatorgroup.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"k8s.io/apimachinery/pkg/labels"
99
"k8s.io/apimachinery/pkg/types"
1010

11-
"github.com/operator-framework/api/pkg/operators/v1"
11+
v1 "github.com/operator-framework/api/pkg/operators/v1"
1212
listers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/listers/operators/v1"
1313
)
1414

Diff for: pkg/lib/operatorlister/pod.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"sync"
66

7-
"k8s.io/api/core/v1"
7+
v1 "k8s.io/api/core/v1"
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
"k8s.io/apimachinery/pkg/labels"
1010
"k8s.io/apimachinery/pkg/types"

Diff for: pkg/package-server/provider/registry.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
87
"io"
98
"strings"
109
"sync"
1110
"time"
1211

12+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
13+
1314
"github.com/sirupsen/logrus"
1415
"google.golang.org/grpc"
1516
"google.golang.org/grpc/connectivity"

Diff for: test/e2e/registry.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package e2e
33
import (
44
"context"
55
"fmt"
6+
"os/exec"
7+
68
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
79
corev1 "k8s.io/api/core/v1"
810
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9-
"os/exec"
1011
)
1112

1213
// This module contains helper functions for copying images and creating image registries

0 commit comments

Comments
 (0)