-
Notifications
You must be signed in to change notification settings - Fork 299
feat: add PR review status evaluator (all 3 phases) #2503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
exploreriii
merged 18 commits into
hiero-ledger:main
from
phillip-nyinomujuni:feat/pr-review-status-evaluator
Aug 13, 2026
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
56061d2
feat: add review stage model and reviewer-type constants
phillip-nyinomujuni bf76661
feat: add PR review status evaluator (all 3 phases)
phillip-nyinomujuni 59bdf47
fix: address CodeRabbit review feedback
phillip-nyinomujuni 4df6b7e
test: verify multi-page pagination in getPRLabels and getDetailedReviews
phillip-nyinomujuni 34095e2
Address review: drop DRY_RUN, use custom runner, verify roles via doc…
phillip-nyinomujuni 850333d
Update MAINTAINERS.md and docs/team.md to match governance/config.yaml
phillip-nyinomujuni 3dd6135
Address CodeRabbit: surface roster-read failures explicitly instead o…
phillip-nyinomujuni 86fe940
Move .coveragerc into tests/
phillip-nyinomujuni 4977ac5
Address review: pass teamRoles into computeStatus, fix docs/team.md n…
phillip-nyinomujuni 624afeb
Revert accidental move of .coveragerc into tests/ - workflow expects …
phillip-nyinomujuni f2ae958
feat/pr-review-status-evaluator
phillip-nyinomujuni 9716938
Merge branch 'main' into feat/pr-review-status-evaluator
phillip-nyinomujuni 3639804
fix: don't fail the workflow when the evaluator isn't on the base ref…
phillip-nyinomujuni 4613f5c
chore: add codeowner protection to team
exploreriii a01454c
chore: remove hardcoding
exploreriii 317ef96
chore: add more tests and narrow guard
exploreriii ee29daf
fix: paths
exploreriii 9c94b18
Merge branch 'main' into feat/pr-review-status-evaluator
exploreriii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
499 changes: 499 additions & 0 deletions
499
.github/scripts/__tests__/jest/review-status-evaluator.test.js
Large diffs are not rendered by default.
Oops, something went wrong.
223 changes: 223 additions & 0 deletions
223
.github/scripts/__tests__/jest/shared-review-stages.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,223 @@ | ||
| // __tests__/jest/shared-review-stages.test.js | ||
| // | ||
| // Run from .github/scripts: | ||
| // npm run test:js -- shared-review-stages.test.js | ||
|
|
||
| const REVIEW_STAGE_ENV_KEYS = [ | ||
| 'STAGE_AWAITING_REVIEW', | ||
| 'STAGE_CHANGES_REQUESTED', | ||
| 'STAGE_APPROVED', | ||
| 'STAGE_AWAITING_TRIAGE', | ||
| 'REVIEWER_TYPE_TRIAGE', | ||
| 'REVIEWER_TYPE_COMMITTER', | ||
| 'REVIEWER_TYPE_MAINTAINER', | ||
| ]; | ||
|
|
||
| const LABEL_ENV_KEYS = [ | ||
| 'GOOD_FIRST_ISSUE_LABEL', | ||
| 'GOOD_FIRST_ISSUE_CANDIDATE_LABEL', | ||
| 'BEGINNER_LABEL', | ||
| 'INTERMEDIATE_LABEL', | ||
| 'ADVANCED_LABEL', | ||
| ]; | ||
|
|
||
| const ALL_ENV_KEYS = [...REVIEW_STAGE_ENV_KEYS, ...LABEL_ENV_KEYS]; | ||
|
|
||
| // Snapshot whatever the environment actually had (which may be nothing, or | ||
| // may be real values set by the CI runner / a preceding test file sharing | ||
| // the same Jest worker) so it can be restored exactly, rather than always | ||
| // deleting the keys and leaving process.env permanently stripped of values | ||
| // that existed before this file ran. | ||
| function snapshotEnv(keys) { | ||
| const snapshot = {}; | ||
| for (const key of keys) { | ||
| snapshot[key] = process.env[key]; | ||
| } | ||
| return snapshot; | ||
| } | ||
|
|
||
| function restoreEnv(snapshot) { | ||
| for (const [key, value] of Object.entries(snapshot)) { | ||
| if (value === undefined) { | ||
| delete process.env[key]; | ||
| } else { | ||
| process.env[key] = value; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function clearEnv(keys) { | ||
| for (const key of keys) { | ||
| delete process.env[key]; | ||
| } | ||
| } | ||
|
|
||
| function freshRequire() { | ||
| jest.resetModules(); | ||
| return require('../../shared/review-stages'); | ||
| } | ||
|
|
||
| describe('review-stages.js — stage constants', () => { | ||
| let stages; | ||
| let envSnapshot; | ||
|
|
||
| beforeEach(() => { | ||
| envSnapshot = snapshotEnv(ALL_ENV_KEYS); | ||
| clearEnv(ALL_ENV_KEYS); | ||
| stages = freshRequire(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| restoreEnv(envSnapshot); | ||
| }); | ||
|
|
||
| test('exports all four stage constants, non-empty', () => { | ||
| expect(stages.AWAITING_REVIEW).toBeTruthy(); | ||
| expect(stages.CHANGES_REQUESTED).toBeTruthy(); | ||
| expect(stages.APPROVED).toBeTruthy(); | ||
| expect(stages.AWAITING_TRIAGE).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('exports correct default stage values', () => { | ||
| expect(stages.AWAITING_REVIEW).toBe('awaiting_review'); | ||
| expect(stages.CHANGES_REQUESTED).toBe('changes_requested'); | ||
| expect(stages.APPROVED).toBe('approved'); | ||
| expect(stages.AWAITING_TRIAGE).toBe('awaiting_triage'); | ||
| }); | ||
|
|
||
| test('exports REVIEW_STAGES array containing all five stages', () => { | ||
| expect(stages.REVIEW_STAGES).toHaveLength(5); | ||
| expect(stages.REVIEW_STAGES).toContain(stages.AWAITING_REVIEW); | ||
| expect(stages.REVIEW_STAGES).toContain(stages.CHANGES_REQUESTED); | ||
| expect(stages.REVIEW_STAGES).toContain(stages.APPROVED); | ||
| expect(stages.REVIEW_STAGES).toContain(stages.AWAITING_TRIAGE); | ||
| expect(stages.REVIEW_STAGES).toContain(stages.ROSTER_UNAVAILABLE); | ||
| }); | ||
| }); | ||
|
|
||
| describe('review-stages.js — reviewer type constants', () => { | ||
| let stages; | ||
| let envSnapshot; | ||
|
|
||
| beforeEach(() => { | ||
| envSnapshot = snapshotEnv(ALL_ENV_KEYS); | ||
| clearEnv(ALL_ENV_KEYS); | ||
| stages = freshRequire(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| restoreEnv(envSnapshot); | ||
| }); | ||
|
|
||
| test('exports all three reviewer-type constants, non-empty', () => { | ||
| expect(stages.TRIAGE).toBeTruthy(); | ||
| expect(stages.COMMITTER).toBeTruthy(); | ||
| expect(stages.MAINTAINER).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('exports correct default reviewer-type values', () => { | ||
| expect(stages.TRIAGE).toBe('triage'); | ||
| expect(stages.COMMITTER).toBe('committer'); | ||
| expect(stages.MAINTAINER).toBe('maintainer'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('review-stages.js — getExpectedReviewers', () => { | ||
| let stages; | ||
| let envSnapshot; | ||
|
|
||
| beforeEach(() => { | ||
| envSnapshot = snapshotEnv(ALL_ENV_KEYS); | ||
| clearEnv(ALL_ENV_KEYS); | ||
| stages = freshRequire(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| restoreEnv(envSnapshot); | ||
| }); | ||
|
|
||
| test('GFI label maps to [TRIAGE, COMMITTER]', () => { | ||
| expect(stages.getExpectedReviewers(['Good First Issue'])) | ||
| .toEqual([stages.TRIAGE, stages.COMMITTER]); | ||
| }); | ||
|
|
||
| test('beginner label maps to [TRIAGE, COMMITTER]', () => { | ||
| expect(stages.getExpectedReviewers(['skill: beginner'])) | ||
| .toEqual([stages.TRIAGE, stages.COMMITTER]); | ||
| }); | ||
|
|
||
| test('intermediate label maps to [COMMITTER, MAINTAINER]', () => { | ||
| expect(stages.getExpectedReviewers(['skill: intermediate'])) | ||
| .toEqual([stages.COMMITTER, stages.MAINTAINER]); | ||
| }); | ||
|
|
||
| test('advanced label maps to [COMMITTER, MAINTAINER]', () => { | ||
| expect(stages.getExpectedReviewers(['skill: advanced'])) | ||
| .toEqual([stages.COMMITTER, stages.MAINTAINER]); | ||
| }); | ||
|
|
||
| test('PR with no skill labels defaults to [COMMITTER, MAINTAINER]', () => { | ||
| expect(stages.getExpectedReviewers([])) | ||
| .toEqual([stages.COMMITTER, stages.MAINTAINER]); | ||
| }); | ||
|
|
||
| test('PR with unrelated non-skill labels defaults to [COMMITTER, MAINTAINER]', () => { | ||
| expect(stages.getExpectedReviewers(['bug', 'documentation'])) | ||
| .toEqual([stages.COMMITTER, stages.MAINTAINER]); | ||
| }); | ||
|
|
||
| test('PR with both beginner and advanced labels uses the higher difficulty', () => { | ||
| expect(stages.getExpectedReviewers(['skill: beginner', 'skill: advanced'])) | ||
| .toEqual([stages.COMMITTER, stages.MAINTAINER]); | ||
| }); | ||
|
|
||
| test('PR with both GFI and intermediate labels uses the higher difficulty', () => { | ||
| expect(stages.getExpectedReviewers(['Good First Issue', 'skill: intermediate'])) | ||
| .toEqual([stages.COMMITTER, stages.MAINTAINER]); | ||
| }); | ||
|
|
||
| test('handles undefined labels gracefully', () => { | ||
| expect(stages.getExpectedReviewers(undefined)) | ||
| .toEqual([stages.COMMITTER, stages.MAINTAINER]); | ||
| }); | ||
| }); | ||
|
|
||
| describe('review-stages.js — environment variable overrides', () => { | ||
| let envSnapshot; | ||
|
|
||
| beforeEach(() => { | ||
| envSnapshot = snapshotEnv(ALL_ENV_KEYS); | ||
| clearEnv(ALL_ENV_KEYS); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| restoreEnv(envSnapshot); | ||
| }); | ||
|
|
||
| test('overrides AWAITING_REVIEW from env', () => { | ||
| process.env.STAGE_AWAITING_REVIEW = 'custom: awaiting review'; | ||
|
|
||
| const stages = freshRequire(); | ||
|
|
||
| expect(stages.AWAITING_REVIEW).toBe('custom: awaiting review'); | ||
| expect(stages.REVIEW_STAGES).toContain('custom: awaiting review'); | ||
| }); | ||
|
|
||
| test('overrides TRIAGE reviewer type from env', () => { | ||
| process.env.REVIEWER_TYPE_TRIAGE = 'custom-triage'; | ||
|
|
||
| const stages = freshRequire(); | ||
|
|
||
| expect(stages.TRIAGE).toBe('custom-triage'); | ||
| expect(stages.getExpectedReviewers(['Good First Issue'])) | ||
| .toContain('custom-triage'); | ||
| }); | ||
|
|
||
| test('trims whitespace from env values', () => { | ||
| process.env.STAGE_APPROVED = ' padded stage '; | ||
|
|
||
| const stages = freshRequire(); | ||
|
|
||
| expect(stages.APPROVED).toBe('padded stage'); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.