Add golangci github action and replace the deprecated golint (#10187)

* Add golangci github action and replace the deprecated golint

Signed-off-by: z1cheng <imchench@gmail.com>

* Install if golangci-lint not exists

Signed-off-by: z1cheng <imchench@gmail.com>

* Use -z operator

Signed-off-by: z1cheng <imchench@gmail.com>

* Fix json tag for DatadogSampleRate field in config.go

Signed-off-by: z1cheng <imchench@gmail.com>

* Add golangci linters

Signed-off-by: z1cheng <imchench@gmail.com>

* Revert DatadogSampleRate fix

Signed-off-by: z1cheng <imchench@gmail.com>

* Fix comments

Signed-off-by: z1cheng <imchench@gmail.com>

* Add a new line

Signed-off-by: z1cheng <imchench@gmail.com>

* fixup! Add a new line

Signed-off-by: z1cheng <imchench@gmail.com>

* Add trigger condition

Signed-off-by: z1cheng <imchench@gmail.com>

* Add golint-check entry in makefile

Signed-off-by: Chen Chen <imchench@gmail.com>

* Run golint-check in a container

Signed-off-by: Chen Chen <imchench@gmail.com>

---------

Signed-off-by: z1cheng <imchench@gmail.com>
Signed-off-by: Chen Chen <imchench@gmail.com>
This commit is contained in:
Chen Chen 2023-09-07 01:06:53 +08:00 committed by GitHub
parent c9ca168364
commit 8a6af6068d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 289 additions and 33 deletions

View file

@ -78,25 +78,6 @@ jobs:
# G307 TODO: Deferring unsafe method "Close"
args: -exclude=G109,G601,G104,G204,G304,G306,G307 -tests=false -exclude-dir=test -exclude-dir=images/ -exclude-dir=docs/ ./...
lint:
runs-on: ubuntu-latest
needs: changes
if: |
(needs.changes.outputs.go == 'true')
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Set up Go
id: go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.20'
check-latest: true
- name: Run Lint
run: ./hack/verify-golint.sh
gofmt:
runs-on: ubuntu-latest
needs: changes

34
.github/workflows/golangci-lint.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: golangci-lint
on:
pull_request:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- 'deploy/**'
- '**.md'
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Go
id: go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: '1.20'
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: v1.53