From e3936cfc0ecc8a2455c1e371baf9e6a39daa9289 Mon Sep 17 00:00:00 2001 From: Michal Fiedorowicz Date: Mon, 29 Jan 2024 21:19:45 +0000 Subject: [PATCH 1/6] feat: OBS-8 - golangci-lint GitHub action workflow Signed-off-by: Michal Fiedorowicz --- .github/golangci.yaml | 23 +++++++++++++++++++ .github/workflows/golangci-lint.yaml | 33 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/golangci.yaml create mode 100644 .github/workflows/golangci-lint.yaml diff --git a/.github/golangci.yaml b/.github/golangci.yaml new file mode 100644 index 00000000..292b3f40 --- /dev/null +++ b/.github/golangci.yaml @@ -0,0 +1,23 @@ +run: + timeout: 5m + modules-download-mode: readonly + +output: + format: github-actions + +linters: + enable: + - revive + - errcheck + - unused + - staticcheck + - ineffassign + - govet + - gosimple + - bodyclose + +issues: + exclude-use-default: false + +severity: + default-severity: error diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml new file mode 100644 index 00000000..607f57dd --- /dev/null +++ b/.github/workflows/golangci-lint.yaml @@ -0,0 +1,33 @@ +name: golangci-lint +on: + push: + branches: + - "!release" + pull_request: + +permissions: + contents: read + +jobs: + golangci: + strategy: + matrix: + go: [ + "diode-sdk-go", + "diode-server", + ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.21' + cache: false + - name: golangci-lint ${{ matrix.go }} + uses: golangci/golangci-lint-action@v3 + with: + version: v1.54 + working-directory: ${{ matrix.go }} + args: --config ../../.github/golangci.yaml --issues-exit-code=0 + skip-pkg-cache: true + skip-build-cache: true From 53d53ed16fb87535b0a8d9bc8a086547a605cdae Mon Sep 17 00:00:00 2001 From: Michal Fiedorowicz Date: Mon, 29 Jan 2024 21:24:07 +0000 Subject: [PATCH 2/6] feat: OBS-8 - correct path to golangci-lint.yaml Signed-off-by: Michal Fiedorowicz --- .github/workflows/golangci-lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 607f57dd..17e79207 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -28,6 +28,6 @@ jobs: with: version: v1.54 working-directory: ${{ matrix.go }} - args: --config ../../.github/golangci.yaml --issues-exit-code=0 + args: --config ./.github/golangci.yaml --issues-exit-code=0 skip-pkg-cache: true skip-build-cache: true From 983c37f94e631116e2890cfcc945a8e6dbf0d404 Mon Sep 17 00:00:00 2001 From: Michal Fiedorowicz Date: Mon, 29 Jan 2024 21:25:06 +0000 Subject: [PATCH 3/6] feat: OBS-8 - correct path to golangci-lint.yaml Signed-off-by: Michal Fiedorowicz --- .github/workflows/golangci-lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 17e79207..6fe8391f 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -28,6 +28,6 @@ jobs: with: version: v1.54 working-directory: ${{ matrix.go }} - args: --config ./.github/golangci.yaml --issues-exit-code=0 + args: --config ../.github/golangci.yaml --issues-exit-code=0 skip-pkg-cache: true skip-build-cache: true From 0c2645729509e2b334127314ce3731aad8c1de43 Mon Sep 17 00:00:00 2001 From: Michal Fiedorowicz Date: Mon, 29 Jan 2024 21:35:24 +0000 Subject: [PATCH 4/6] feat: OBS-8 - default exit code (1) on golangci-lint issues Signed-off-by: Michal Fiedorowicz --- .github/workflows/golangci-lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 6fe8391f..1bd77952 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -28,6 +28,6 @@ jobs: with: version: v1.54 working-directory: ${{ matrix.go }} - args: --config ../.github/golangci.yaml --issues-exit-code=0 + args: --config ../.github/golangci.yaml skip-pkg-cache: true skip-build-cache: true From a2dd2c865d354b578b9f70201cf2ae92f839d0f1 Mon Sep 17 00:00:00 2001 From: Michal Fiedorowicz Date: Mon, 29 Jan 2024 21:42:29 +0000 Subject: [PATCH 5/6] feat: OBS-8 - revive.package-comments warning severity Signed-off-by: Michal Fiedorowicz --- .github/golangci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/golangci.yaml b/.github/golangci.yaml index 292b3f40..d60ad484 100644 --- a/.github/golangci.yaml +++ b/.github/golangci.yaml @@ -16,6 +16,12 @@ linters: - gosimple - bodyclose +linters-settings: + revive: + rules: + - name: package-comments + severity: warning + issues: exclude-use-default: false From c1d239c6a112f49469b368e13797eabc63571c92 Mon Sep 17 00:00:00 2001 From: Michal Fiedorowicz Date: Mon, 29 Jan 2024 22:11:08 +0000 Subject: [PATCH 6/6] feat: OBS-8 - exclude rule revive package-comments Signed-off-by: Michal Fiedorowicz --- .github/golangci.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/golangci.yaml b/.github/golangci.yaml index d60ad484..3cfdf04b 100644 --- a/.github/golangci.yaml +++ b/.github/golangci.yaml @@ -16,14 +16,13 @@ linters: - gosimple - bodyclose -linters-settings: - revive: - rules: - - name: package-comments - severity: warning - issues: exclude-use-default: false + exclude-rules: + - path: /*.go + text: "package-comments: should have a package comment" + linters: + - revive severity: default-severity: error