-
Notifications
You must be signed in to change notification settings - Fork 1
Add prek pre-commit hooks #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,4 +30,4 @@ | |
| "mcp-graphql", | ||
| "context7" | ||
| ] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,4 +25,4 @@ | |
| "schedule": ["every weekend after 4am"] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Prek | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| determine-runner: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| runner: ${{ steps.runner.outputs.use-runner }} | ||
| steps: | ||
| - name: Determine runner | ||
| id: runner | ||
| uses: mikehardy/runner-fallback-action@v1 | ||
| with: | ||
| github-token: ${{ secrets.GH_RUNNER_TOKEN }} | ||
| primary-runner: self-hosted-16-cores | ||
| fallback-runner: ubuntu-latest | ||
| organization: fuww | ||
| fallback-on-error: true | ||
|
|
||
| prek: | ||
| runs-on: ${{ fromJson(needs.determine-runner.outputs.runner) }} | ||
| needs: [determine-runner] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: DeterminateSystems/nix-installer-action@main | ||
| - uses: DeterminateSystems/magic-nix-cache-action@main | ||
| - name: Run prek checks | ||
| run: nix develop --command prek run --all-files |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,4 +44,4 @@ | |
| }; | ||
| }; | ||
| }; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| { | ||
| "cloud_run_deploy": {} | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,4 +11,4 @@ | |
| ".cache": true, | ||
| "retool.config.json": true | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,4 +128,4 @@ export default defineConfig({ | |
| adapter: node({ | ||
| mode: "standalone" | ||
| }) | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,4 +17,4 @@ | |
| "lib": "@/lib", | ||
| "hooks": "@/hooks" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Pre-commit file checks (builtin Rust hooks — zero network, instant startup) | ||
| [[repos]] | ||
| repo = "builtin" | ||
| hooks = [ | ||
| { id = "trailing-whitespace" }, | ||
| { id = "end-of-file-fixer" }, | ||
| { id = "check-yaml" }, | ||
| { id = "check-json", exclude = "devcontainer\\.json$" }, | ||
| { id = "check-merge-conflict" }, | ||
| { id = "detect-private-key" }, | ||
| { id = "check-added-large-files", args = ["--maxkb=500"] }, | ||
| ] | ||
|
|
||
| # Commit message validation (local shell hooks) | ||
| [[repos]] | ||
| repo = "local" | ||
| hooks = [ | ||
| { id = "capitalized-subject", name = "Capitalized subject", language = "system", entry = "sh -c 'head -1 \"$1\" | grep -q \"^[A-Z]\" || { echo \"Commit subject must start with a capital letter\"; exit 1; }' --", stages = ["commit-msg"] }, | ||
| { id = "subject-max-length", name = "Subject max 50 chars", language = "system", entry = "sh -c 'len=$(head -1 \"$1\" | wc -m); [ \"$len\" -le 51 ] || { echo \"Commit subject too long ($len chars, max 50)\"; exit 1; }' --", stages = ["commit-msg"] }, | ||
| { id = "body-max-length", name = "Body lines max 72 chars", language = "system", entry = "sh -c 'grep -v \"^#\" \"$1\" | tail -n +3 | awk \"length > 72 { print NR\\\": \\\"\\$0; found=1 } END { if (found) { print \\\"Body lines must be 72 chars or less\\\"; exit 1 } }\"' --", stages = ["commit-msg"] }, | ||
| { id = "no-trailing-period", name = "No trailing period", language = "system", entry = "sh -c 'head -1 \"$1\" | grep -q \"\\\\.$\" && { echo \"Commit subject must not end with a period\"; exit 1; } || true' --", stages = ["commit-msg"] }, | ||
| { id = "github-issue-ref", name = "GitHub issue reference", language = "system", entry = "sh -c 'head -1 \"$1\" | grep -q \"#[0-9]\" || { echo \"Commit subject must reference a GitHub issue (e.g. #123)\"; exit 1; }' --", stages = ["commit-msg"] }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This check hard-requires Useful? React with 👍 / 👎. |
||
| { id = "max-message-length", name = "Max 500 chars total", language = "system", entry = "sh -c 'chars=$(wc -c < \"$1\"); [ \"$chars\" -le 500 ] || { echo \"Commit message too long ($chars chars, max 500)\"; exit 1; }' --", stages = ["commit-msg"] }, | ||
| { id = "no-branch-push", name = "No push to main/master", language = "system", entry = "sh -c 'branch=$(git symbolic-ref --short HEAD 2>/dev/null); case \"$branch\" in main|master|development) echo \"Direct push to $branch is not allowed\"; exit 1;; esac' --", stages = ["pre-push"] }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Useful? React with 👍 / 👎. |
||
| ] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bdcommand in Nix shellThis shell setup no longer installs or exposes
bd, and now only checksbr, but repo automation still requiresbd(for exampleloop.sh’sbeads_checkexits whencommand -v bdfails at lines 534-536). In a cleannix developenvironment, core task-tracking workflows now fail immediately unless contributors manually installbdoutside the declared dev shell.Useful? React with 👍 / 👎.