@sentry/junior-github 0.190.0 → 0.191.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.
|
@@ -101,6 +101,10 @@ var GITHUB_PULL_REQUEST_MATCH_FIELDS = resourceEventMatchFieldsSchema.parse({
|
|
|
101
101
|
kind: "string",
|
|
102
102
|
description: "pull request author login"
|
|
103
103
|
},
|
|
104
|
+
headBranch: {
|
|
105
|
+
kind: "string",
|
|
106
|
+
description: "head branch name from the webhook"
|
|
107
|
+
},
|
|
104
108
|
isDraft: {
|
|
105
109
|
kind: "boolean",
|
|
106
110
|
description: "true when the pull request is a draft"
|
|
@@ -859,6 +863,8 @@ var checkSuiteWebhookSchema = z.object({
|
|
|
859
863
|
slug: z.string().optional().nullable()
|
|
860
864
|
}).optional().nullable(),
|
|
861
865
|
conclusion: z.string().optional().nullable(),
|
|
866
|
+
/** Branch name for the suite head commit when GitHub sends it. */
|
|
867
|
+
head_branch: z.string().optional().nullable(),
|
|
862
868
|
head_sha: z.string().optional(),
|
|
863
869
|
id: z.number().optional(),
|
|
864
870
|
latest_check_runs_count: z.number().optional().nullable(),
|
|
@@ -897,24 +903,31 @@ function buildCheckSuiteUrl(args) {
|
|
|
897
903
|
function oneLineLabel(value, maxLength = 80) {
|
|
898
904
|
return value.replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim().slice(0, maxLength);
|
|
899
905
|
}
|
|
906
|
+
function checkSuiteHeadBranch(value) {
|
|
907
|
+
const branch = value?.trim();
|
|
908
|
+
return branch ? branch : void 0;
|
|
909
|
+
}
|
|
900
910
|
function buildCheckSuiteResourceEvent(args) {
|
|
901
|
-
const
|
|
902
|
-
|
|
911
|
+
const pullRequestNumber = args.pullRequestNumber;
|
|
912
|
+
const resource = pullRequestNumber === void 0 ? gitHubRepositoryResource({ repo: args.repo }) : gitHubPullRequestResource({
|
|
913
|
+
number: pullRequestNumber,
|
|
903
914
|
repo: args.repo
|
|
904
915
|
});
|
|
905
916
|
const shortSha = args.headSha?.slice(0, 12);
|
|
906
917
|
const failingChecks = (args.failingChecks ?? []).slice(0, 12);
|
|
907
918
|
const failingCount = failingChecks.length;
|
|
908
|
-
const
|
|
919
|
+
const branchSuffix = args.headBranch ? ` on ${args.headBranch}` : "";
|
|
920
|
+
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}.`;
|
|
909
921
|
const data = {
|
|
910
922
|
repo: args.repo,
|
|
911
|
-
pullRequest: args.pullRequestNumber,
|
|
912
923
|
scope: "check_suite",
|
|
913
924
|
suiteConclusion: args.suiteConclusion
|
|
914
925
|
};
|
|
926
|
+
if (pullRequestNumber !== void 0) data.pullRequest = pullRequestNumber;
|
|
915
927
|
if (typeof args.isDraft === "boolean") data.isDraft = args.isDraft;
|
|
916
928
|
if (args.authorUsername) data.authorUsername = args.authorUsername;
|
|
917
929
|
if (args.authorEmail) data.authorEmail = args.authorEmail;
|
|
930
|
+
if (args.headBranch) data.headBranch = args.headBranch;
|
|
918
931
|
if (args.headSha) data.headSha = args.headSha;
|
|
919
932
|
if (args.checkSuiteId !== void 0) data.checkSuiteId = args.checkSuiteId;
|
|
920
933
|
if (args.checkSuiteId !== void 0 && args.headSha) {
|
|
@@ -946,7 +959,7 @@ function buildCheckSuiteResourceEvent(args) {
|
|
|
946
959
|
return {
|
|
947
960
|
eventKey: gitHubEventKey(
|
|
948
961
|
args.deliveryId,
|
|
949
|
-
`${args.eventType}:${
|
|
962
|
+
pullRequestNumber === void 0 ? args.eventType : `${args.eventType}:${pullRequestNumber}`
|
|
950
963
|
),
|
|
951
964
|
eventType: args.eventType,
|
|
952
965
|
occurredAtMs: Date.now(),
|
|
@@ -990,27 +1003,43 @@ function normalizeCheckSuiteEvents(deliveryId, body, options) {
|
|
|
990
1003
|
if (!eventType || typeof conclusion !== "string") return [];
|
|
991
1004
|
const suite = parsed.data.check_suite;
|
|
992
1005
|
const appName = suite.app?.name?.trim() || suite.app?.slug?.trim() || void 0;
|
|
1006
|
+
const headBranch = checkSuiteHeadBranch(suite.head_branch);
|
|
993
1007
|
const headSha = typeof suite.head_sha === "string" && /^[0-9a-f]{7,40}$/i.test(suite.head_sha) ? suite.head_sha : void 0;
|
|
994
1008
|
const repository = parsed.data.repository;
|
|
995
1009
|
const repo = repository.full_name;
|
|
996
|
-
|
|
997
|
-
|
|
1010
|
+
const shared = {
|
|
1011
|
+
appName,
|
|
1012
|
+
checkSuiteId: suite.id,
|
|
1013
|
+
deliveryId,
|
|
1014
|
+
eventType,
|
|
1015
|
+
failingChecks: eventType === "pull_request.checks.failed" ? options?.failingChecks : void 0,
|
|
1016
|
+
headSha,
|
|
1017
|
+
latestCheckRunsCount: typeof suite.latest_check_runs_count === "number" ? suite.latest_check_runs_count : void 0,
|
|
1018
|
+
repo,
|
|
1019
|
+
suiteConclusion: conclusion
|
|
1020
|
+
};
|
|
1021
|
+
const sameRepoPullRequests = suite.pull_requests.filter(
|
|
1022
|
+
(pullRequest) => isCheckSuiteRepositoryPullRequest(pullRequest, repository.id)
|
|
1023
|
+
);
|
|
1024
|
+
if (sameRepoPullRequests.length === 0) {
|
|
1025
|
+
return [
|
|
1026
|
+
buildCheckSuiteResourceEvent({
|
|
1027
|
+
...shared,
|
|
1028
|
+
...headBranch ? { headBranch } : void 0
|
|
1029
|
+
})
|
|
1030
|
+
];
|
|
1031
|
+
}
|
|
1032
|
+
return sameRepoPullRequests.flatMap((pullRequest) => {
|
|
998
1033
|
const facts = options?.pullRequestFactsByNumber?.[pullRequest.number];
|
|
1034
|
+
const pullRequestHeadBranch = checkSuiteHeadBranch(pullRequest.head?.ref) ?? headBranch;
|
|
999
1035
|
return pullRequestTargets(
|
|
1000
1036
|
buildCheckSuiteResourceEvent({
|
|
1001
|
-
|
|
1037
|
+
...shared,
|
|
1002
1038
|
...facts?.authorEmail ? { authorEmail: facts.authorEmail } : void 0,
|
|
1003
1039
|
...facts?.authorUsername ? { authorUsername: facts.authorUsername } : void 0,
|
|
1004
|
-
|
|
1005
|
-
deliveryId,
|
|
1006
|
-
eventType,
|
|
1007
|
-
failingChecks: eventType === "pull_request.checks.failed" ? options?.failingChecks : void 0,
|
|
1008
|
-
headSha,
|
|
1040
|
+
...pullRequestHeadBranch ? { headBranch: pullRequestHeadBranch } : void 0,
|
|
1009
1041
|
...typeof facts?.isDraft === "boolean" ? { isDraft: facts.isDraft } : void 0,
|
|
1010
|
-
|
|
1011
|
-
pullRequestNumber: pullRequest.number,
|
|
1012
|
-
repo,
|
|
1013
|
-
suiteConclusion: conclusion
|
|
1042
|
+
pullRequestNumber: pullRequest.number
|
|
1014
1043
|
}),
|
|
1015
1044
|
repo
|
|
1016
1045
|
);
|
|
@@ -1187,6 +1216,10 @@ function gitHubEventKey2(deliveryId, eventType) {
|
|
|
1187
1216
|
function pullRequestDraftData(draft) {
|
|
1188
1217
|
return typeof draft === "boolean" ? { isDraft: draft } : void 0;
|
|
1189
1218
|
}
|
|
1219
|
+
function pullRequestHeadBranchData(headRef) {
|
|
1220
|
+
const headBranch = headRef?.trim();
|
|
1221
|
+
return headBranch ? { headBranch } : void 0;
|
|
1222
|
+
}
|
|
1190
1223
|
function pullRequestAuthorData(user) {
|
|
1191
1224
|
const data = {};
|
|
1192
1225
|
const username = user?.login?.trim();
|
|
@@ -1464,6 +1497,9 @@ var pullRequestReviewCommentWebhookSchema = z2.object({
|
|
|
1464
1497
|
}),
|
|
1465
1498
|
pull_request: z2.object({
|
|
1466
1499
|
draft: z2.boolean().optional(),
|
|
1500
|
+
head: z2.object({
|
|
1501
|
+
ref: z2.string().optional().nullable()
|
|
1502
|
+
}).optional().nullable(),
|
|
1467
1503
|
number: z2.number(),
|
|
1468
1504
|
user: z2.object({
|
|
1469
1505
|
email: z2.string().optional().nullable(),
|
|
@@ -1484,7 +1520,8 @@ function normalizePullRequestReviewCommentEvent(deliveryId, body) {
|
|
|
1484
1520
|
const author = parsed.data.comment.user?.login;
|
|
1485
1521
|
const data = pullRequestMatchData([
|
|
1486
1522
|
pullRequestDraftData(parsed.data.pull_request.draft),
|
|
1487
|
-
pullRequestAuthorData(parsed.data.pull_request.user)
|
|
1523
|
+
pullRequestAuthorData(parsed.data.pull_request.user),
|
|
1524
|
+
pullRequestHeadBranchData(parsed.data.pull_request.head?.ref)
|
|
1488
1525
|
]);
|
|
1489
1526
|
return pullRequestTargets2(
|
|
1490
1527
|
{
|
|
@@ -1503,6 +1540,9 @@ var pullRequestReviewWebhookSchema = z2.object({
|
|
|
1503
1540
|
action: z2.string(),
|
|
1504
1541
|
pull_request: z2.object({
|
|
1505
1542
|
draft: z2.boolean().optional(),
|
|
1543
|
+
head: z2.object({
|
|
1544
|
+
ref: z2.string().optional().nullable()
|
|
1545
|
+
}).optional().nullable(),
|
|
1506
1546
|
number: z2.number(),
|
|
1507
1547
|
user: z2.object({
|
|
1508
1548
|
email: z2.string().optional().nullable(),
|
|
@@ -1530,7 +1570,8 @@ function normalizePullRequestReviewEvent(deliveryId, body) {
|
|
|
1530
1570
|
const reviewer = parsed.data.review.user?.login;
|
|
1531
1571
|
const data = pullRequestMatchData([
|
|
1532
1572
|
pullRequestDraftData(parsed.data.pull_request.draft),
|
|
1533
|
-
pullRequestAuthorData(parsed.data.pull_request.user)
|
|
1573
|
+
pullRequestAuthorData(parsed.data.pull_request.user),
|
|
1574
|
+
pullRequestHeadBranchData(parsed.data.pull_request.head?.ref)
|
|
1534
1575
|
]);
|
|
1535
1576
|
return pullRequestTargets2(
|
|
1536
1577
|
{
|
|
@@ -1552,6 +1593,9 @@ var pullRequestWebhookSchema = z2.object({
|
|
|
1552
1593
|
closed_at: z2.string().optional().nullable(),
|
|
1553
1594
|
created_at: z2.string().optional(),
|
|
1554
1595
|
draft: z2.boolean().optional(),
|
|
1596
|
+
head: z2.object({
|
|
1597
|
+
ref: z2.string().optional().nullable()
|
|
1598
|
+
}).optional().nullable(),
|
|
1555
1599
|
merged: z2.boolean().optional(),
|
|
1556
1600
|
merged_at: z2.string().optional().nullable(),
|
|
1557
1601
|
number: z2.number(),
|
|
@@ -1582,7 +1626,8 @@ function pullRequestLifecycleEvents(input) {
|
|
|
1582
1626
|
pullRequestAuthorData({
|
|
1583
1627
|
email: input.authorEmail,
|
|
1584
1628
|
login: input.authorUsername
|
|
1585
|
-
})
|
|
1629
|
+
}),
|
|
1630
|
+
pullRequestHeadBranchData(input.headBranch)
|
|
1586
1631
|
]);
|
|
1587
1632
|
return pullRequestTargets2(
|
|
1588
1633
|
{
|
|
@@ -1609,6 +1654,9 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1609
1654
|
const draft = parsed.data.pull_request.draft;
|
|
1610
1655
|
const isDraft = typeof draft === "boolean" ? draft : void 0;
|
|
1611
1656
|
const author = pullRequestAuthorData(parsed.data.pull_request.user);
|
|
1657
|
+
const headBranch = pullRequestHeadBranchData(
|
|
1658
|
+
parsed.data.pull_request.head?.ref
|
|
1659
|
+
)?.headBranch;
|
|
1612
1660
|
const untrustedText = pullRequestEventText(parsed.data.pull_request);
|
|
1613
1661
|
if (parsed.data.action === "opened") {
|
|
1614
1662
|
const openedAtMs = providerTime(parsed.data.pull_request.created_at) ?? Date.now();
|
|
@@ -1616,6 +1664,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1616
1664
|
...author,
|
|
1617
1665
|
deliveryId,
|
|
1618
1666
|
eventType: "pull_request.opened",
|
|
1667
|
+
...headBranch ? { headBranch } : void 0,
|
|
1619
1668
|
...isDraft !== void 0 ? { isDraft } : void 0,
|
|
1620
1669
|
occurredAtMs: openedAtMs,
|
|
1621
1670
|
repo,
|
|
@@ -1629,6 +1678,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1629
1678
|
...author,
|
|
1630
1679
|
deliveryId,
|
|
1631
1680
|
eventType: "pull_request.ready_for_review",
|
|
1681
|
+
...headBranch ? { headBranch } : void 0,
|
|
1632
1682
|
isDraft: false,
|
|
1633
1683
|
occurredAtMs: openedAtMs,
|
|
1634
1684
|
repo,
|
|
@@ -1645,6 +1695,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1645
1695
|
...author,
|
|
1646
1696
|
deliveryId,
|
|
1647
1697
|
eventType: "pull_request.ready_for_review",
|
|
1698
|
+
...headBranch ? { headBranch } : void 0,
|
|
1648
1699
|
isDraft: false,
|
|
1649
1700
|
occurredAtMs: providerTime(parsed.data.pull_request.updated_at) ?? Date.now(),
|
|
1650
1701
|
repo,
|
|
@@ -1659,6 +1710,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1659
1710
|
...author,
|
|
1660
1711
|
deliveryId,
|
|
1661
1712
|
eventType,
|
|
1713
|
+
...headBranch ? { headBranch } : void 0,
|
|
1662
1714
|
...isDraft !== void 0 ? { isDraft } : void 0,
|
|
1663
1715
|
occurredAtMs: providerTime(
|
|
1664
1716
|
parsed.data.pull_request.merged ? parsed.data.pull_request.merged_at : parsed.data.pull_request.closed_at
|
package/dist/index.js
CHANGED
package/dist/testing.js
CHANGED
|
@@ -26,7 +26,7 @@ export declare function buildCheckSuiteUrl(args: {
|
|
|
26
26
|
headSha: string;
|
|
27
27
|
repo: string;
|
|
28
28
|
}): string;
|
|
29
|
-
/** Build the trusted data and summary for one check-suite
|
|
29
|
+
/** Build the trusted data and summary for one check-suite event. */
|
|
30
30
|
export declare function buildCheckSuiteResourceEvent(args: {
|
|
31
31
|
appName?: string;
|
|
32
32
|
authorEmail?: string;
|
|
@@ -35,10 +35,12 @@ export declare function buildCheckSuiteResourceEvent(args: {
|
|
|
35
35
|
deliveryId: string;
|
|
36
36
|
eventType: "pull_request.checks.failed" | "pull_request.checks.recovered";
|
|
37
37
|
failingChecks?: GitHubFailingCheck[];
|
|
38
|
+
headBranch?: string;
|
|
38
39
|
headSha?: string;
|
|
39
40
|
isDraft?: boolean;
|
|
40
41
|
latestCheckRunsCount?: number;
|
|
41
|
-
|
|
42
|
+
/** Pull request number when GitHub attached one. */
|
|
43
|
+
pullRequestNumber?: number;
|
|
42
44
|
repo: string;
|
|
43
45
|
suiteConclusion: string;
|
|
44
46
|
}): ResourceEventInput;
|
|
@@ -46,7 +48,7 @@ export declare function buildCheckSuiteResourceEvent(args: {
|
|
|
46
48
|
export declare function selectFailingChecks(checkRuns: unknown, options?: {
|
|
47
49
|
checkSuiteId?: number;
|
|
48
50
|
}): GitHubFailingCheck[];
|
|
49
|
-
/** Normalize a completed check suite for
|
|
51
|
+
/** Normalize a completed check suite for attached PRs, or the repository alone. */
|
|
50
52
|
export declare function normalizeCheckSuiteEvents(deliveryId: string, body: unknown, options?: GitHubCheckSuiteFacts): ResourceEventInput[];
|
|
51
53
|
/** Identifiers and event types one completed check suite may publish. */
|
|
52
54
|
export declare function parseCheckSuitePublishTargets(body: unknown): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.191.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@sinclair/typebox": "^0.34.49",
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
|
-
"zod": "^4.4
|
|
34
|
-
"@sentry/junior-plugin-api": "0.
|
|
33
|
+
"zod": "^4.5.4",
|
|
34
|
+
"@sentry/junior-plugin-api": "0.191.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@oxlint/plugins": "1.79.0",
|