@continuous-excellence/ze-great-dashboard-aws 0.31.19 → 0.31.20
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/cli.js +2 -1
- package/dist/index.js +2 -1
- package/dist/lambda.mjs +65 -26
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -668,7 +668,8 @@ var runSchema = z7.object({
|
|
|
668
668
|
head_branch: z7.string().min(1).nullable().optional(),
|
|
669
669
|
// Timestamp quality should only remove timing advice, never make an otherwise useful run unreadable.
|
|
670
670
|
run_started_at: z7.string().nullable().optional(),
|
|
671
|
-
updated_at: z7.string().optional()
|
|
671
|
+
updated_at: z7.string().optional(),
|
|
672
|
+
created_at: z7.string().optional()
|
|
672
673
|
});
|
|
673
674
|
var runsSchema = z7.object({ workflow_runs: z7.array(runSchema) });
|
|
674
675
|
var jobsSchema = z7.object({
|
package/dist/index.js
CHANGED
|
@@ -1349,7 +1349,8 @@ var runSchema = z7.object({
|
|
|
1349
1349
|
head_branch: z7.string().min(1).nullable().optional(),
|
|
1350
1350
|
// Timestamp quality should only remove timing advice, never make an otherwise useful run unreadable.
|
|
1351
1351
|
run_started_at: z7.string().nullable().optional(),
|
|
1352
|
-
updated_at: z7.string().optional()
|
|
1352
|
+
updated_at: z7.string().optional(),
|
|
1353
|
+
created_at: z7.string().optional()
|
|
1353
1354
|
});
|
|
1354
1355
|
var runsSchema = z7.object({ workflow_runs: z7.array(runSchema) });
|
|
1355
1356
|
var jobsSchema = z7.object({
|
package/dist/lambda.mjs
CHANGED
|
@@ -70222,7 +70222,8 @@ var runSchema = external_exports.object({
|
|
|
70222
70222
|
head_branch: external_exports.string().min(1).nullable().optional(),
|
|
70223
70223
|
// Timestamp quality should only remove timing advice, never make an otherwise useful run unreadable.
|
|
70224
70224
|
run_started_at: external_exports.string().nullable().optional(),
|
|
70225
|
-
updated_at: external_exports.string().optional()
|
|
70225
|
+
updated_at: external_exports.string().optional(),
|
|
70226
|
+
created_at: external_exports.string().optional()
|
|
70226
70227
|
});
|
|
70227
70228
|
var runsSchema = external_exports.object({ workflow_runs: external_exports.array(runSchema) });
|
|
70228
70229
|
var jobsSchema = external_exports.object({
|
|
@@ -70422,12 +70423,13 @@ function pullRequestsCall(source, baseBranch, page) {
|
|
|
70422
70423
|
url2.searchParams.set("page", String(page));
|
|
70423
70424
|
return { url: url2.toString(), headers: new Headers() };
|
|
70424
70425
|
}
|
|
70425
|
-
function githubRunsCall(source, workflow, branch, event, perPage = 1) {
|
|
70426
|
+
function githubRunsCall(source, workflow, branch, event, perPage = 1, created) {
|
|
70426
70427
|
const url2 = new URL(
|
|
70427
70428
|
`https://api.github.com/repos/${source.repo}/actions/workflows/${encodeURIComponent(workflow)}/runs`
|
|
70428
70429
|
);
|
|
70429
70430
|
if (branch) url2.searchParams.set("branch", branch);
|
|
70430
70431
|
if (event) url2.searchParams.set("event", event);
|
|
70432
|
+
if (created) url2.searchParams.set("created", `>=${created}`);
|
|
70431
70433
|
url2.searchParams.set("per_page", String(perPage));
|
|
70432
70434
|
return { url: url2.toString(), headers: new Headers() };
|
|
70433
70435
|
}
|
|
@@ -70444,16 +70446,42 @@ function sourceLinkForRepository(source) {
|
|
|
70444
70446
|
}
|
|
70445
70447
|
async function fetchGithubActionsPipeline(args) {
|
|
70446
70448
|
const parsedSource = githubActionsSourceSchema.parse(args.source);
|
|
70447
|
-
const
|
|
70448
|
-
|
|
70449
|
+
const parsedPanel = pipelinePanelSchema2.parse(args.panel);
|
|
70450
|
+
const githubClient = githubClientFor(args);
|
|
70451
|
+
const recentCall = githubRunsCall(
|
|
70452
|
+
parsedSource,
|
|
70453
|
+
parsedPanel.pipeline,
|
|
70454
|
+
parsedSource.branch,
|
|
70455
|
+
void 0,
|
|
70456
|
+
100,
|
|
70457
|
+
recentRunsCreatedAt()
|
|
70458
|
+
);
|
|
70449
70459
|
let upstream;
|
|
70460
|
+
let runs;
|
|
70450
70461
|
try {
|
|
70451
|
-
upstream = await githubFetch(
|
|
70462
|
+
upstream = await githubFetch(recentCall, {
|
|
70452
70463
|
requestHeaders: args.requestHeaders,
|
|
70453
70464
|
fetcher: args.fetcher,
|
|
70454
70465
|
source: parsedSource,
|
|
70455
|
-
githubClient
|
|
70466
|
+
githubClient
|
|
70456
70467
|
});
|
|
70468
|
+
if (upstream.status === 304) return { response: upstream };
|
|
70469
|
+
if (!upstream.ok) return githubPipelineFailure(args, upstream);
|
|
70470
|
+
runs = runsSchema.parse(await upstream.json()).workflow_runs;
|
|
70471
|
+
if (runs.length === 0) {
|
|
70472
|
+
upstream = await githubFetch(
|
|
70473
|
+
githubRunsCall(parsedSource, parsedPanel.pipeline, parsedSource.branch),
|
|
70474
|
+
{
|
|
70475
|
+
requestHeaders: args.requestHeaders,
|
|
70476
|
+
fetcher: args.fetcher,
|
|
70477
|
+
source: parsedSource,
|
|
70478
|
+
githubClient
|
|
70479
|
+
}
|
|
70480
|
+
);
|
|
70481
|
+
if (upstream.status === 304) return { response: upstream };
|
|
70482
|
+
if (!upstream.ok) return githubPipelineFailure(args, upstream);
|
|
70483
|
+
runs = runsSchema.parse(await upstream.json()).workflow_runs;
|
|
70484
|
+
}
|
|
70457
70485
|
} catch (error63) {
|
|
70458
70486
|
return {
|
|
70459
70487
|
response: new Response(
|
|
@@ -70473,27 +70501,8 @@ async function fetchGithubActionsPipeline(args) {
|
|
|
70473
70501
|
}
|
|
70474
70502
|
};
|
|
70475
70503
|
}
|
|
70476
|
-
if (upstream.status === 304) return { response: upstream };
|
|
70477
|
-
if (!upstream.ok) {
|
|
70478
|
-
return {
|
|
70479
|
-
response: new Response(
|
|
70480
|
-
JSON.stringify(
|
|
70481
|
-
errorEnvelope2(
|
|
70482
|
-
args.panel.id,
|
|
70483
|
-
errorKind2(upstream.status),
|
|
70484
|
-
`${upstream.status} ${upstream.statusText}`,
|
|
70485
|
-
sourceLink2(args.panel, args.source),
|
|
70486
|
-
observedAt3(upstream.headers.get("date"))
|
|
70487
|
-
)
|
|
70488
|
-
),
|
|
70489
|
-
{ status: 200 }
|
|
70490
|
-
),
|
|
70491
|
-
failure: { kind: errorKind2(upstream.status), upstreamStatus: upstream.status }
|
|
70492
|
-
};
|
|
70493
|
-
}
|
|
70494
70504
|
try {
|
|
70495
|
-
const
|
|
70496
|
-
const run = runs[0];
|
|
70505
|
+
const run = newestGithubRun(runs);
|
|
70497
70506
|
if (!run) {
|
|
70498
70507
|
return {
|
|
70499
70508
|
response: new Response(
|
|
@@ -70558,6 +70567,36 @@ async function fetchGithubActionsPipeline(args) {
|
|
|
70558
70567
|
};
|
|
70559
70568
|
}
|
|
70560
70569
|
}
|
|
70570
|
+
function githubPipelineFailure(args, upstream) {
|
|
70571
|
+
return {
|
|
70572
|
+
response: new Response(
|
|
70573
|
+
JSON.stringify(
|
|
70574
|
+
errorEnvelope2(
|
|
70575
|
+
args.panel.id,
|
|
70576
|
+
errorKind2(upstream.status),
|
|
70577
|
+
`${upstream.status} ${upstream.statusText}`,
|
|
70578
|
+
sourceLink2(args.panel, args.source),
|
|
70579
|
+
observedAt3(upstream.headers.get("date"))
|
|
70580
|
+
)
|
|
70581
|
+
),
|
|
70582
|
+
{ status: 200 }
|
|
70583
|
+
),
|
|
70584
|
+
failure: { kind: errorKind2(upstream.status), upstreamStatus: upstream.status }
|
|
70585
|
+
};
|
|
70586
|
+
}
|
|
70587
|
+
function recentRunsCreatedAt(now = /* @__PURE__ */ new Date()) {
|
|
70588
|
+
return new Date(now.valueOf() - 30 * 24 * 60 * 60 * 1e3).toISOString();
|
|
70589
|
+
}
|
|
70590
|
+
function newestGithubRun(runs) {
|
|
70591
|
+
return runs.reduce((newest, candidate) => {
|
|
70592
|
+
if (!newest) return candidate;
|
|
70593
|
+
const candidateCreatedAt = Date.parse(candidate.created_at ?? "");
|
|
70594
|
+
const newestCreatedAt = Date.parse(newest.created_at ?? "");
|
|
70595
|
+
if (candidateCreatedAt > newestCreatedAt) return candidate;
|
|
70596
|
+
if (candidateCreatedAt < newestCreatedAt) return newest;
|
|
70597
|
+
return (candidate.id ?? 0) > (newest.id ?? 0) ? candidate : newest;
|
|
70598
|
+
}, void 0);
|
|
70599
|
+
}
|
|
70561
70600
|
async function activeGithubActivity(args) {
|
|
70562
70601
|
const call = githubJobsCall(args.source, args.runId);
|
|
70563
70602
|
try {
|
package/package.json
CHANGED