From e8952b6eedff519645e83b5c6892611d904d73e3 Mon Sep 17 00:00:00 2001 From: Marcela Melara Date: Wed, 25 Oct 2023 11:29:42 -0700 Subject: [PATCH] Switch Go linting to golangci-lint Signed-off-by: Marcela Melara --- .github/workflows/go-fmt.yml | 26 -------------------------- .github/workflows/lint.yml | 27 +++++++++++++++++++++++++++ .golangci.yml | 24 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 26 deletions(-) delete mode 100644 .github/workflows/go-fmt.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/go-fmt.yml b/.github/workflows/go-fmt.yml deleted file mode 100644 index a565108..0000000 --- a/.github/workflows/go-fmt.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Run Go checks -on: - workflow_dispatch: - push: - branches: - - main - paths: - - 'scai-gen/**' - # Want to trigger these tests whenever the Go CLI or - # APIs are modified - pull_request: - paths: - - 'scai-gen/**' -permissions: read-all -jobs: - tests: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - name: Install Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe - with: - go-version: 1.20.x - - name: Format - run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..6955c86 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: golangci-lint +on: + push: + branches: + - main + paths: + - "scai-gen/*" + # Want to trigger these tests whenever the Go CLI or + # APIs are modified + pull_request: + paths: + - "scai-gen/*" +permissions: + contents: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe + with: + go-version: '1.21.x' + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: golangci-lint + uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc + with: + version: v1.54.2 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..14fe0b1 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,24 @@ +linters: + enable: + - asciicheck + - errcheck + - errorlint + - gofmt + - goimports + - gosec + - gocritic + - importas + - prealloc + - revive + - misspell + - stylecheck + - tparallel + - unconvert + - unparam + - unused + - whitespace +output: + uniq-by-line: false +run: + issues-exit-code: 1 + timeout: 10m