Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 36 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,41 @@ permissions:
contents: read

jobs:
lint:
Comment thread
ThomasK33 marked this conversation as resolved.
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false

- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true

- name: Verify vendor is up to date
run: |
go mod tidy
go mod vendor
git diff --exit-code -- go.mod go.sum vendor/

- name: Run golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
with:
version: v2.8
args: --timeout=5m ./...
Comment thread
ThomasK33 marked this conversation as resolved.

- name: Run golangci-lint formatter checks
run: go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0 fmt --diff

- name: Run govulncheck
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1
with:
go-version-file: go.mod
go-package: ./...

test:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -68,7 +103,7 @@ jobs:

publish-main:
name: Publish GHCR :main
needs: [test, lint-actions]
needs: [test, lint, lint-actions]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
Expand Down
25 changes: 25 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "2"

run:
timeout: 5m
modules-download-mode: vendor

linters:
enable:
- bodyclose
- errorlint
- gosec
- misspell
- nilerr
- revive

formatters:
enable:
- gofumpt
settings:
gofumpt:
extra-rules: true

issues:
max-issues-per-linter: 0
max-same-issues: 0
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GOFLAGS ?= -mod=vendor
VENDOR_STAMP := vendor/.modules.stamp
MODULE_FILES := go.mod $(wildcard go.sum)

.PHONY: vendor test build verify-vendor codegen
.PHONY: vendor test build lint vuln verify-vendor codegen

$(VENDOR_STAMP): $(MODULE_FILES)
go mod tidy
Expand All @@ -18,6 +18,15 @@ test: $(VENDOR_STAMP)
build: $(VENDOR_STAMP)
GOFLAGS=$(GOFLAGS) go build ./...

lint: $(VENDOR_STAMP)
@command -v golangci-lint >/dev/null || (echo "golangci-lint not found; use nix develop" && exit 1)
GOFLAGS=$(GOFLAGS) golangci-lint run ./...
GOFLAGS=$(GOFLAGS) golangci-lint fmt --diff

vuln: $(VENDOR_STAMP)
@command -v govulncheck >/dev/null || (echo "govulncheck not found; use nix develop" && exit 1)
GOFLAGS=$(GOFLAGS) govulncheck ./...

verify-vendor:
go mod tidy
go mod vendor
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
goreleaser
actionlint
zizmor
golangci-lint
govulncheck
];
};
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/coder/coder-k8s

go 1.25.6
go 1.25.7

require (
k8s.io/apimachinery v0.35.0
Expand Down
1 change: 1 addition & 0 deletions internal/controller/codercontrolplane_controller.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package controller contains Kubernetes controllers for coder-k8s resources.
package controller

import (
Expand Down
8 changes: 4 additions & 4 deletions internal/deps/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package deps

import (
_ "k8s.io/apimachinery/pkg/runtime"
_ "k8s.io/client-go/kubernetes"
_ "k8s.io/code-generator"
_ "sigs.k8s.io/controller-runtime/pkg/client"
_ "k8s.io/apimachinery/pkg/runtime" // Keep apimachinery runtime dependency vendored.
_ "k8s.io/client-go/kubernetes" // Keep client-go kubernetes client vendored.
_ "k8s.io/code-generator" // Keep code-generator scripts vendored.
_ "sigs.k8s.io/controller-runtime/pkg/client" // Keep controller-runtime client vendored.
)
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package main provides the entrypoint for the coder-k8s binary.
package main

import (
Expand Down
Loading