Skip to content

Commit 446a113

Browse files
committed
Add lint and vulnerability scanning workflow
Add golangci-lint v2 configuration and make targets for lint/vuln. Integrate lint+govulncheck into CI and add tools to Nix devshell. Also bump Go toolchain to 1.25.7 and address revive lint requirements. --- _Generated with [`mux`](https://github.com/coder/mux) • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh`_
1 parent 68aaf00 commit 446a113

8 files changed

Lines changed: 99 additions & 6 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ permissions:
1010
contents: read
1111

1212
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version-file: go.mod
23+
cache: true
24+
25+
- name: Verify vendor is up to date
26+
run: |
27+
go mod tidy
28+
go mod vendor
29+
git diff --exit-code -- go.mod go.sum vendor/
30+
31+
- name: Run golangci-lint
32+
uses: golangci/golangci-lint-action@v9
33+
with:
34+
version: v2.8
35+
args: --timeout=5m ./...
36+
37+
- name: Run govulncheck
38+
uses: golang/govulncheck-action@v1
39+
with:
40+
go-version-file: go.mod
41+
go-package: ./...
42+
1343
test:
1444
runs-on: ubuntu-latest
1545
steps:

.golangci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
modules-download-mode: vendor
6+
7+
linters:
8+
enable:
9+
- bodyclose
10+
- errorlint
11+
- gosec
12+
- misspell
13+
- nilerr
14+
- revive
15+
16+
formatters:
17+
enable:
18+
- gofumpt
19+
settings:
20+
gofumpt:
21+
extra-rules: true
22+
23+
issues:
24+
max-issues-per-linter: 0
25+
max-same-issues: 0

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ GOFLAGS ?= -mod=vendor
22
VENDOR_STAMP := vendor/.modules.stamp
33
MODULE_FILES := go.mod $(wildcard go.sum)
44

5-
.PHONY: vendor test build verify-vendor codegen
5+
.PHONY: vendor test build lint vuln verify-vendor codegen
66

77
$(VENDOR_STAMP): $(MODULE_FILES)
88
go mod tidy
@@ -18,6 +18,14 @@ test: $(VENDOR_STAMP)
1818
build: $(VENDOR_STAMP)
1919
GOFLAGS=$(GOFLAGS) go build ./...
2020

21+
lint: $(VENDOR_STAMP)
22+
@command -v golangci-lint >/dev/null || (echo "golangci-lint not found; use nix develop" && exit 1)
23+
GOFLAGS=$(GOFLAGS) golangci-lint run ./...
24+
25+
vuln: $(VENDOR_STAMP)
26+
@command -v govulncheck >/dev/null || (echo "govulncheck not found; use nix develop" && exit 1)
27+
GOFLAGS=$(GOFLAGS) govulncheck ./...
28+
2129
verify-vendor:
2230
go mod tidy
2331
go mod vendor

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
goreleaser
2626
actionlint
2727
zizmor
28+
golangci-lint
29+
govulncheck
2830
];
2931
};
3032
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/coder/coder-k8s
22

3-
go 1.25.6
3+
go 1.25.7
44

55
require (
66
k8s.io/apimachinery v0.35.0

internal/deps/deps.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
package deps
66

77
import (
8-
_ "k8s.io/apimachinery/pkg/runtime"
9-
_ "k8s.io/client-go/kubernetes"
10-
_ "k8s.io/code-generator"
11-
_ "sigs.k8s.io/controller-runtime/pkg/client"
8+
_ "k8s.io/apimachinery/pkg/runtime" // Keep apimachinery runtime dependency vendored.
9+
_ "k8s.io/client-go/kubernetes" // Keep client-go kubernetes client vendored.
10+
_ "k8s.io/code-generator" // Keep code-generator scripts vendored.
11+
_ "sigs.k8s.io/controller-runtime/pkg/client" // Keep controller-runtime client vendored.
1212
)

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main provides the entrypoint for the coder-k8s binary.
12
package main
23

34
import (

0 commit comments

Comments
 (0)