cloudflare/kumo

Public

mirrored fromhttps://github.com/cloudflare/kumoAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ab273fe184fe56ca777f342fa4f1912f726563a8

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

ci/scripts/post-pr-report.ts

64lines · modecode

1#!/usr/bin/env tsx
2
3/**
4 * Post PR Report
5 *
6 * Collects report artifacts from upstream CI jobs and posts
7 * a consolidated comment to the pull request.
8 *
9 * This script should run as the final job in the pipeline,
10 * after all jobs that produce report artifacts.
11 *
12 * Usage: pnpm tsx ci/scripts/post-pr-report.ts
13 *
14 * Required environment variables:
15 * - GITHUB_PR_NUMBER: Pull request number (from github.event.pull_request.number)
16 * - GITHUB_TOKEN: GitHub API token
17 *
18 * Report artifacts are read from: ci/reports/*.json
19 */
20
21import { readReportArtifacts, buildContextFromEnv } from "../reporters";
22import { buildMarkdownComment, postPRComment } from "../utils/pr-reporter";
23
24async function main() {
25 console.log("Collecting report artifacts from upstream jobs...");
26
27 const context = buildContextFromEnv();
28
29 if (!context.prNumber) {
30 console.log("Not in PR context, skipping report");
31 return;
32 }
33
34 // Read all report artifacts from upstream jobs
35 const { items, failures } = readReportArtifacts();
36
37 console.log(` Found ${items.length} report artifact(s)`);
38 if (failures.length > 0) {
39 console.log(` ${failures.length} artifact(s) failed to load:`);
40 failures.forEach((f) => console.log(` - ${f}`));
41 }
42
43 if (items.length === 0) {
44 console.log("No report artifacts found, skipping comment");
45 return;
46 }
47
48 for (const item of items) {
49 console.log(` -> ${item.title} (${item.id})`);
50 }
51
52 console.log(`\nBuilding comment with ${items.length} section(s)...`);
53
54 // Build and post the comment
55 const comment = buildMarkdownComment(items, failures);
56 await postPRComment(context, comment);
57
58 console.log("PR report posted successfully");
59}
60
61main().catch((error) => {
62 console.error("Failed to post PR report:", error);
63 process.exit(1);
64});
65