mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:00:43 +00:00
ci: exclude app PRs from active limit
This commit is contained in:
19
.github/workflows/labeler.yml
vendored
19
.github/workflows/labeler.yml
vendored
@@ -296,6 +296,25 @@ jobs:
|
||||
.filter((name) => typeof name === "string"),
|
||||
);
|
||||
|
||||
if (pullRequest.user?.type === "Bot" || /\[bot\]$/i.test(authorLogin) || authorLogin.startsWith("app/")) {
|
||||
if (labelNames.has(activePrLimitLabel)) {
|
||||
try {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: pullRequest.number,
|
||||
name: activePrLimitLabel,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error?.status !== 404) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
core.info(`Skipping active PR limit for GitHub App author ${authorLogin}.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (labelNames.has(activePrLimitOverrideLabel)) {
|
||||
if (labelNames.has(activePrLimitLabel)) {
|
||||
try {
|
||||
|
||||
@@ -728,10 +728,17 @@ async function applyPullRequestCandidateLabels(github, context, core, pullReques
|
||||
);
|
||||
}
|
||||
|
||||
function isAutomationUser(user, fallbackLogin = "") {
|
||||
const login = user?.login ?? fallbackLogin;
|
||||
return user?.type === "Bot" || /\[bot\]$/i.test(login) || login.startsWith("app/");
|
||||
}
|
||||
|
||||
function isAutomationActor(context) {
|
||||
const sender = context.payload.sender;
|
||||
const login = sender?.login ?? context.actor ?? "";
|
||||
return sender?.type === "Bot" || /\[bot\]$/i.test(login);
|
||||
return isAutomationUser(context.payload.sender, context.actor ?? "");
|
||||
}
|
||||
|
||||
function isGitHubAppPullRequestAuthor(pullRequest) {
|
||||
return isAutomationUser(pullRequest.user);
|
||||
}
|
||||
|
||||
function candidateActionRuleForLabelSet(labelSet, preferredLabel = "") {
|
||||
@@ -975,6 +982,11 @@ export async function runBarnacleAutoResponse({ github, context, core = console
|
||||
return;
|
||||
}
|
||||
|
||||
if (isGitHubAppPullRequestAuthor(pullRequest)) {
|
||||
await removeLabels(github, context, pullRequest.number, [activePrLimitLabel], labelSet);
|
||||
core.info(`Skipping active PR limit for GitHub App-authored PR #${pullRequest.number}.`);
|
||||
}
|
||||
|
||||
await applyPullRequestCandidateLabels(github, context, core, pullRequest, labelSet);
|
||||
|
||||
if (labelSet.has(dirtyLabel)) {
|
||||
@@ -1061,7 +1073,10 @@ export async function runBarnacleAutoResponse({ github, context, core = console
|
||||
if (pullRequest && labelSet.has(activePrLimitOverrideLabel)) {
|
||||
labelSet.delete(activePrLimitLabel);
|
||||
}
|
||||
if (pullRequest && isAutomationPullRequest(pullRequest)) {
|
||||
if (
|
||||
pullRequest &&
|
||||
(isAutomationPullRequest(pullRequest) || isGitHubAppPullRequestAuthor(pullRequest))
|
||||
) {
|
||||
await removeLabels(github, context, pullRequest.number, [activePrLimitLabel], labelSet);
|
||||
}
|
||||
|
||||
|
||||
@@ -492,6 +492,30 @@ describe("barnacle-auto-response", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("removes stale PR-limit labels from GitHub App-authored PRs", async () => {
|
||||
const { calls, github } = barnacleGithub([file("README.md")]);
|
||||
|
||||
await runBarnacleAutoResponse({
|
||||
github,
|
||||
context: barnacleContext(
|
||||
{
|
||||
user: {
|
||||
login: "renovate[bot]",
|
||||
type: "Bot",
|
||||
},
|
||||
},
|
||||
["r: too-many-prs"],
|
||||
),
|
||||
core: {
|
||||
info: () => undefined,
|
||||
},
|
||||
});
|
||||
|
||||
expect(calls.removeLabel).toContainEqual(expect.objectContaining({ name: "r: too-many-prs" }));
|
||||
expect(calls.createComment).toEqual([]);
|
||||
expect(calls.update).toEqual([]);
|
||||
});
|
||||
|
||||
it("still adds candidate labels to broad contributor PRs", async () => {
|
||||
const { calls, github } = barnacleGithub([
|
||||
file("ui/src/app.ts"),
|
||||
|
||||
Reference in New Issue
Block a user