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

Add golangci github action and replace the deprecated golint #10187

Merged
merged 15 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint

z1cheng marked this conversation as resolved.
Show resolved Hide resolved
on:
pull_request:
types: [opened, edited, synchronize, reopened]
z1cheng marked this conversation as resolved.
Show resolved Hide resolved

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
z1cheng marked this conversation as resolved.
Show resolved Hide resolved
with:
version: v1.53
z1cheng marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
run:
z1cheng marked this conversation as resolved.
Show resolved Hide resolved
timeout: 10m
go: "1.20"
z1cheng marked this conversation as resolved.
Show resolved Hide resolved
allow-parallel-runners: true
17 changes: 2 additions & 15 deletions hack/verify-golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
z1cheng marked this conversation as resolved.
Show resolved Hide resolved

# ex: ts=2 sw=2 et filetype=sh
${LINT} run
z1cheng marked this conversation as resolved.
Show resolved Hide resolved