@sentry/junior-github 0.275.0 → 0.277.0

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.
@@ -95,11 +95,11 @@ function gitHubDeploymentSourceSubscribable(input) {
95
95
  ...gitHubDeploymentSourceResource(input),
96
96
  match: {
97
97
  repo: gitHubRepoDataSchema.parse(input.repo),
98
- commitSha: gitHubCommitShaDataSchema.parse(input.commitSha),
98
+ commit_sha: gitHubCommitShaDataSchema.parse(input.commitSha),
99
99
  ...environment ? { environment } : void 0
100
100
  },
101
- suggestedEvents: GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
102
- supportedEvents: [...GITHUB_DEPLOYMENT_EVENTS],
101
+ suggested_events: GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
102
+ supported_events: [...GITHUB_DEPLOYMENT_EVENTS],
103
103
  type: "deployment_source"
104
104
  };
105
105
  }
@@ -173,8 +173,8 @@ function gitHubIssueSubscribable(input) {
173
173
  repo: gitHubRepoDataSchema.parse(input.repo),
174
174
  issue: input.number
175
175
  },
176
- suggestedEvents: GITHUB_ISSUE_SUGGESTED_EVENTS,
177
- supportedEvents: GITHUB_ISSUE_EVENTS,
176
+ suggested_events: GITHUB_ISSUE_SUGGESTED_EVENTS,
177
+ supported_events: GITHUB_ISSUE_EVENTS,
178
178
  type: "issue"
179
179
  };
180
180
  }
@@ -204,9 +204,9 @@ var GITHUB_PULL_REQUEST_EVENT_GUIDANCE = {
204
204
  // An approval with a body also arrives as review.commented in the same
205
205
  // Turn, so this guidance must not tell the agent to hold off on that body.
206
206
  "pull_request.review.approved": "When the approval includes actionable feedback, address it like any other review feedback.",
207
- "pull_request.comment.created": 'After acting on actionable feedback, call github_updatePullRequestFeedback with the exact repo, commentId, and commentKind from Verified details, and status "addressed" or "declined".',
208
- "pull_request.review_comment.created": 'After acting on actionable feedback, call github_updatePullRequestFeedback with the exact repo, commentId, and commentKind from Verified details, and status "addressed" or "declined". Then resolve the thread with github_resolvePullRequestReviewThread.',
209
- "pull_request.merge_conflict": `${STACK_CHECK} If it is, run \`gh stack checkout NUMBER\`, then ${STACK_CONFLICT_STEPS} If it is not, fetch baseBranch from Verified details and merge it into the pull request branch. Do not rebase. Resolve each conflict so that both the pull request change and the base branch change stay intact. Run the checks again, push, and confirm that the pull request can merge. Report the files that had conflicts.`
207
+ "pull_request.comment.created": 'After acting on actionable feedback, call github_updatePullRequestFeedback with the exact repo, comment_id, and comment_kind from Verified details, and status "addressed" or "declined".',
208
+ "pull_request.review_comment.created": 'After acting on actionable feedback, call github_updatePullRequestFeedback with the exact repo, comment_id, and comment_kind from Verified details, and status "addressed" or "declined". Then resolve the thread with github_resolvePullRequestReviewThread.',
209
+ "pull_request.merge_conflict": `${STACK_CHECK} If it is, run \`gh stack checkout NUMBER\`, then ${STACK_CONFLICT_STEPS} If it is not, fetch base_branch from Verified details and merge it into the pull request branch. Do not rebase. Resolve each conflict so that both the pull request change and the base branch change stay intact. Run the checks again, push, and confirm that the pull request can merge. Report the files that had conflicts.`
210
210
  };
211
211
  function gitHubPullRequestEventGuidance(guidance) {
212
212
  const merged = { ...GITHUB_PULL_REQUEST_EVENT_GUIDANCE };
@@ -329,10 +329,10 @@ function gitHubPullRequestSubscribable(input) {
329
329
  ...gitHubPullRequestResource(input),
330
330
  match: {
331
331
  repo: gitHubRepoDataSchema.parse(input.repo),
332
- pullRequest: input.number
332
+ pull_request: input.number
333
333
  },
334
- ...suggestedEvents.length > 0 ? { suggestedEvents: [...suggestedEvents] } : void 0,
335
- supportedEvents: [...GITHUB_PULL_REQUEST_EVENTS],
334
+ ...suggestedEvents.length > 0 ? { suggested_events: [...suggestedEvents] } : void 0,
335
+ supported_events: [...GITHUB_PULL_REQUEST_EVENTS],
336
336
  type: "pull_request"
337
337
  };
338
338
  }
@@ -377,8 +377,8 @@ function gitHubReleaseSourceSubscribable(input) {
377
377
  repo: gitHubRepoDataSchema.parse(input.repo),
378
378
  ...tag ? { tag: gitHubReleaseTagDataSchema.parse(tag) } : void 0
379
379
  },
380
- suggestedEvents: GITHUB_RELEASE_SUGGESTED_EVENTS,
381
- supportedEvents: [...GITHUB_RELEASE_EVENTS],
380
+ suggested_events: GITHUB_RELEASE_SUGGESTED_EVENTS,
381
+ supported_events: [...GITHUB_RELEASE_EVENTS],
382
382
  type: "release_source"
383
383
  };
384
384
  }
@@ -411,8 +411,8 @@ function gitHubRepositorySubscribable(input) {
411
411
  return {
412
412
  ...gitHubRepositoryResource(input),
413
413
  match: { repo: gitHubRepoDataSchema.parse(input.repo) },
414
- suggestedEvents: [...GITHUB_REPOSITORY_SUGGESTED_EVENTS],
415
- supportedEvents: [...GITHUB_REPOSITORY_EVENTS],
414
+ suggested_events: [...GITHUB_REPOSITORY_SUGGESTED_EVENTS],
415
+ supported_events: [...GITHUB_REPOSITORY_EVENTS],
416
416
  type: "repository"
417
417
  };
418
418
  }
