Skip to content

Commit

Permalink
ci: run go vet and staticcheck separately
Browse files Browse the repository at this point in the history
dominickh, the author of staticcheck, doesn't recommend running
staticcheck as a part of golangci-lint. Run the real, official
staticcheck separately.

Run go vet separately as well. This way we know we're using the latest
official go vet tool.

Also, use autobuild to set up Go in the CodeQL analysis workflow.
  • Loading branch information
ryboe committed Nov 9, 2024
1 parent ab13383 commit a18258f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@ jobs:
security-events: write

steps:
- name: Checkout repository
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- name: initialize codeql
uses: github/codeql-action/init@v3
with:
languages: go
build-mode: autobuild

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
- name: perform codeql analysis
uses: github/codeql-action/analyze@v3
39 changes: 29 additions & 10 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,52 @@ on:

jobs:
lint:
name: GolangCI Lint
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up go
uses: actions/setup-go@v5
- name: set up go
uses: WillAbides/setup-go-faster@v1
with:
go-version-file: go.mod
- name: Run linter
- name: lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

check:
name: go vet
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: set up go
uses: WillAbides/setup-go-faster@v1
with:
go-version-file: go.mod
- name: run go vet
run: go vet ./...
- name: run staticcheck
uses: dominikh/staticcheck-action@v1
with:
version: latest

tests:
name: Run unit tests with the race detector enabled
name: run unit tests with the race detector enabled
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up go
uses: actions/setup-go@v5
- name: set up go
uses: WillAbides/setup-go-faster@v1
with:
go-version-file: go.mod
- name: Run unit tests
- name: run unit tests
run: go test -v -race ./...
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ linters:
- depguard # enforces that only deps on a whitelist can be used (meant for orgs, not small projects)
- execinquery # deprecated
- exhaustruct
- exportloopref # deprecated
- forbidigo # we need to use fmt.Print*()
- gomnd
- nolintlint
- nonamedreturns
- govet # we run the official go vet separately
- nolintlint # we do occasionally need to suppress linter false positives
- nonamedreturns # named returns often help readability
- paralleltest # tests only take 2.5s to run. no need to parallelize
- staticcheck # dominickh doesn't recommend running staticcheck as part of golangci-lint, so we run Real Staticcheck™ separately
- testpackage
- varnamelen # makes bad suggestions
- wsl
Expand Down

0 comments on commit a18258f

Please sign in to comment.