Respect manual contribution policy labels

This commit is contained in:
Gregory Schier
2026-07-03 10:52:44 -07:00
parent 0497a54928
commit 3f9baca85e
2 changed files with 22 additions and 15 deletions
+21 -14
View File
@@ -10,8 +10,7 @@ const REVIEWER_LOGIN = "gschier";
const LARGE_DIFF_CHANGED_FILES = 20; const LARGE_DIFF_CHANGED_FILES = 20;
const LARGE_DIFF_CHANGED_LINES = 800; const LARGE_DIFF_CHANGED_LINES = 800;
const SUMMARY_TITLE_MAX_LENGTH = 80; const SUMMARY_TITLE_MAX_LENGTH = 80;
const AUTOMATIC_PR_CREATED_AFTER = "2026-06-30T07:00:00.000Z"; const MIN_AUTOMATIC_PR_NUMBER = 494;
const AUTOMATIC_PR_CREATED_AFTER_LABEL = "June 30, 2026";
const LABELS = { const LABELS = {
inScope: { inScope: {
@@ -186,6 +185,18 @@ function analyzePullRequest(pr) {
}; };
} }
if (labelNames.has(LABELS.explicitPermission.name)) {
return {
blockers: [],
changedFiles,
desiredLabels: [LABELS.explicitPermission.name],
largeDiff,
status: "in_scope",
templateUsed,
totalChangedLines,
};
}
if (!templateUsed) { if (!templateUsed) {
blockers.push({ blockers.push({
label: LABELS.missingTemplate.name, label: LABELS.missingTemplate.name,
@@ -428,10 +439,6 @@ function summarizeResult({ pr, analysis, skipped, skipReason }) {
}; };
} }
function wasCreatedBefore(value, cutoff) {
return Date.parse(value) < Date.parse(cutoff);
}
async function isOfficialMaintainer({ github, owner, repo, pr }) { async function isOfficialMaintainer({ github, owner, repo, pr }) {
if (MAINTAINER_LOGINS.has(pr.user.login)) { if (MAINTAINER_LOGINS.has(pr.user.login)) {
return true; return true;
@@ -603,7 +610,7 @@ async function checkPullRequest({
repo, repo,
pullNumber, pullNumber,
dryRun, dryRun,
skipCreatedBefore, minimumAutomaticPullNumber,
}) { }) {
const response = await github.rest.pulls.get({ const response = await github.rest.pulls.get({
owner, owner,
@@ -614,11 +621,11 @@ async function checkPullRequest({
const issueNumber = pr.number; const issueNumber = pr.number;
if ( if (
skipCreatedBefore != null && minimumAutomaticPullNumber != null &&
wasCreatedBefore(pr.created_at, skipCreatedBefore) pr.number < minimumAutomaticPullNumber
) { ) {
core.notice( core.notice(
`Skipping contribution policy for PR #${pr.number} because it was created before ${AUTOMATIC_PR_CREATED_AFTER_LABEL}.`, `Skipping contribution policy for PR #${pr.number} because automatic checks start at PR #${minimumAutomaticPullNumber}.`,
); );
return { return {
blocked: false, blocked: false,
@@ -626,7 +633,7 @@ async function checkPullRequest({
summary: summarizeResult({ summary: summarizeResult({
pr, pr,
skipped: true, skipped: true,
skipReason: `created before ${AUTOMATIC_PR_CREATED_AFTER_LABEL}`, skipReason: `before automatic rollout PR #${minimumAutomaticPullNumber}`,
}), }),
skipped: true, skipped: true,
}; };
@@ -756,8 +763,8 @@ async function run({ github, context, core }) {
context.eventName === "workflow_dispatch" && context.eventName === "workflow_dispatch" &&
dryRunInput !== false && dryRunInput !== false &&
dryRunInput !== "false"; dryRunInput !== "false";
const skipCreatedBefore = const minimumAutomaticPullNumber =
payloadPr == null ? null : AUTOMATIC_PR_CREATED_AFTER; payloadPr == null ? null : MIN_AUTOMATIC_PR_NUMBER;
let pullNumbers; let pullNumbers;
if (payloadPr != null) { if (payloadPr != null) {
@@ -795,7 +802,7 @@ async function run({ github, context, core }) {
repo, repo,
pullNumber: pr.number, pullNumber: pr.number,
dryRun, dryRun,
skipCreatedBefore, minimumAutomaticPullNumber,
}), }),
); );
} }
+1 -1
View File
@@ -36,7 +36,7 @@ jobs:
- name: Checkout policy script - name: Checkout policy script
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ github.event.pull_request.base.sha || github.ref }} ref: main
fetch-depth: 1 fetch-depth: 1
- name: Check contribution policy - name: Check contribution policy