Skip to content

Commit 20180ac

Browse files
cpcloudclaude
andauthored
perf(ci): move slow pre-push hooks to CI and split into Lint/Security workflows (#720)
## Summary - Disable `deadcode`, `golangci-lint`, `govulncheck`, and `osv-scanner` from pre-push hooks (`enable = false`) so they no longer block `git push` - Keep `go-generate-check` as the sole remaining pre-push hook - Add `run-golangci-lint` nix app; the other three already existed - Update `run-pre-commit` nix app to accept optional args (defaults to `--all-files`, supports `--from-ref`/`--to-ref` passthrough) - Split CI into three focused workflows: - **CI** (`ci.yml`) — test matrix, benchmarks, nix build, docs, semantic release - **Lint** (`lint.yml`) — deadcode, golangci-lint, pre-commit (diff-only on PRs) - **Security** (`security.yml`) — govulncheck, osv-scanner, trufflehog, CodeQL - Merge `codeql.yml` into `security.yml`, simplify to `build-mode: none`, drop cron schedule closes #718 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a325f80 commit 20180ac

5 files changed

Lines changed: 189 additions & 107 deletions

File tree

.github/workflows/ci.yml

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

152-
deadcode:
153-
name: Dead Code
154-
runs-on: ubuntu-latest
155-
concurrency:
156-
group: ci-deadcode-${{ github.ref }}
157-
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
158-
steps:
159-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
160-
with:
161-
persist-credentials: false
162-
163-
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
164-
with:
165-
go-version: "1.25"
166-
167-
- name: Check for dead code
168-
run: go run golang.org/x/tools/cmd/deadcode@v0.42.0 -test ./...
169-
170-
pre-commit:
171-
name: Pre-commit
172-
runs-on: ubuntu-latest
173-
concurrency:
174-
group: ci-pre-commit-${{ github.ref }}
175-
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
176-
steps:
177-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
178-
with:
179-
persist-credentials: false
180-
181-
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
182-
183-
- name: Run pre-commit hooks
184-
run: nix run '.#pre-commit'
185-
186152
nix-build:
187153
name: Nix Build
188154
runs-on: ubuntu-latest
@@ -224,29 +190,13 @@ jobs:
224190
- name: Build docs
225191
run: nix run '.#docs'
226192

227-
secrets:
228-
name: Secret Scan
229-
runs-on: ubuntu-latest
230-
concurrency:
231-
group: ci-secrets-${{ github.ref }}
232-
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
233-
steps:
234-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
235-
with:
236-
fetch-depth: 0
237-
persist-credentials: false
238-
239-
- uses: trufflesecurity/trufflehog@7635b24fd512a2e817dd3e9dd661caaf035a079d # v3.93.1
240-
with:
241-
extra_args: --only-verified
242-
243193
# ---------------------------------------------------------------------------
244194
# Semantic Release (dry-run on PRs, publish on main push)
245195
# ---------------------------------------------------------------------------
246196

247197
semantic-release:
248198
name: Semantic Release
249-
needs: [test, deadcode, pre-commit, nix-build, docs, secrets]
199+
needs: [test, nix-build, docs]
250200
runs-on: ubuntu-latest
251201
concurrency:
252202
group: semantic-release-${{ github.ref }}

.github/workflows/codeql.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright 2026 Phillip Cloud
2+
# Licensed under the Apache License, Version 2.0
3+
4+
name: Lint
5+
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
branches: [main]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
deadcode:
17+
name: Dead Code
18+
runs-on: ubuntu-latest
19+
concurrency:
20+
group: lint-deadcode-${{ github.ref }}
21+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
22+
steps:
23+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
24+
with:
25+
persist-credentials: false
26+
27+
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
28+
29+
- name: Run deadcode
30+
run: nix run '.#deadcode'
31+
32+
golangci-lint:
33+
name: Lint
34+
runs-on: ubuntu-latest
35+
concurrency:
36+
group: lint-golangci-lint-${{ github.ref }}
37+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
38+
steps:
39+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
40+
with:
41+
persist-credentials: false
42+
43+
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
44+
45+
- name: Run golangci-lint
46+
run: nix run '.#golangci-lint'
47+
48+
pre-commit:
49+
name: Pre-commit
50+
runs-on: ubuntu-latest
51+
concurrency:
52+
group: lint-pre-commit-${{ github.ref }}
53+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
54+
steps:
55+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
56+
with:
57+
fetch-depth: 0
58+
persist-credentials: false
59+
60+
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
61+
62+
- name: Run pre-commit hooks
63+
run: nix run '.#pre-commit' -- --from-ref 'origin/${{ github.base_ref || 'main' }}' --to-ref HEAD

.github/workflows/security.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright 2026 Phillip Cloud
2+
# Licensed under the Apache License, Version 2.0
3+
4+
name: Security
5+
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
branches: [main]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
govulncheck:
17+
name: Vulnerability Check
18+
runs-on: ubuntu-latest
19+
concurrency:
20+
group: security-govulncheck-${{ github.ref }}
21+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
22+
steps:
23+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
24+
with:
25+
persist-credentials: false
26+
27+
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
28+
29+
- name: Run govulncheck
30+
run: nix run '.#govulncheck'
31+
32+
osv-scanner:
33+
name: OSV Scan
34+
runs-on: ubuntu-latest
35+
concurrency:
36+
group: security-osv-scanner-${{ github.ref }}
37+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
38+
steps:
39+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
40+
with:
41+
persist-credentials: false
42+
43+
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
44+
45+
- name: Run osv-scanner
46+
run: nix run '.#osv-scanner'
47+
48+
secrets:
49+
name: Secret Scan
50+
runs-on: ubuntu-latest
51+
concurrency:
52+
group: security-secrets-${{ github.ref }}
53+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
54+
steps:
55+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
56+
with:
57+
fetch-depth: 0
58+
persist-credentials: false
59+
60+
- uses: trufflesecurity/trufflehog@7635b24fd512a2e817dd3e9dd661caaf035a079d # v3.93.1
61+
with:
62+
extra_args: --only-verified
63+
64+
codeql:
65+
name: CodeQL (Go)
66+
runs-on: ubuntu-latest
67+
concurrency:
68+
group: security-codeql-${{ github.ref }}
69+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
70+
permissions:
71+
security-events: write
72+
env:
73+
CGO_ENABLED: "0"
74+
steps:
75+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
76+
with:
77+
persist-credentials: false
78+
79+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
80+
with:
81+
go-version: "1.25"
82+
83+
- name: Initialize CodeQL
84+
uses: github/codeql-action/init@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
85+
with:
86+
languages: go
87+
build-mode: manual
88+
89+
- name: Build
90+
run: go build ./...
91+
92+
- name: Perform CodeQL analysis
93+
uses: github/codeql-action/analyze@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3

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)