Skip to content

Commit

Permalink
feat: add api-review/skip-delay ⏰ label (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsananderson authored Sep 23, 2024
1 parent 525f06e commit 3bc1115
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Members of the API Working Group must indicate their approval by leaving a comme

If a PR has passed its minimum open time and has the requisite number of approvals with no outstanding requests for changes, the bot will then switch `api-review/requested 🗳` to `api-review/approved ✅`, and the PR is free to be merged. If outstanding change requests persist, then the group will initiate consensus-seeking procedures and ultimately choose to approve or decline the PR. If the decision is made to decline, the API WG chair will then comment on the PR with `API Declined` and the bot will update `api-review/requested 🗳` to `api-review/declined ❌`.

For PRs that need to land faster than the minimum open time (e.g. to respond to OS or Chromium updates), the minimum open time can be bypassed by adding a `api-review/skip-delay ⏰` label to the PR. This label may be added to a PR if at least two members of the API WG representing two different employers approve fast-tracking the PR.

## Deprecation Review

The bot controls the deprecation review lifecycle on behalf of the [Releases Working Group](https://github.com/electron/governance/tree/main/wg-releases).
Expand Down
12 changes: 12 additions & 0 deletions spec/api-review-state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ describe('api review', () => {
expect(readyDate).toEqual(expectedDate);
});

it('correctly returns PR ready date when skip-timeout label is found', async () => {
const payload = loadFixture('api-review-state/pull_request.api-skip-delay_label.json');

// Set created_at to yesterday.
payload.created_at = new Date(+new Date() - 1000 * 60 * 60 * 24 * 2);

const expectedDate = payload.created_at.toISOString().split('T')[0];
const readyDate = getPRReadyDate(payload);

expect(readyDate).toEqual(expectedDate);
});

it('should reset the check when PR does not have an API review label on a base PR', async () => {
let { pull_request } = loadFixture('api-review-state/pull_request.no_review_label.json');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"url": "https://api.github.com/repos/electron/electron/pulls/26876",
"id": 534054584,
"node_id": "MDExOlB1bGxSZXF1ZXN0NTM0MDU0NTg0",
"issue_url": "https://api.github.com/repos/electron/electron/issues/26876",
"number": 26876,
"state": "closed",
"locked": false,
"title": "build: fix JS linting",
"user": {
"login": "MarshallOfSound"
},
"labels": [
{
"id": 1034512799,
"node_id": "MDU6TGFiZWwxMDM0NTEyNzk5",
"url": "https://api.github.com/repos/electron/electron/labels/api-review/skip-delay%20%E2%8F%B0",
"name": "api-review/skip-delay ⏰",
"color": "6ac2dd",
"default": false,
"description": "skip the default API approval delay"
}
],
"body": "* Ensure --fix output is actually written to disk\r\n* Cache bust on lint.js file changes\r\n* Ensure CI does not use the linting cache\r\n\r\nNotes: no-notes",
"created_at": "2020-12-08T01:24:55Z",
"updated_at": "2020-12-10T18:57:11Z",
"closed_at": "2020-12-10T18:57:07Z",
"merged_at": "2020-12-10T18:57:07Z",
"merge_commit_sha": "51db2a6b34792c99a9a685bdfbfe87a7343631b9",
"assignee": null,
"milestone": null,
"draft": false,
"commits_url": "https://api.github.com/repos/electron/electron/pulls/26876/commits",
"review_comments_url": "https://api.github.com/repos/electron/electron/pulls/26876/comments",
"review_comment_url": "https://api.github.com/repos/electron/electron/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/electron/electron/issues/26876/comments",
"statuses_url": "https://api.github.com/repos/electron/electron/statuses/c6b1b7168ab850a47f856c4a30f7a441bede1117",
"head": {
"label": "electron:fix-lint-js",
"ref": "fix-lint-js",
"sha": "c6b1b7168ab850a47f856c4a30f7a441bede1117",
"user": {
"login": "electron",
"id": 13409222,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjEzNDA5MjIy",
"avatar_url": "https://avatars.githubusercontent.com/u/13409222?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/electron"
},
"repo": {
"id": 9384267,
"node_id": "MDEwOlJlcG9zaXRvcnk5Mzg0MjY3",
"name": "electron",
"full_name": "electron/electron",
"private": false,
"owner": {
"login": "electron",
"id": 13409222,
"url": "https://api.github.com/users/electron"
},
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
}
}
}
}
8 changes: 5 additions & 3 deletions src/api-review-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Context, Probot } from 'probot';
import { log } from './utils/log-util';
import {
API_REVIEW_CHECK_NAME,
API_SKIP_DELAY_LABEL,
API_WORKING_GROUP,
EXCLUDE_LABELS,
MINIMUM_MINOR_OPEN_TIME,
Expand All @@ -10,7 +11,6 @@ import {
OWNER,
REPO,
REVIEW_LABELS,
REVIEW_STATUS,
SEMVER_LABELS,
} from './constants';
import { CheckRunStatus, LogLevel } from './enums';
Expand Down Expand Up @@ -44,9 +44,11 @@ export const isSemverMajorMinorLabel = (label: string) =>
*/
export const getPRReadyDate = (pr: PullRequest) => {
let readyTime = new Date(pr.created_at).getTime();
const isMajorMinor = pr.labels.some((l: any) => isSemverMajorMinorLabel(l.name));

readyTime += isMajorMinor ? MINIMUM_MINOR_OPEN_TIME : MINIMUM_PATCH_OPEN_TIME;
if (!pr.labels.some((l: any) => l.name === API_SKIP_DELAY_LABEL)) {
const isMajorMinor = pr.labels.some((l: any) => isSemverMajorMinorLabel(l.name));
readyTime += isMajorMinor ? MINIMUM_MINOR_OPEN_TIME : MINIMUM_PATCH_OPEN_TIME;
}

return new Date(readyTime).toISOString().split('T')[0];
};
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const REVIEW_LABELS = {
APPROVED: 'api-review/approved ✅',
DECLINED: 'api-review/declined ❌',
};
export const API_SKIP_DELAY_LABEL = 'api-review/skip-delay ⏰';

export const DEPRECATION_REVIEW_LABELS = {
REQUESTED: 'deprecation-review/requested 📝',
Expand Down

0 comments on commit 3bc1115

Please sign in to comment.