fix(ci): exclude test files from PR size classification - #2387
Conversation
Test code shouldn't inflate PR size labels — a 1-line fix with 500 lines of tests was getting classified as XL instead of XS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the .github/scripts/pr-labeler.sh script to exclude test files from the pull request size classification logic. A review comment suggests a more robust regex for identifying test files to ensure that directories like __tests__ and standalone test files are correctly captured and excluded.
| [.[] | select(.filename | test("\\.(md|txt|rst|adoc)$") | not) | .changes] | ||
| [.[] | ||
| | select(.filename | test("\\.(md|txt|rst|adoc)$") | not) | ||
| | select(.filename | test("^tests/|_test\\.rs$|_tests\\.rs$|/tests/|\\.test\\.[jt]sx?$|\\.spec\\.[jt]sx?$") | not) |
There was a problem hiding this comment.
The regex for identifying test files can be simplified and made more robust. The current implementation misses __tests__ directories and standalone test.rs or tests.rs files. Please ensure this updated pattern is applied consistently across all scripts and CI configurations that identify test files to prevent logic divergence, as per the repository's consistency guidelines.
| | select(.filename | test("^tests/|_test\\.rs$|_tests\\.rs$|/tests/|\\.test\\.[jt]sx?$|\\.spec\\.[jt]sx?$") | not) | |
| | select(.filename | test("(^|/)(__)?tests?(__)?/|(^|[/_])tests?\\.rs$|\\.(test|spec)\\.[jt]sx?$") | not) |
References
- When applying a best practice or logic change in shell scripts, it should be applied consistently across the codebase to avoid partial fixes and maintain synchronization between different scripts or CI/CD pipelines.
henrypark133
left a comment
There was a problem hiding this comment.
Review: Exclude test files from PR size classification (Risk: Low)
Clean fix. Adds a jq filter to exclude test files from the PR size calculation:
^tests/directory_test.rs/_tests.rssuffixes/tests/subdirectories.test.[jt]sx?/.spec.[jt]sx?patterns
Test-heavy PRs will now be classified by their production code size. Sensible change.
LGTM.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(ci): exclude test files from PR size classification Test code shouldn't inflate PR size labels — a 1-line fix with 500 lines of tests was getting classified as XL instead of XS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: retrigger with skip-regression-check label Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Zaki <zaki@iqlusion.io>
Summary
tests/,*_test.rs,*_tests.rs,*.test.{js,ts,jsx,tsx},*.spec.{js,ts,jsx,tsx}Test plan
🤖 Generated with Claude Code