Skip to content

Commit 52a6d5c

Browse files
cpcloudclaude
andcommitted
perf(ci): move slow pre-push hooks to CI-only nix-tools matrix job
Disable deadcode, golangci-lint, govulncheck, and osv-scanner from pre-push hooks (they remain defined but with enable=false) and run them as independent CI jobs via a nix-tools matrix using cachix/install-nix-action and nix run. go-generate-check stays in pre-push. Also adds a run-golangci-lint nix app and updates the pre-commit CI step to use --from-ref/--to-ref for diff-only checking instead of --all-files. closes #718 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 232edde commit 52a6d5c

2 files changed

Lines changed: 53 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,33 @@ jobs:
149149
- name: Run smoke benchmarks
150150
run: go test -bench . -benchtime 1x -timeout 5m -run '^$' ./...
151151

152-
deadcode:
153-
name: Dead Code
152+
nix-tools:
153+
name: ${{ matrix.name }}
154154
runs-on: ubuntu-latest
155155
concurrency:
156-
group: ci-deadcode-${{ github.ref }}
156+
group: ci-${{ matrix.tool }}-${{ github.ref }}
157157
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
158+
strategy:
159+
fail-fast: ${{ github.event_name == 'pull_request' }}
160+
matrix:
161+
include:
162+
- tool: deadcode
163+
name: Dead Code
164+
- tool: golangci-lint
165+
name: Lint
166+
- tool: govulncheck
167+
name: Vulnerability Check
168+
- tool: osv-scanner
169+
name: OSV Scan
158170
steps:
159171
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
160172
with:
161173
persist-credentials: false
162174

163-
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
164-
with:
165-
go-version: "1.25"
175+
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
166176

167-
- name: Check for dead code
168-
run: go run golang.org/x/tools/cmd/deadcode@v0.42.0 -test ./...
177+
- name: Run ${{ matrix.tool }}
178+
run: nix run '.#${{ matrix.tool }}'
169179

170180
pre-commit:
171181
name: Pre-commit
@@ -176,12 +186,13 @@ jobs:
176186
steps:
177187
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
178188
with:
189+
fetch-depth: 0
179190
persist-credentials: false
180191

181192
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
182193

183194
- name: Run pre-commit hooks
184-
run: nix run '.#pre-commit'
195+
run: nix run '.#pre-commit' -- --from-ref 'origin/${{ github.base_ref || 'main' }}' --to-ref HEAD
185196

186197
nix-build:
187198
name: Nix Build
@@ -246,7 +257,7 @@ jobs:
246257

247258
semantic-release:
248259
name: Semantic Release
249-
needs: [test, deadcode, pre-commit, nix-build, docs, secrets]
260+
needs: [test, nix-tools, pre-commit, nix-build, docs, secrets]
250261
runs-on: ubuntu-latest
251262
concurrency:
252263
group: semantic-release-${{ github.ref }}

flake.nix

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
};
126126
nixfmt.enable = true;
127127
golangci-lint = {
128-
enable = true;
128+
enable = false; # CI-only job
129129
stages = [ "pre-push" ];
130130
};
131131
actionlint.enable = true;
@@ -160,7 +160,7 @@
160160
pass_filenames = false;
161161
};
162162
deadcode-check = {
163-
enable = true;
163+
enable = false; # CI-only job
164164
name = "deadcode";
165165
entry = "${run-deadcode}/bin/run-deadcode";
166166
files = "\\.go$";
@@ -169,7 +169,7 @@
169169
stages = [ "pre-push" ];
170170
};
171171
govulncheck = {
172-
enable = true;
172+
enable = false; # CI-only job
173173
name = "govulncheck";
174174
entry = "${run-govulncheck}/bin/run-govulncheck";
175175
files = "^go\\.(mod|sum)$";
@@ -178,7 +178,7 @@
178178
stages = [ "pre-push" ];
179179
};
180180
osv-scanner = {
181-
enable = true;
181+
enable = false; # CI-only job
182182
name = "osv-scanner";
183183
entry = "${run-osv-scanner}/bin/run-osv-scanner";
184184
files = "^go\\.(mod|sum)$";
@@ -292,6 +292,22 @@
292292
'';
293293
};
294294

295+
run-golangci-lint = pkgs.writeShellApplication {
296+
name = "run-golangci-lint";
297+
runtimeInputs = [
298+
pkgs.golangci-lint
299+
pkgs.go
300+
];
301+
runtimeEnv.CGO_ENABLED = "0";
302+
text = ''
303+
_tmpdir=$(mktemp -d -t micasa-golangci-lint-XXXXXX)
304+
trap 'chmod -R u+w "$_tmpdir" 2>/dev/null; rm -rf "$_tmpdir"' EXIT
305+
export GOCACHE="''${GOCACHE:-$_tmpdir/gocache}"
306+
export GOMODCACHE="''${GOMODCACHE:-$_tmpdir/gomodcache}"
307+
golangci-lint run ./...
308+
'';
309+
};
310+
295311
goModTidyCheck = pkgs.writeShellApplication {
296312
name = "go-mod-tidy-check";
297313
runtimeInputs = [
@@ -596,7 +612,12 @@
596612
gen-mixed-pdf
597613
'';
598614
};
599-
inherit run-deadcode run-govulncheck run-osv-scanner;
615+
inherit
616+
run-deadcode
617+
run-govulncheck
618+
run-osv-scanner
619+
run-golangci-lint
620+
;
600621
run-pre-commit = pkgs.writeShellApplication {
601622
name = "run-pre-commit";
602623
runtimeInputs = [
@@ -617,8 +638,11 @@
617638
];
618639
text = ''
619640
${preCommit.shellHook}
620-
pre-commit run --all-files
621-
pre-commit run --all-files --hook-stage pre-push
641+
if [ $# -eq 0 ]; then
642+
set -- --all-files
643+
fi
644+
pre-commit run "$@"
645+
pre-commit run "$@" --hook-stage pre-push
622646
'';
623647
};
624648

@@ -646,6 +670,7 @@
646670
deadcode = app (pkg "run-deadcode") "Run whole-program dead code analysis";
647671
govulncheck = app (pkg "run-govulncheck") "Check for known Go vulnerabilities with call-graph analysis";
648672
osv-scanner = app (pkg "run-osv-scanner") "Scan for known vulnerabilities";
673+
golangci-lint = app (pkg "run-golangci-lint") "Run golangci-lint";
649674
pre-commit = app (pkg "run-pre-commit") "Run all pre-commit hooks";
650675
};
651676

0 commit comments

Comments
 (0)