MCPcopy Create free account
hub / github.com/github/gh-aw / runRangeReport

Function runRangeReport

actions/setup/js/run_activity_report.cjs:39–98  ·  view source on GitHub ↗

* Run the logs command for a configured report range. * * @param {string} bin * @param {string[]} prefixArgs * @param {string} repoSlug * @param {ActivityRange} range * @param {string} outputDir * @returns {Promise<{ heading: string, body: string }>}

(bin, prefixArgs, repoSlug, range, outputDir)

Source from the content-addressed store, hash-verified

37 * @returns {Promise<{ heading: string, body: string }>}
38 */
39async function runRangeReport(bin, prefixArgs, repoSlug, range, outputDir) {
40 const args = [...prefixArgs, "logs", "--repo", repoSlug, "--start-date", range.startDate, "--count", String(REPORT_COUNT), "--output", outputDir, "--format", "markdown"];
41 core.info(`Running: ${bin} ${args.join(" ")}`);
42
43 try {
44 const result = await exec.getExecOutput(bin, args, { ignoreReturnCode: true });
45 const output = `${result.stdout || ""}\n${result.stderr || ""}`.trim();
46 const rateLimited = hasRateLimitText(output);
47
48 if (result.exitCode === 0 && result.stdout.trim()) {
49 return {
50 heading: range.heading,
51 body: normalizeReportMarkdown(sanitizeContent(result.stdout.trim())),
52 };
53 }
54
55 if (rateLimited && range.optionalOnRateLimit) {
56 core.warning(`Skipping ${range.heading} report due to GitHub API rate limiting`);
57 return {
58 heading: range.heading,
59 body: "_Skipped due to GitHub API rate limiting._",
60 };
61 }
62
63 if (rateLimited) {
64 return {
65 heading: range.heading,
66 body: "_Could not generate this section due to GitHub API rate limiting._",
67 };
68 }
69
70 return {
71 heading: range.heading,
72 body: `_Report command failed (exit code ${result.exitCode})._\n\n\`\`\`\n${sanitizeContent(output || "No command output was captured.")}\n\`\`\``,
73 };
74 } catch (error) {
75 const errorMessage = getErrorMessage(error);
76 const rateLimited = isRateLimitError(error) || hasRateLimitText(errorMessage);
77
78 if (rateLimited && range.optionalOnRateLimit) {
79 core.warning(`Skipping ${range.heading} report due to GitHub API rate limiting`);
80 return {
81 heading: range.heading,
82 body: "_Skipped due to GitHub API rate limiting._",
83 };
84 }
85
86 if (rateLimited) {
87 return {
88 heading: range.heading,
89 body: "_Could not generate this section due to GitHub API rate limiting._",
90 };
91 }
92
93 return {
94 heading: range.heading,
95 body: `_Report command failed: ${sanitizeContent(errorMessage)}_`,
96 };

Callers 1

mainFunction · 0.85

Calls 5

hasRateLimitTextFunction · 0.85
normalizeReportMarkdownFunction · 0.85
sanitizeContentFunction · 0.85
getErrorMessageFunction · 0.70
isRateLimitErrorFunction · 0.70

Tested by

no test coverage detected