From 966ec60f17f91c8f1ec0e448dc05e04a22e613c5 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sat, 22 Aug 2026 15:43:22 +0200 Subject: [PATCH] CI: fail the build on any file over 250 lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) Claude-Session: https://claude.ai/code/session_01CFSGeWxHPY5rHUGrPqhcmG --- .github/workflows/file-length.yml | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/file-length.yml diff --git a/.github/workflows/file-length.yml b/.github/workflows/file-length.yml new file mode 100644 index 0000000..f4c67e3 --- /dev/null +++ b/.github/workflows/file-length.yml @@ -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