Add golangci github action and replace the deprecated golint
Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
ff0cb504d6
commit
facf582069
4 changed files with 34 additions and 34 deletions
19
.github/workflows/ci.yaml
vendored
19
.github/workflows/ci.yaml
vendored
|
@ -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@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: Run Lint
|
||||
run: ./hack/verify-golint.sh
|
||||
|
||||
gofmt:
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
|
|
28
.github/workflows/golangci-lint.yml
vendored
Normal file
28
.github/workflows/golangci-lint.yml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
name: golangci-lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, edited, synchronize, reopened]
|
||||
|
||||
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 # tag=v3.6.0
|
||||
with:
|
||||
version: v1.53
|
4
.golangci.yml
Normal file
4
.golangci.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
run:
|
||||
timeout: 10m
|
||||
go: "1.20"
|
||||
allow-parallel-runners: true
|
|
@ -22,19 +22,6 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
|||
|
||||
cd "${KUBE_ROOT}"
|
||||
|
||||
GOLINT=${GOLINT:-"golint"}
|
||||
PACKAGES=($(go list ./internal/... | grep -v /vendor/))
|
||||
bad_files=()
|
||||
for package in "${PACKAGES[@]}"; do
|
||||
out=$("${GOLINT}" -min_confidence=0.9 "${package}" | grep -v -E '(should not use dot imports|internal/file/bindata.go)' || :)
|
||||
if [[ -n "${out}" ]]; then
|
||||
bad_files+=("${out}")
|
||||
fi
|
||||
done
|
||||
if [[ "${#bad_files[@]}" -ne 0 ]]; then
|
||||
echo "!!! '$GOLINT' problems: "
|
||||
echo "${bad_files[@]}"
|
||||
exit 1
|
||||
fi
|
||||
LINT=${LINT:-golangci-lint}
|
||||
|
||||
# ex: ts=2 sw=2 et filetype=sh
|
||||
${LINT} run
|
Loading…
Reference in a new issue