Skip to content

Commit a97d336

Browse files
authored
chore: use github-action for golangci-lint workflow (#538)
Signed-off-by: odubajDT <[email protected]>
1 parent 3acd492 commit a97d336

22 files changed

+125
-63
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Lint checks
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
- '[0-9]+.[1-9][0-9]*.x'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
- '[0-9]+.[1-9][0-9]*.x'
11+
paths:
12+
- "**.go"
13+
- "**/go.mod"
14+
- "**/go.sum"
15+
- ".golangi.yml"
16+
- ".github/workflows/golangci-lint.yml"
17+
- "!docs/**"
18+
env:
19+
# renovate: datasource=github-releases depName=golangci/golangci-lint
20+
GOLANGCI_LINT_VERSION: "v1.55.2"
21+
GO_VERSION: "~1.20"
22+
jobs:
23+
golangci-lint:
24+
name: golangci-lint
25+
runs-on: ubuntu-22.04
26+
strategy:
27+
fail-fast: false
28+
steps:
29+
- name: Check out code
30+
uses: actions/checkout@v4
31+
32+
- uses: actions/setup-go@v4
33+
with:
34+
go-version: ${{ env.GO_VERSION }}
35+
check-latest: true
36+
37+
- name: golangci-lint
38+
uses: golangci/golangci-lint-action@v3
39+
with:
40+
working-directory: ./
41+
version: ${{ env.GOLANGCI_LINT_VERSION }}
42+
args: --config ./.golangci.yml -v

.github/workflows/pr-checks.yml

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,9 @@ permissions:
1919
contents: read
2020

2121
jobs:
22-
lint:
23-
runs-on: ubuntu-latest
24-
steps:
25-
- name: Install Go
26-
uses: actions/setup-go@v4
27-
with:
28-
go-version: ${{ env.DEFAULT_GO_VERSION }}
29-
- name: Checkout repository
30-
uses: actions/checkout@v3
31-
- name: Setup Environment
32-
run: |
33-
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
34-
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
35-
- name: Module cache
36-
uses: actions/cache@v3
37-
env:
38-
cache-name: go-mod-cache
39-
with:
40-
path: ~/go/pkg/mod
41-
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
42-
- name: Run linter
43-
run: make lint
44-
4522
unit-test:
4623
name: Unit Tests
47-
runs-on: ubuntu-latest
24+
runs-on: ubuntu-22.04
4825
steps:
4926
- name: Install Go
5027
uses: actions/setup-go@v4
@@ -78,7 +55,7 @@ jobs:
7855
docker-local:
7956
permissions:
8057
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
81-
runs-on: ubuntu-latest
58+
runs-on: ubuntu-22.04
8259
steps:
8360
- name: Checkout
8461
uses: actions/checkout@v3
@@ -117,7 +94,7 @@ jobs:
11794
path: ${{ github.workspace }}/open-feature-operator-local.tar
11895

11996
e2e-test:
120-
runs-on: ubuntu-latest
97+
runs-on: ubuntu-22.04
12198
needs: docker-local
12299
strategy:
123100
matrix:

.github/workflows/pr-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
pull-requests: write
1919
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
2020
name: Validate PR title
21-
runs-on: ubuntu-latest
21+
runs-on: ubuntu-22.04
2222
steps:
2323
- uses: amannn/action-semantic-pull-request@v5
2424
env:

.github/workflows/release-please.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
permissions:
2121
contents: write # for google-github-actions/release-please-action to create release commit
2222
pull-requests: write # for google-github-actions/release-please-action to create release PR
23-
runs-on: ubuntu-latest
23+
runs-on: ubuntu-22.04
2424

2525
# Release-please creates a PR that tracks all changes
2626
steps:
@@ -38,7 +38,7 @@ jobs:
3838
permissions:
3939
packages: write # to push the container image
4040
needs: release-please
41-
runs-on: ubuntu-latest
41+
runs-on: ubuntu-22.04
4242
if: ${{ needs.release-please.outputs.release_created }}
4343
steps:
4444
- name: Checkout
@@ -104,7 +104,7 @@ jobs:
104104
permissions:
105105
contents: write # for softprops/action-gh-release to create GitHub release
106106
needs: release-please
107-
runs-on: ubuntu-latest
107+
runs-on: ubuntu-22.04
108108
if: ${{ needs.release-please.outputs.release_created }}
109109
steps:
110110
- name: Checkout
@@ -139,7 +139,7 @@ jobs:
139139
needs: release-please
140140
permissions:
141141
contents: write
142-
runs-on: ubuntu-latest
142+
runs-on: ubuntu-22.04
143143
if: ${{ needs.release-please.outputs.release_created }}
144144
steps:
145145
- name: Checkout

.github/workflows/validate-crd-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defaults:
99
jobs:
1010
check-helm-docs:
1111
name: Check crd documentation values
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-22.04
1313
steps:
1414
- name: Check out code
1515
uses: actions/checkout@v3

.golangci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
run:
2+
timeout: 5m
3+
go: '1.20'
4+
linters:
5+
enable:
6+
- gofmt # Gofmt checks whether code was gofmt-ed. By default, this tool runs with -s option to check for code simplification
7+
- gci # Gci controls golang package import order and makes it always deterministic.
8+
- errorlint # errorlint can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
9+
- containedctx # containedctx is a linter that detects struct contained context.Context field
10+
- dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
11+
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
12+
- noctx # noctx finds sending http request without context.Context
13+
- gocyclo # measure cyclomatic complexity
14+
- gocognit # measure cognitive complexity
15+
- funlen # limit function length
16+
- dupl # Detect code duplication
17+
18+
issues:
19+
exclude-rules:
20+
- linters:
21+
- containedctx
22+
- gocyclo
23+
- gocognit
24+
- funlen
25+
path: _test\.go
26+
27+
linters-settings:
28+
gocyclo:
29+
min-complexity: 10
30+
gocognit:
31+
min-complexity: 20
32+
funlen:
33+
lines: 120
34+
statements: 120

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ e2e-test-validate-local:
8686
.PHONY: lint
8787
lint:
8888
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
89-
${GOPATH}/bin/golangci-lint run --deadline=3m --timeout=3m ./... # Run linters
89+
${GOPATH}/bin/golangci-lint run --deadline=3m --timeout=3m --config=./.golangci.yml -v ./... # Run linters
9090

9191
.PHONY: generate-crdocs
9292
generate-crdocs: kustomize crdocs

apis/core/v1alpha1/flagsourceconfiguration_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ type FlagSourceConfigurationList struct {
196196
Items []FlagSourceConfiguration `json:"items"`
197197
}
198198

199+
//nolint:gocyclo
199200
func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
200201
fsc := &FlagSourceConfigurationSpec{
201202
MetricsPort: DefaultMetricPort,
@@ -278,6 +279,7 @@ func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
278279
return fsc, nil
279280
}
280281

282+
//nolint:gocyclo
281283
func (fc *FlagSourceConfigurationSpec) Merge(new *FlagSourceConfigurationSpec) {
282284
if new == nil {
283285
return

apis/core/v1beta1/groupversion_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ limitations under the License.
1515
*/
1616

1717
// Package v1beta1 contains API Schema definitions for the core v1beta1 API group
18-
//+kubebuilder:object:generate=true
19-
//+groupName=core.openfeature.dev
18+
// +kubebuilder:object:generate=true
19+
// +groupName=core.openfeature.dev
2020
package v1beta1
2121

2222
import (

controllers/common/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package common
33
import (
44
"context"
55
"fmt"
6-
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
7-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
86
"time"
97

8+
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
109
appsV1 "k8s.io/api/apps/v1"
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
"sigs.k8s.io/controller-runtime/pkg/client"
1212
)
1313

0 commit comments

Comments
 (0)