dsh-inbox-bridge 2.19.2 → 2.20.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.
- package/CHANGELOG.md +11 -0
- package/README.en.md +3 -2
- package/README.md +3 -2
- package/client.js +105 -6
- package/docs/DETAIL.md +1 -1
- package/docs/DETAIL.zh.md +1 -1
- package/docs/configuration.md +3 -2
- package/docs/how-it-works.md +5 -1
- package/docs/index.json +3 -3
- package/index.js +113 -8
- package/package.json +1 -1
- package/scripts/clear-inbox.mjs +9 -1
- package/scripts/github-inbox.mjs +1484 -1386
- package/scripts/github-inbox.test.mjs +122 -48
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
extractNotificationEvents,
|
|
18
18
|
extractPrEvents,
|
|
19
19
|
extractRunEvents,
|
|
20
|
+
extractReviewCommentEvents,
|
|
20
21
|
extractSecurityEvents,
|
|
21
22
|
filterRuns,
|
|
22
23
|
formatEvent,
|
|
@@ -812,6 +813,79 @@ test("a failing run on my pull request's branch is news; a stranger's branch is
|
|
|
812
813
|
assert.deepEqual(events.map((event) => event.key), ["run:24", "run:26"]);
|
|
813
814
|
});
|
|
814
815
|
|
|
816
|
+
test("a scheduled run says it was scheduled, so a nightly failure is not read as a push", () => {
|
|
817
|
+
const state = normalizeState({ lastPollAt: "2026-11-16T00:00:00.000Z" });
|
|
818
|
+
const nightly = extractRunEvents(
|
|
819
|
+
[run({ databaseId: 77, event: "schedule", workflowName: "nightly-cache", name: "nightly-cache" })],
|
|
820
|
+
state,
|
|
821
|
+
);
|
|
822
|
+
assert.equal(nightly.length, 1);
|
|
823
|
+
assert.equal(nightly[0].key, "run:77");
|
|
824
|
+
assert.equal(nightly[0].label, "Scheduled");
|
|
825
|
+
assert.equal(nightly[0].scheduled, true);
|
|
826
|
+
assert.match(formatEvent(nightly[0]), /^\[Scheduled\] run 77 failed: /u);
|
|
827
|
+
|
|
828
|
+
// A run triggered by a push keeps the plain CI name it always had.
|
|
829
|
+
const pushed = extractRunEvents([run({ databaseId: 78, event: "push" })], state);
|
|
830
|
+
assert.equal(pushed[0].label, "CI");
|
|
831
|
+
assert.equal(pushed[0].scheduled, false);
|
|
832
|
+
|
|
833
|
+
// The recovery of a nightly job is labeled the same way as its failure.
|
|
834
|
+
const recovered = extractRunEvents(
|
|
835
|
+
[run({ databaseId: 79, conclusion: "success", event: "schedule", workflowName: "nightly-cache" })],
|
|
836
|
+
normalizeState({
|
|
837
|
+
lastPollAt: "2026-11-16T00:00:00.000Z",
|
|
838
|
+
lastRun: { id: 77, conclusion: "failure" },
|
|
839
|
+
}),
|
|
840
|
+
);
|
|
841
|
+
const healed = recovered.find((event) => event.kind === "recovered");
|
|
842
|
+
assert.equal(healed?.label, "Scheduled");
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
test("a review comment on my pull request is news until a push answers it", () => {
|
|
846
|
+
const prs = [
|
|
847
|
+
pullRequest({ number: 7, headRefOid: "aaaa1111" }),
|
|
848
|
+
pullRequest({ number: 8, author: { login: "someone-else" }, headRefOid: "bbbb2222" }),
|
|
849
|
+
];
|
|
850
|
+
const comment = (overrides = {}) => ({
|
|
851
|
+
id: 42,
|
|
852
|
+
pull_request_url: "https://api.github.com/repos/Noema-Harness/noema-agent/pulls/7",
|
|
853
|
+
user: { login: "ichika0130" },
|
|
854
|
+
body: "this branch drops the retry\n\nplease keep it",
|
|
855
|
+
path: "src/a.ts",
|
|
856
|
+
line: 12,
|
|
857
|
+
commit_id: "aaaa1111",
|
|
858
|
+
html_url: "https://github.com/Noema-Harness/noema-agent/pull/7#discussion_r42",
|
|
859
|
+
created_at: "2026-11-17T09:00:00Z",
|
|
860
|
+
...overrides,
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
const fresh = extractReviewCommentEvents([comment()], { me: ME, prs });
|
|
864
|
+
assert.equal(fresh.length, 1);
|
|
865
|
+
assert.equal(fresh[0].key, "pr:7:review:42");
|
|
866
|
+
assert.equal(fresh[0].kind, "review");
|
|
867
|
+
assert.equal(fresh[0].role, "author");
|
|
868
|
+
assert.equal(fresh[0].ref, "src/a.ts:12");
|
|
869
|
+
assert.match(fresh[0].title, /^ichika0130: this branch drops the retry/u);
|
|
870
|
+
assert.match(formatEvent(fresh[0]), /^\[Review\/author\] #7 src\/a\.ts:12: /u);
|
|
871
|
+
|
|
872
|
+
// A push past the commit the comment was written on answers it: the source
|
|
873
|
+
// stops reporting it, which is how the queue closes it.
|
|
874
|
+
const answered = extractReviewCommentEvents([comment({ commit_id: "old00000" })], { me: ME, prs });
|
|
875
|
+
assert.deepEqual(answered, []);
|
|
876
|
+
|
|
877
|
+
// A comment on somebody else's pull request is not mine to carry.
|
|
878
|
+
const foreign = extractReviewCommentEvents(
|
|
879
|
+
[comment({ pull_request_url: "https://api.github.com/repos/o/r/pulls/8" })],
|
|
880
|
+
{ me: ME, prs },
|
|
881
|
+
);
|
|
882
|
+
assert.deepEqual(foreign, []);
|
|
883
|
+
|
|
884
|
+
// My own replies are not news either.
|
|
885
|
+
const mine = extractReviewCommentEvents([comment({ user: { login: ME } })], { me: ME, prs });
|
|
886
|
+
assert.deepEqual(mine, []);
|
|
887
|
+
});
|
|
888
|
+
|
|
815
889
|
test("the same PR number in two repositories becomes two keys", () => {
|
|
816
890
|
const one = tagEvents("owner/one", [{ key: "pr:7:author:failed[]|review:NONE", kind: "pr" }]);
|
|
817
891
|
const two = tagEvents("owner/two", [{ key: "pr:7:author:failed[]|review:NONE", kind: "pr" }]);
|
|
@@ -942,54 +1016,54 @@ test("a clean pull request keeps the digest it had before", () => {
|
|
|
942
1016
|
assert.equal(prStatusDigest(clean), prStatusDigest(pullRequest()));
|
|
943
1017
|
});
|
|
944
1018
|
|
|
945
|
-
test("open advisories collapse into one line per source", () => {
|
|
946
|
-
const alerts = [
|
|
947
|
-
{
|
|
948
|
-
source: "dependabot",
|
|
949
|
-
alert: {
|
|
950
|
-
number: 3,
|
|
951
|
-
html_url: "u3",
|
|
952
|
-
security_advisory: { severity: "high", summary: "Prototype pollution in foo" },
|
|
953
|
-
dependency: { package: { name: "foo" } },
|
|
954
|
-
updated_at: "2026-11-16T09:00:00Z",
|
|
955
|
-
},
|
|
956
|
-
},
|
|
957
|
-
{
|
|
958
|
-
source: "dependabot",
|
|
959
|
-
alert: {
|
|
960
|
-
number: 4,
|
|
961
|
-
html_url: "u4",
|
|
962
|
-
security_advisory: { severity: "low", summary: "TLS client crash in bar" },
|
|
963
|
-
dependency: { package: { name: "bar" } },
|
|
964
|
-
updated_at: "2026-11-16T10:00:00Z",
|
|
965
|
-
},
|
|
966
|
-
},
|
|
967
|
-
{
|
|
968
|
-
source: "code-scanning",
|
|
969
|
-
alert: {
|
|
970
|
-
number: 7,
|
|
971
|
-
html_url: "u7",
|
|
972
|
-
rule: { description: "Unvalidated input reaches the shell", security_severity_level: "medium" },
|
|
973
|
-
most_recent_instance: { location: { path: "scripts/run.mjs" } },
|
|
974
|
-
},
|
|
975
|
-
},
|
|
976
|
-
];
|
|
977
|
-
const events = extractSecurityEvents(alerts);
|
|
978
|
-
assert.deepEqual(
|
|
979
|
-
events.map((event) => event.key),
|
|
980
|
-
["dependabot", "code-scanning"],
|
|
981
|
-
);
|
|
982
|
-
assert.equal(events[0].kind, "security");
|
|
983
|
-
assert.equal(events[0].role, "any");
|
|
984
|
-
assert.equal(events[0].at, "2026-11-16T10:00:00Z");
|
|
985
|
-
const dependabot = formatEvent(events[0]);
|
|
986
|
-
assert.match(dependabot, /^\[Dependabot\] 2 open advisories \(1 high, 1 low\): foo, bar https:\/\//u);
|
|
987
|
-
assert.match(dependabot, /security\/dependabot$/u);
|
|
988
|
-
const scanning = formatEvent(events[1]);
|
|
989
|
-
assert.match(scanning, /^\[Code scanning\] 1 open advisory \(1 medium\): scripts\/run\.mjs /u);
|
|
990
|
-
assert.ok(!scanning.includes("#7"), "an aggregated line carries no alert number");
|
|
991
|
-
});
|
|
992
|
-
|
|
1019
|
+
test("open advisories collapse into one line per source", () => {
|
|
1020
|
+
const alerts = [
|
|
1021
|
+
{
|
|
1022
|
+
source: "dependabot",
|
|
1023
|
+
alert: {
|
|
1024
|
+
number: 3,
|
|
1025
|
+
html_url: "u3",
|
|
1026
|
+
security_advisory: { severity: "high", summary: "Prototype pollution in foo" },
|
|
1027
|
+
dependency: { package: { name: "foo" } },
|
|
1028
|
+
updated_at: "2026-11-16T09:00:00Z",
|
|
1029
|
+
},
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
source: "dependabot",
|
|
1033
|
+
alert: {
|
|
1034
|
+
number: 4,
|
|
1035
|
+
html_url: "u4",
|
|
1036
|
+
security_advisory: { severity: "low", summary: "TLS client crash in bar" },
|
|
1037
|
+
dependency: { package: { name: "bar" } },
|
|
1038
|
+
updated_at: "2026-11-16T10:00:00Z",
|
|
1039
|
+
},
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
source: "code-scanning",
|
|
1043
|
+
alert: {
|
|
1044
|
+
number: 7,
|
|
1045
|
+
html_url: "u7",
|
|
1046
|
+
rule: { description: "Unvalidated input reaches the shell", security_severity_level: "medium" },
|
|
1047
|
+
most_recent_instance: { location: { path: "scripts/run.mjs" } },
|
|
1048
|
+
},
|
|
1049
|
+
},
|
|
1050
|
+
];
|
|
1051
|
+
const events = extractSecurityEvents(alerts);
|
|
1052
|
+
assert.deepEqual(
|
|
1053
|
+
events.map((event) => event.key),
|
|
1054
|
+
["dependabot", "code-scanning"],
|
|
1055
|
+
);
|
|
1056
|
+
assert.equal(events[0].kind, "security");
|
|
1057
|
+
assert.equal(events[0].role, "any");
|
|
1058
|
+
assert.equal(events[0].at, "2026-11-16T10:00:00Z");
|
|
1059
|
+
const dependabot = formatEvent(events[0]);
|
|
1060
|
+
assert.match(dependabot, /^\[Dependabot\] 2 open advisories \(1 high, 1 low\): foo, bar https:\/\//u);
|
|
1061
|
+
assert.match(dependabot, /security\/dependabot$/u);
|
|
1062
|
+
const scanning = formatEvent(events[1]);
|
|
1063
|
+
assert.match(scanning, /^\[Code scanning\] 1 open advisory \(1 medium\): scripts\/run\.mjs /u);
|
|
1064
|
+
assert.ok(!scanning.includes("#7"), "an aggregated line carries no alert number");
|
|
1065
|
+
});
|
|
1066
|
+
|
|
993
1067
|
test("a repository without Dependabot still polls the rest", () => {
|
|
994
1068
|
const result = pollOnce({
|
|
995
1069
|
state: normalizeState({}),
|