Skip to content

Add CI guard for validator file size limit (768 lines)#21077

Merged
pelikhan merged 4 commits intomainfrom
copilot/deep-report-add-ci-guard
Mar 15, 2026
Merged

Add CI guard for validator file size limit (768 lines)#21077
pelikhan merged 4 commits intomainfrom
copilot/deep-report-add-ci-guard

Conversation

Copy link
Contributor

Copilot AI commented Mar 15, 2026

Validator files have been repeatedly growing past the hard limit documented in AGENTS.md with no automated enforcement. This adds a make check-validator-sizes target and wires it into CI as a non-blocking job so regressions are visible immediately.

Changes

  • scripts/check-validator-sizes.sh — scans all *_validation.go files (excluding tests) and reports any exceeding 768 lines; exits 1 on violations, or 0 when WARN_ONLY=1; honors NO_COLOR, TERM=dumb, and non-TTY environments to emit plain text (no ANSI escape codes)
  • Makefile — new check-validator-sizes target + help text
  • .github/workflows/ci.yml — new check-validator-sizes job with continue-on-error: true (non-blocking); invokes the script with NO_COLOR=1 so the step summary output is readable plain text; shell variables are properly quoted

Current state

All existing validator files are within the 768-line limit. The CI job is intentionally non-blocking; once the team is confident no regressions exist, continue-on-error can be removed to make it blocking.

# Run locally
make check-validator-sizes          # blocking (exits 1 if violations found)
WARN_ONLY=1 make check-validator-sizes  # non-blocking (reports but exits 0)

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI and others added 2 commits March 15, 2026 03:36
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI linked an issue Mar 15, 2026 that may be closed by this pull request
@pelikhan pelikhan marked this pull request as ready for review March 15, 2026 13:37
Copilot AI review requested due to automatic review settings March 15, 2026 13:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automated visibility/enforcement for the 300-line hard limit on Go validator files (*_validation.go) documented in AGENTS.md, via a new make target and a non-blocking CI job.

Changes:

  • Added scripts/check-validator-sizes.sh to scan pkg/**/_validation.go files (excluding tests) and fail when any exceed 300 lines (or report-only with WARN_ONLY=1).
  • Added make check-validator-sizes target and documented it in make help.
  • Wired a new non-blocking check-validator-sizes job into CI with a formatted step summary.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
scripts/check-validator-sizes.sh New validator line-count checker with hard limit + warn-only mode.
Makefile New check-validator-sizes target and help text entry.
.github/workflows/ci.yml New CI job to run the checker and publish output to the step summary (non-blocking).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +32 to +35
line_count=$(wc -l < "$file")
# Note: wc -l counts newlines, so files without a trailing newline are
# counted as one line fewer. Go source files almost always have a trailing
# newline, so this off-by-one is acceptable for this advisory check.
Comment on lines +13 to +17
# Colors for output
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
Comment on lines +978 to +984
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
echo "## Validator File Size Check" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Checking \`*_validation.go\` files against the 300-line hard limit (AGENTS.md)." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$OUTPUT" >> $GITHUB_STEP_SUMMARY
Comment on lines +978 to +990
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
echo "## Validator File Size Check" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Checking \`*_validation.go\` files against the 300-line hard limit (AGENTS.md)." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$OUTPUT" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
if [ $EXIT_CODE -ne 0 ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "⚠️ This check is currently non-blocking. Fix violations to keep the codebase healthy." >> $GITHUB_STEP_SUMMARY
fi
exit $EXIT_CODE
@pelikhan
Copy link
Contributor

@copilot set limit at 512

…ting

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 15, 2026

@copilot set limit at 512

Done in 73b34bc — limit raised to 512. Also took the opportunity to fix the ANSI color/CI summary issues raised in the review: colors are now suppressed when not connected to a TTY or when NO_COLOR=1 is set, the CI step invokes the script with NO_COLOR=1 so the step summary stays readable, and shell variables are properly quoted.

Copilot AI changed the title Add CI guard for validator file size limit (300 lines) Add CI guard for validator file size limit (512 lines) Mar 15, 2026
Copilot AI requested a review from pelikhan March 15, 2026 13:47
@pelikhan
Copy link
Contributor

@copilot raise limit to 768

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 15, 2026

@copilot raise limit to 768

Done in 6954bb6 — limit raised to 768. All validator files now pass.

Copilot AI changed the title Add CI guard for validator file size limit (512 lines) Add CI guard for validator file size limit (768 lines) Mar 15, 2026
@pelikhan pelikhan merged commit 76f6c6e into main Mar 15, 2026
79 of 80 checks passed
@pelikhan pelikhan deleted the copilot/deep-report-add-ci-guard branch March 15, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[deep-report] Add CI guard for validator file size limit (300 lines)

3 participants