Repository navigation
ci: block new root-level entries - #11903
Conversation
Greptile SummaryThis PR introduces a new CI gate (
Confidence Score: 5/5Safe to merge — the guard script, workflow job, and tests are all self-contained with no risk to existing jobs or the codebase. The bash script uses well-established git plumbing commands, the null-delimiter handling is correct, the associative-array membership check is idiomatic, and fetch-depth=0 is properly set so the base SHA is always resolvable. The verify gate wiring follows the same pattern as every other job in the workflow. Files Needing Attention: config/scripts/check-root-directory-entries.test.mjs — two pre-existing test coverage gaps noted in earlier review threads remain open, but they carry no runtime risk.
|
| Filename | Overview |
|---|---|
| .github/scripts/check-root-directory-entries.sh | New guard script; correctly uses null-delimited git ls-tree, declare -A membership check, and GitHub Actions annotation format. Logic is sound and handles edge cases like special characters in filenames. |
| .github/workflows/pr.yml | Adds root_directory_guard job with fetch-depth=0 (required for base SHA resolution) and wires it into the verify aggregate gate correctly alongside all existing jobs. |
| config/scripts/check-root-directory-entries.test.mjs | New vitest tests covering nested addition (pass), root file (fail), root directory (fail), and workflow wiring. Step-index assertion on steps[0] is brittle (flagged in prior review thread); no deletion-allowed test case (also noted previously). |
| config/scripts/pr-workflow-parallelism.test.mjs | Adds root_directory_guard to the expected verify.needs list to keep the parallelism snapshot test accurate. |
Reviews (2): Last reviewed commit: "fix: clear existing type-aware lint warn..." | Re-trigger Greptile
| ) | ||
|
|
||
| expect(guardJob.name).toBe('root directory guard') | ||
| expect(guardJob.steps[0].with['fetch-depth']).toBe(0) |
There was a problem hiding this comment.
guardJob.steps[0] hardcodes the position of the checkout step. If any step is ever prepended before it (e.g., an actions/configure-pages or a caching step), this assertion silently tests the wrong step and can pass while the actual checkout step loses the fetch-depth guarantee. The guardStep lookup already shows the right pattern — use .find() with a name match instead.
| describe('root directory guard', () => { | ||
| it('allows additions inside an existing top-level directory', () => { | ||
| const fixture = makeFixture() | ||
| const head = commitFiles(fixture.root, [['config/new.txt', 'nested\n']]) | ||
|
|
||
| const result = runGuard({ ...fixture, head }) | ||
|
|
||
| expect(result.status).toBe(0) | ||
| expect(result.stdout).toContain('no new root-level files or folders') | ||
| }) | ||
|
|
||
| it('rejects a new root-level file with the landing-page message', () => { | ||
| const fixture = makeFixture() | ||
| const head = commitFiles(fixture.root, [['new-root.md', 'too prominent\n']]) | ||
|
|
||
| const result = runGuard({ ...fixture, head }) | ||
| const output = `${result.stdout}\n${result.stderr}` | ||
|
|
||
| expect(result.status).toBe(1) | ||
| expect(output).toContain('bloat the GitHub landing page') | ||
| expect(output).toContain('new-root.md') | ||
| }) | ||
|
|
||
| it('rejects a new top-level directory', () => { | ||
| const fixture = makeFixture() | ||
| const head = commitFiles(fixture.root, [['new-folder/file.txt', 'too prominent\n']]) | ||
|
|
||
| const result = runGuard({ ...fixture, head }) | ||
| const output = `${result.stdout}\n${result.stderr}` | ||
|
|
||
| expect(result.status).toBe(1) | ||
| expect(output).toContain('new-folder') | ||
| }) |
There was a problem hiding this comment.
No test for entry deletion being allowed
The three test cases cover adding a nested file (pass), adding a root file (fail), and adding a root directory (fail). There is no test confirming that removing a root-level entry does not trigger a failure. If a future maintainer accidentally inverts the comparison logic, deletion-only PRs would start failing the guard with no existing test to catch the regression. A brief fixture that removes the base config tree and expects exit code 0 would close this gap.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdded a Bash guard that compares root-level entries between two Git revisions and rejects new files or directories. Added a pull request workflow job to run the guard and made the aggregate verification job require its result. Added tests for valid and invalid repository changes, diagnostics, exit statuses, temporary repository cleanup, and workflow wiring. Updated benchmark formatting and string conversion in Windows update tests. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
thanks for reporting. looking into it |
* ci: guard repository root additions * fix: clear existing type-aware lint warnings
Summary
verifygate and cover allowed/rejected cases with fixtures.Testing
pnpm exec vitest run --config config/vitest.config.ts config/scripts/check-root-directory-entries.test.mjs config/scripts/pr-workflow-parallelism.test.mjs config/scripts/pr-workflow-lint-parity.test.mjs config/scripts/pr-e2e-gate-contract.test.mjs(23 passed)pnpm typecheckbash -n .github/scripts/check-root-directory-entries.shgit diff --check