@@ -1237,7 +1237,9 @@ function buildCheckSuiteEvent(args) {
1237
1237
  const failingChecks = (args.failingChecks ?? []).slice(0, 12);
1238
1238
  const failingCount = failingChecks.length;
1239
1239
  const branchSuffix = args.headBranch ? ` on ${args.headBranch}` : "";
1240
- const trustedSummary = args.eventType === "pull_request.checks.failed" ? `${resource.label} checks failed${failingCount > 0 ? ` (${failingCount})` : ""}${shortSha ? ` for ${shortSha}` : ""}${branchSuffix}.` : `${resource.label} check suite recovered${shortSha ? ` for ${shortSha}` : ""}${branchSuffix}.`;
1240
+ const incidents = args.eventType === "pull_request.checks.failed" ? args.githubIncidents ?? [] : [];
1241
+ const incidentSuffix = incidents.length > 0 ? ` githubstatus.com lists ${incidents.length} open or recent GitHub incident${incidents.length === 1 ? "" : "s"}.` : "";
1242
+ const trustedSummary = args.eventType === "pull_request.checks.failed" ? `${resource.label} checks failed${failingCount > 0 ? ` (${failingCount})` : ""}${shortSha ? ` for ${shortSha}` : ""}${branchSuffix}.${incidentSuffix}` : `${resource.label} check suite recovered${shortSha ? ` for ${shortSha}` : ""}${branchSuffix}.`;
1241
1243
  const data = checkSuiteEventDataSchema.parse(
1242
1244
  definedValues({
1243
1245
  repo: args.repo,
@@ -1269,9 +1271,22 @@ function buildCheckSuiteEvent(args) {
1269
1271
  if (!name) return void 0;
1270
1272
  return check.htmlUrl ? `${name}: ${check.htmlUrl}` : name;
1271
1273
  }).filter((part) => part !== void 0) : [];
1272
- const untrustedText = untrustedParts.length > 0 ? [`Failed checks:`, ...untrustedParts.map((part) => `- ${part}`)].join(
1273
- "\n"
1274
- ) : void 0;
1274
+ const untrustedSections = [
1275
+ ...untrustedParts.length > 0 ? [
1276
+ [`Failed checks:`, ...untrustedParts.map((part) => `- ${part}`)].join(
1277
+ "\n"
1278
+ )
1279
+ ] : [],
1280
+ ...incidents.length > 0 ? [
1281
+ [
1282
+ "GitHub status incidents:",
1283
+ ...incidents.map(
1284
+ (incident) => `- ${oneLineLabel(incident.name, 160)} (${incident.status}; ${incident.components.join(", ") || "no components"}; started ${incident.startedAt}${incident.resolvedAt ? `, resolved ${incident.resolvedAt}` : ""}): ${incident.url}`
1285
+ )
1286
+ ].join("\n")
1287
+ ] : []
1288
+ ];
1289
+ const untrustedText = untrustedSections.length > 0 ? untrustedSections.join("\n\n") : void 0;
1275
1290
  return {
1276
1291
  eventKey: gitHubEventKey(
1277
1292
  args.deliveryId,
@@ -1329,6 +1344,7 @@ function normalizeCheckSuiteEvents(deliveryId, body, options) {
1329
1344
  deliveryId,
1330
1345
  eventType,
1331
1346
  failingChecks: eventType === "pull_request.checks.failed" ? options?.failingChecks : void 0,
1347
+ githubIncidents: eventType === "pull_request.checks.failed" ? options?.githubIncidents : void 0,
1332
1348
  headSha,
1333
1349
  latestCheckRunsCount: typeof suite.latest_check_runs_count === "number" ? suite.latest_check_runs_count : void 0,
1334
1350
  repo,
@@ -1490,6 +1506,16 @@ async function loadCheckSuiteFacts(args) {
1490
1506
  });
1491
1507
  }
1492
1508
  }
1509
+ if (target.loadFailingChecks && args.loadGitHubIncidents) {
1510
+ try {
1511
+ const incidents = await args.loadGitHubIncidents();
1512
+ if (incidents.length > 0) facts.githubIncidents = incidents;
1513
+ } catch (error) {
1514
+ args.log?.error("GitHub status load failed", {
1515
+ errorType: error instanceof Error ? error.name : "UnknownError"
1516
+ });
1517
+ }
1518
+ }
1493
1519
  if (target.loadPullRequestFacts) {
1494
1520
  try {
1495
1521
  const token = await issueInstallationToken({
@@ -0,0 +1,5 @@
1
+ /** Name the github.com page of one watched resource, when it has one. */
2
+ export declare function gitHubResourceUrl(input: {
3
+ identifier: string;
4
+ resourceType: string;
5
+ }): string | undefined;
@@ -0,0 +1,16 @@
1
+ import type { PluginCache } from "@sentry/junior-plugin-api";
2
+ /** One incident from githubstatus.com. */
3
+ export type GitHubStatusIncident = {
4
+ components: string[];
5
+ impact: string;
6
+ name: string;
7
+ resolvedAt?: string;
8
+ startedAt: string;
9
+ status: string;
10
+ url: string;
11
+ };
12
+ /**
13
+ * Read GitHub incidents that are open, or that were resolved within
14
+ * `withinMs`. Callers share one cached read of githubstatus.com.
15
+ */
16
+ export declare function loadGitHubStatusIncidents(cache: PluginCache, withinMs: number): Promise<GitHubStatusIncident[]>;