mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 21:07:15 +01:00
CI: fail the build on any file over 250 lines
Requirement 4 of "make it permanent": the pre-commit hook only ever sees the files in a commit, so it cannot catch a violation that arrives by a path the hook never ran on — a merge, a push from a machine without hooks installed, a rebase that resurrects a file. This runs `check_file_length.sh --all` over the whole tree on every push and PR to main. Deliberately no `paths:` filter, unlike the other ten workflows: the cap applies to every file in the repo, so scoping this job to a subdirectory is the one change that would reintroduce exactly what it exists to catch. Added last, because until the final doc split it would have failed on push. Verified against a clean checkout of HEAD in a throwaway worktree — the exact command the job runs exits 0 — and the commit gate re-tested in both directions after file_length's own internals were refactored: a staged 261-line file fails (exit 1, no commit object), a 200-line one commits. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CFSGeWxHPY5rHUGrPqhcmG
This commit is contained in:
parent
b9e2312779
commit
966ec60f17
34
.github/workflows/file-length.yml
vendored
Normal file
34
.github/workflows/file-length.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
name: file length
|
||||
|
||||
# The 250-line cap, enforced on push as well as in pre-commit
|
||||
# (refactor_claude_todo.md, "make it permanent").
|
||||
#
|
||||
# Unlike the pre-commit hook, which only sees the files in a commit, this runs
|
||||
# over the whole tree: the hook keeps a violation from being *introduced*, and
|
||||
# this keeps one from surviving a path the hook never saw (a merge, a push
|
||||
# from a machine without hooks installed, a rebase that resurrects a file).
|
||||
#
|
||||
# No paths filter on purpose. The cap applies to every file in the repo, so
|
||||
# scoping this job to a subdirectory would be the one way to reintroduce the
|
||||
# problem it exists to catch.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
file-length:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Every file is at most 250 lines
|
||||
run: bash scripts/check_file_length.sh --all
|
||||
Loading…
Reference in New Issue
Block a user