Skip to content
Merged
Show file tree
Hide file tree
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 Aug 2, 2026
bf76661
feat: add PR review status evaluator (all 3 phases)
phillip-nyinomujuni Aug 2, 2026
59bdf47
fix: address CodeRabbit review feedback
phillip-nyinomujuni Aug 3, 2026
4df6b7e
test: verify multi-page pagination in getPRLabels and getDetailedReviews
phillip-nyinomujuni Aug 3, 2026
34095e2
Address review: drop DRY_RUN, use custom runner, verify roles via doc…
phillip-nyinomujuni Aug 5, 2026
850333d
Update MAINTAINERS.md and docs/team.md to match governance/config.yaml
phillip-nyinomujuni Aug 5, 2026
3dd6135
Address CodeRabbit: surface roster-read failures explicitly instead o…
phillip-nyinomujuni Aug 5, 2026
86fe940
Move .coveragerc into tests/
phillip-nyinomujuni Aug 8, 2026
4977ac5
Address review: pass teamRoles into computeStatus, fix docs/team.md n…
phillip-nyinomujuni Aug 8, 2026
624afeb
Revert accidental move of .coveragerc into tests/ - workflow expects …
phillip-nyinomujuni Aug 8, 2026
f2ae958
feat/pr-review-status-evaluator
phillip-nyinomujuni Aug 10, 2026
9716938
Merge branch 'main' into feat/pr-review-status-evaluator
phillip-nyinomujuni Aug 10, 2026
3639804
fix: don't fail the workflow when the evaluator isn't on the base ref…
phillip-nyinomujuni Aug 11, 2026
4613f5c
chore: add codeowner protection to team
exploreriii Aug 13, 2026
a01454c
chore: remove hardcoding
exploreriii Aug 13, 2026
317ef96
chore: add more tests and narrow guard
exploreriii Aug 13, 2026
ee29daf
fix: paths
exploreriii Aug 13, 2026
9c94b18
Merge branch 'main' into feat/pr-review-status-evaluator
exploreriii Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
499 changes: 499 additions & 0 deletions .github/scripts/__tests__/jest/review-status-evaluator.test.js

Large diffs are not rendered by default.

223 changes: 223 additions & 0 deletions .github/scripts/__tests__/jest/shared-review-stages.test.js
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',
];
Comment thread
danielmarv marked this conversation as resolved.

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');
});
});
Loading
Loading