Repository navigation
Expand file tree
/
Copy pathprek.toml
More file actions
85 lines (81 loc) · 8.09 KB
/
Copy pathprek.toml
File metadata and controls
85 lines (81 loc) · 8.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
minimum_prek_version = "0.5.7"
default_install_hook_types = ["pre-commit", "pre-push"]
default_stages = ["pre-commit"]
# Commits run only formatters, generators, and checks that stay scoped to the
# change or finish in a few seconds. Whole-repo lint, type checks, contract
# checks, and test suites run at pre-push, and CI runs the same make targets.
#
# prek runs hooks that share a priority value concurrently and runs priority
# groups in ascending order. Hooks that mutate files must not share a group
# with any hook that reads or writes the same files. Layout:
# 0 read-only guards (builtin checks, meta checks)
# 1-3 file fixers, each mutating domain isolated from same-file hooks
# 4 frontend-deps (bun install mutates node_modules, which every
# Node-based hook below reads; it must finish before they start)
# 8 lint-config-check (kennlint config must match before Go lint runs)
# 10 independent lanes: api-generate, Go lint, frontend core, rust, scripts
# 20 read-only Go consumers, concurrent with each other
[[repos]]
repo = "builtin"
hooks = [
{ id = "check-case-conflict", priority = 0 },
{ id = "check-merge-conflict", args = [
"--assume-in-merge",
], priority = 0 },
{ id = "detect-private-key", priority = 0 },
{ id = "no-commit-to-branch", priority = 0 },
{ id = "check-added-large-files", args = [
"--maxkb=1024",
], exclude = "^internal/apiclient/generated/client\\.go$", priority = 0 },
{ id = "check-json", priority = 0 },
{ id = "check-toml", priority = 0 },
{ id = "check-yaml", priority = 0 },
{ id = "trailing-whitespace", args = [
"--markdown-linebreak-ext=md",
], priority = 1 },
{ id = "end-of-file-fixer", priority = 2 },
]
[[repos]]
repo = "local"
hooks = [
# Formats staged files only; CI's `make fmt-check` covers the whole repo.
# Serial so concurrent batches don't rebuild ./custom-gcl at the same time.
{ id = "gofmt", name = "gofmt + gofumpt (via custom-gcl fmt)", language = "system", entry = "./scripts/run-hook-go.sh sh -c 'make -s custom-gcl && exec ./custom-gcl fmt \"$@\"' --", types = ["go"], require_serial = true, priority = 3 },
{ id = "cargo-fmt", name = "cargo fmt", language = "system", entry = "cargo fmt --all", files = "^(Cargo\\.toml|Cargo\\.lock|rust/.*\\.rs|rust/.*/Cargo\\.toml)$", pass_filenames = false, priority = 3 },
{ id = "frontend-deps", name = "install workspace dependencies", language = "system", entry = "make frontend-deps", stages = ["pre-commit", "pre-push"], always_run = true, pass_filenames = false, priority = 4 },
{ id = "lint-config-check", name = "kennlint config drift", language = "system", entry = "./scripts/run-hook-go.sh make lint-config-check", files = "^(\\.golangci(\\.overlay)?\\.yml|\\.custom-gcl\\.yml|go\\.mod|go\\.sum)$", pass_filenames = false, priority = 8 },
{ id = "api-generate", name = "regenerate api clients", language = "system", entry = "make api-generate", files = "^(.*\\.go|go\\.mod|go\\.sum|Makefile|package\\.json|bun\\.lock|\\.oxfmtrc\\.json|vite\\.config\\.ts|scripts/(cached-generate\\.sh|generate-schema-constraints\\.mjs)|internal/apiclient/.*|frontend/(package\\.json|vite\\.config\\.ts|scripts/generate-api-client\\.mjs|openapi/openapi\\.yaml|src/lib/api/(generated/.*|roborev/openapi\\.yaml)))$", exclude = "_test\\.go$", pass_filenames = false, priority = 10 },
{ id = "golangci-lint-check", name = "golangci-lint check", language = "system", entry = "./scripts/run-hook-go.sh make lint-check", stages = [
"pre-push",
], always_run = true, pass_filenames = false, priority = 10 },
{ id = "frontend-check", name = "vite-plus frontend core check", language = "system", entry = "make frontend-check-core-no-deps", files = "^(vite\\.config\\.ts|package\\.json|bun\\.lock|frontend/((src|tests)/.*\\.(svelte|ts)|package\\.json|tsconfig\\.json|vite\\.config\\.ts|playwright(-e2e)?\\.config\\.ts)|packages/(ui|github-app-ui)/(src/.*\\.(svelte|ts)|package\\.json|tsconfig\\.json))$", stages = ["pre-push"], pass_filenames = false, priority = 10 },
{ id = "cargo-clippy", name = "cargo clippy", language = "system", entry = "cargo clippy --workspace --all-targets -- -D warnings", files = "^(Cargo\\.toml|Cargo\\.lock|rust/.*\\.(rs|toml)|rust/.*/Cargo\\.toml)$", pass_filenames = false, priority = 10 },
{ id = "frontend-api-client-check", name = "prevent manual frontend /api/v1 calls", language = "system", entry = "make frontend-api-client-check", files = "^(scripts/lint-api-urls\\.(mjs|test\\.mjs)|frontend/src/.*\\.(svelte|ts|js|tsx|jsx))$", stages = ["pre-push"], pass_filenames = false, priority = 10 },
{ id = "font-size-token-check", name = "enforce font-size design tokens", language = "system", entry = "make font-size-token-check", files = "^(scripts/check-font-size-tokens\\.(ts|test\\.ts)|frontend/src/.*\\.(svelte|css|ts))$", pass_filenames = false, priority = 10 },
{ id = "script-tests", name = "script regression tests", language = "system", entry = "make script-tests", files = "^(scripts/.*\\.(mjs|ts|sh|py)|frontend/scripts/.*\\.ts|docs/screenshots/.*\\.(md|ts)|package\\.json|bun\\.lock)$", stages = ["pre-push"], pass_filenames = false, priority = 10 },
{ id = "playwright-version-check", name = "browser CI image matches pinned toolchain", language = "system", entry = "make playwright-version-check", files = "^(scripts/check-playwright-version\\.mjs|\\.github/docker/playwright/Dockerfile|\\.github/workflows/ci\\.yml|package\\.json|frontend/package\\.json|packages/github-app-ui/package\\.json)$", pass_filenames = false, priority = 10 },
{ id = "actions-lock-check", name = "workflow actions are locked", language = "system", entry = "make actions-lock-check-local", files = "^\\.github/workflows/.*\\.(ya?ml|lock)$", pass_filenames = false, priority = 10 },
{ id = "huma-check", name = "shared Huma API contract", language = "system", entry = "./scripts/run-hook-go.sh make huma-check", files = "(\\.(go|json|ya?ml|toml|sh|mk|m?[jt]sx?|cjs|svelte|vue)|(^|/)(go\\.(mod|sum)|[Mm]akefile|GNUmakefile|[Jj]ustfile))$", exclude = "(_test\\.go|\\.d\\.ts)$|\\.(test|spec|stories|browser)\\.|(^|/)(e2e|tests?|__tests__|__mocks__|mocks|fixtures)/", stages = ["pre-push"], pass_filenames = false, priority = 20 },
{ id = "huma-route-check", name = "prevent non-Huma Go routes", language = "system", entry = "./scripts/run-hook-go.sh make huma-route-check", files = "^(tools/nohttpmux/.*\\.go|cmd/.*\\.go|internal/.*\\.go|kenn-forge\\.go)$", exclude = "^(cmd|internal)/.*_test\\.go$", stages = ["pre-push"], pass_filenames = false, priority = 20 },
{ id = "git-test-fixture-check", name = "keep test Git inside gitsafe/gitfixture", language = "system", entry = "./scripts/run-hook-go.sh make git-test-fixture-check", files = "^(tools/norawgittest/.*\\.go|.*_test\\.go|internal/testutil/.*\\.go)$", stages = ["pre-push"], pass_filenames = false, priority = 20 },
{ id = "migration-history-check", name = "enforce immutable history and one migration per PR", language = "system", entry = "./scripts/run-hook-go.sh make migration-history-check", files = "^internal/db/migrations/.*$", pass_filenames = false, priority = 20 },
# The commit-time check sees only staged migrations, so a number that main
# takes after the branch's migration was committed passes locally and fails
# every CI job. At push, compare the branch's migrations with origin/main the
# way PR CI does. It reads origin/main, which changes without any pushed file
# changing, hence always_run. Stacked branches override the base ref.
{ id = "migration-history-check-push", name = "migration numbers stay unique against origin/main", language = "system", entry = "./scripts/run-hook-go.sh sh -c 'KENN_FORGE_MIGRATION_PR_BASE_REF=\"${KENN_FORGE_MIGRATION_PR_BASE_REF:-origin/main}\" exec make migration-history-check'", stages = ["pre-push"], always_run = true, pass_filenames = false, priority = 20 },
{ id = "nilaway", name = "nilaway", language = "system", entry = "./scripts/run-hook-go.sh make nilaway", stages = [
"pre-push",
], types_or = [
"go",
"go-mod",
"go-sum",
], pass_filenames = false, priority = 20 },
]
[[repos]]
repo = "meta"
hooks = [
{ id = "check-hooks-apply", priority = 0 },
{ id = "check-useless-excludes", priority = 0 },
]