Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -847,26 +847,43 @@ describe("toPullRequestChecks", () => {
]);
});

it("reads a manual-only build nobody queued as skipped rather than pending forever", () => {
const checks = checksFor([
policy({
status: "queued",
settings: { manualQueueOnly: true, displayName: "Optional perf" },
}),
policy({
status: "queued",
settings: { manualQueueOnly: true, displayName: "Queued perf" },
context: { buildId: 9 },
}),
policy({ status: "notApplicable", settings: { displayName: "Docs" } }),
policy({ status: "broken", settings: { displayName: "Broken" } }),
]);

expect(checks.map((check) => [check.name, check.status, check.description])).toEqual([
["Broken", "failure", null],
["Docs", "skipped", null],
["Optional perf", "skipped", "Not run"],
["Queued perf", "pending", null],
]);
});
it.each([undefined, null, 0, -1, 1.5])(
"reads a manual-only build with no valid run (%s) as skipped rather than pending forever",
(buildId) => {
const checks = checksFor([
policy({
status: "queued",
settings: { displayName: "Awaiting run" },
context: { buildId: 0 },
}),
policy({
status: "queued",
settings: { manualQueueOnly: true, displayName: "Optional perf" },
context: { buildId },
}),
policy({
status: "queued",
settings: { manualQueueOnly: true, displayName: "Queued perf" },
context: { buildId: 9 },
}),
policy({ status: "notApplicable", settings: { displayName: "Docs" } }),
policy({ status: "broken", settings: { displayName: "Broken" } }),
]);

expect(
checks.map((check) => [check.name, check.status, check.description, check.url]),
).toEqual([
["Awaiting run", "pending", null, null],
["Broken", "failure", null, null],
["Docs", "skipped", null, null],
["Optional perf", "skipped", "Not run", null],
[
"Queued perf",
"pending",
null,
"https://dev.azure.com/acme/6f9c9b7f-0000-0000-0000-000000000000/_build/results?buildId=9",
],
]);
},
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,11 @@ export function toPullRequestChecks(
trimmed(context?.buildDefinitionName) ??
trimmed(configuration.type?.displayName);
if (name === null) continue;
const buildId = context?.buildId ?? null;
const reportedBuildId = context?.buildId;
const buildId =
reportedBuildId != null && Number.isSafeInteger(reportedBuildId) && reportedBuildId > 0
? reportedBuildId
: null;
const neverQueued = settings?.manualQueueOnly === true && buildId === null;
// An expired build no longer satisfies its policy, and Azure counts it as failed.
const expired = context?.isExpired === true;
Expand Down
Loading