Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add golangci-lint workflow #448

Merged
Merged
31 changes: 31 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: golangci-lint
on: pull_request
env:
GOLANGCI_LINT_VERSION: "v1.50.1"
GO_VERSION: "1.19"
jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
config:
- name: "keptn-lifecycle-operator"
folder: "operator/"
- name: "scheduler"
folder: "scheduler/"
steps:
- name: Check out code into the Go module directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this name is maybe a bit misleading. what go module are we meaning here?

uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
working-directory: ${{ matrix.config.folder }}
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --config ../.golangci.yml -v
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
run:
timeout: 5m
go: '1.19'
linters:
enable:
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
# - dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
# - containedctx # containedctx is a linter that detects struct contained context.Context field
# - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
# - gci # Gci controls golang package import order and makes it always deterministic.
# - nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
# - noctx # noctx finds sending http request without context.Context
3 changes: 2 additions & 1 deletion operator/controllers/common/activemetricsobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

// ActiveMetricsObject represents an object whose active metrics are stored
//
//go:generate moq -pkg fake --skip-ensure -out ./fake/activemetricsobject_mock.go . ActiveMetricsObject
//ActiveMetricsObject represents an object whose active metrics are stored
type ActiveMetricsObject interface {
GetActiveMetricsAttributes() []attribute.KeyValue
IsEndTimeSet() bool
Expand Down
32 changes: 17 additions & 15 deletions operator/controllers/common/fake/activemetricsobject_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions operator/controllers/common/fake/listitem_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 47 additions & 39 deletions operator/controllers/common/fake/metricsobject_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading