merge-steward 0.32.0 → 0.32.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/github/pr-client.js +11 -12
- package/dist/github-auth.js +4 -2
- package/dist/service-queue.js +7 -1
- package/package.json +1 -1
package/dist/github/pr-client.js
CHANGED
|
@@ -132,19 +132,15 @@ export class GitHubPRClient {
|
|
|
132
132
|
}
|
|
133
133
|
async listLabels(prNumber) {
|
|
134
134
|
const result = await exec("gh", [
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
"--
|
|
135
|
+
"api",
|
|
136
|
+
`repos/${this.repoFullName}/issues/${prNumber}/labels`,
|
|
137
|
+
"--paginate",
|
|
138
|
+
"--jq", ".[].name",
|
|
138
139
|
], { allowNonZero: true, githubRepoFullName: this.repoFullName });
|
|
139
|
-
if (result.exitCode !== 0)
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
const data = JSON.parse(result.stdout);
|
|
143
|
-
return data.labels.map((l) => l.name);
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
return [];
|
|
140
|
+
if (result.exitCode !== 0) {
|
|
141
|
+
throw new Error(`Failed to list labels for PR #${prNumber}: ${result.stderr.trim() || `exit ${result.exitCode}`}`);
|
|
147
142
|
}
|
|
143
|
+
return result.stdout.split(/\r?\n/).map((label) => label.trim()).filter(Boolean);
|
|
148
144
|
}
|
|
149
145
|
async setLabels(prNumber, opts) {
|
|
150
146
|
const args = ["pr", "edit", String(prNumber), "--repo", this.repoFullName];
|
|
@@ -155,7 +151,10 @@ export class GitHubPRClient {
|
|
|
155
151
|
// Nothing to change beyond the base args — skip the call.
|
|
156
152
|
if (args.length === 5)
|
|
157
153
|
return;
|
|
158
|
-
await exec("gh", args, { allowNonZero: true, githubRepoFullName: this.repoFullName });
|
|
154
|
+
const result = await exec("gh", args, { allowNonZero: true, githubRepoFullName: this.repoFullName });
|
|
155
|
+
if (result.exitCode !== 0) {
|
|
156
|
+
throw new Error(`Failed to edit labels for PR #${prNumber}: ${result.stderr.trim() || `exit ${result.exitCode}`}`);
|
|
157
|
+
}
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
/** Map GitHub REST API check-run status/conclusion to our union. */
|
package/dist/github-auth.js
CHANGED
|
@@ -5,12 +5,14 @@ const TOKEN_REFRESH_MS = 30 * 60_000;
|
|
|
5
5
|
const TOKEN_EXPIRY_MARGIN_MS = 5 * 60_000;
|
|
6
6
|
const RECENT_AUTH_FAILURE_WINDOW_MS = 15 * 60_000;
|
|
7
7
|
const MAX_AUTH_FAILURES_TO_KEEP = 50;
|
|
8
|
+
const GITHUB_APP_JWT_MAX_LIFETIME_SECONDS = 10 * 60;
|
|
9
|
+
const GITHUB_APP_JWT_CLOCK_SKEW_SECONDS = 60;
|
|
8
10
|
export function generateJwt(appId, privateKey) {
|
|
9
11
|
const now = Math.floor(Date.now() / 1000);
|
|
10
12
|
const header = Buffer.from(JSON.stringify({ alg: "RS256", typ: "JWT" })).toString("base64url");
|
|
11
13
|
const payload = Buffer.from(JSON.stringify({
|
|
12
|
-
iat: now -
|
|
13
|
-
exp: now +
|
|
14
|
+
iat: now - GITHUB_APP_JWT_CLOCK_SKEW_SECONDS,
|
|
15
|
+
exp: now + GITHUB_APP_JWT_MAX_LIFETIME_SECONDS - GITHUB_APP_JWT_CLOCK_SKEW_SECONDS,
|
|
14
16
|
iss: appId,
|
|
15
17
|
})).toString("base64url");
|
|
16
18
|
const signer = createSign("RSA-SHA256");
|
package/dist/service-queue.js
CHANGED
|
@@ -146,7 +146,13 @@ export class MergeStewardQueueCommands {
|
|
|
146
146
|
this.logger.debug({ prNumber, reviewDecision: status.reviewDecision }, "PR review gate is not satisfied, skipping admission");
|
|
147
147
|
return false;
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
let labels = [];
|
|
150
|
+
try {
|
|
151
|
+
labels = await this.github.listLabels(prNumber);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
this.logger.debug({ prNumber, err: error }, "Could not read labels for priority detection; continuing without priority label");
|
|
155
|
+
}
|
|
150
156
|
const priority = labels.includes(this.config.priorityQueueLabel) ? 1 : 0;
|
|
151
157
|
const checks = await this.github.listChecks(prNumber);
|
|
152
158
|
const requiredChecks = this.policy.getRequiredChecks();
|