CI: add code-size check for files crossing LOC threshold (#12810)

* CI: add code-size check for files crossing LOC threshold

* feat(ci): add duplicate function detection to CI code-size check

The --compare-to mode now also detects new duplicate function names
introduced by a PR. Uses git diff to scope checks to changed files
only, keeping CI fast.

* fix(ci): address review feedback for code-size check

- Validate git ref upfront; exit 2 if ref doesn't exist
- Distinguish 'file missing at ref' from genuine git errors
- Explicitly fetch base branch ref in CI workflow
- Raise threshold from 700 to 1000 lines

* fix(ci): exclude Swabble, skills, .pi from code analysis

* update gitignore for pycache

* ci: make code-size check informational (no failure on violations)
This commit is contained in:
max
2026-02-09 11:34:18 -08:00
committed by GitHub
parent 268094938b
commit 50b3d32d3c
3 changed files with 268 additions and 8 deletions

View File

@@ -386,6 +386,31 @@ jobs:
- name: Run ${{ matrix.task }}
run: ${{ matrix.command }}
# Check for files that grew past LOC threshold in this PR (delta-only).
code-size:
if: github.event_name == 'pull_request'
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Fetch base branch
run: git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
- name: Check code file sizes
run: |
python scripts/analyze_code_files.py \
--compare-to origin/${{ github.base_ref }} \
--threshold 1000
secrets:
runs-on: blacksmith-4vcpu-ubuntu-2404
steps: