Post React Compiler report as a sticky PR comment instead of a CI job
Review feedback: as a lint-matrix job it never fails and the report is buried in the job summary. A dedicated workflow now runs the report on every same-repo PR and posts it via sticky-pull-request-comment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -4,7 +4,8 @@
|
||||
|
||||
Reports which components and hooks React Compiler skipped optimizing, grouped by
|
||||
the compiler's own diagnostic category. Run with `pnpm react-compiler:report`;
|
||||
also runs in the Lint workflow, where it writes the report to the job summary.
|
||||
the React Compiler report workflow also runs it on every pull request and posts
|
||||
the report as a sticky PR comment.
|
||||
|
||||
## updateExtensions.sh
|
||||
|
||||
|
||||
@@ -21,11 +21,19 @@
|
||||
* Runs under Node's type stripping, so keep the syntax erasable - no enums, no
|
||||
* namespaces, and type-only imports must say `import type`.
|
||||
*
|
||||
* Prints the same report to stdout and, under GitHub Actions, to the job
|
||||
* summary. Always exits 0 - this is a metric, not a gate.
|
||||
* Prints the report to stdout, and writes a markdown version to the job
|
||||
* summary under GitHub Actions and to REACT_COMPILER_REPORT_PATH when set
|
||||
* (the React Compiler report workflow posts that file as a sticky PR
|
||||
* comment). Always exits 0 - this is a metric, not a gate.
|
||||
*/
|
||||
|
||||
import {appendFileSync, readdirSync, readFileSync, statSync} from 'node:fs'
|
||||
import {
|
||||
appendFileSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
statSync,
|
||||
writeFileSync,
|
||||
} from 'node:fs'
|
||||
import {dirname, join, relative, resolve} from 'node:path'
|
||||
import {fileURLToPath} from 'node:url'
|
||||
|
||||
@@ -179,40 +187,44 @@ for (const [file, message] of unreadable) {
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
* The markdown report goes to the job summary when running under GitHub
|
||||
* Actions, and to REACT_COMPILER_REPORT_PATH when set - the React Compiler
|
||||
* report workflow posts that file as a sticky PR comment.
|
||||
*/
|
||||
const summaryPath = process.env.GITHUB_STEP_SUMMARY
|
||||
if (summaryPath) {
|
||||
appendFileSync(
|
||||
summaryPath,
|
||||
[
|
||||
`## React Compiler`,
|
||||
``,
|
||||
`**${headline}** ${subhead}`,
|
||||
``,
|
||||
`| category | severity | components and hooks |`,
|
||||
`| --- | --- | --- |`,
|
||||
...ranked.map(
|
||||
([category, {severity, count}]) =>
|
||||
`| ${category} | ${severity} | ${count} |`,
|
||||
const reportPath = process.env.REACT_COMPILER_REPORT_PATH
|
||||
if (summaryPath || reportPath) {
|
||||
const markdown = [
|
||||
`## React Compiler`,
|
||||
``,
|
||||
`**${headline}** ${subhead}`,
|
||||
``,
|
||||
`| category | severity | components and hooks |`,
|
||||
`| --- | --- | --- |`,
|
||||
...ranked.map(
|
||||
([category, {severity, count}]) =>
|
||||
`| ${category} | ${severity} | ${count} |`,
|
||||
),
|
||||
``,
|
||||
`\`Hint\` is a \`Todo\`: syntax React Compiler does not support yet.`,
|
||||
`\`Error\` is code the compiler cannot safely optimize.`,
|
||||
``,
|
||||
`<details><summary>All ${rows.length + optedOut.size} skipped components and hooks</summary>`,
|
||||
``,
|
||||
...rows.map(
|
||||
([key, diagnostics]) =>
|
||||
`- \`${key}\` - ${diagnostics.map(d => `${d.category}: ${d.reason}`).join('; ')}`,
|
||||
),
|
||||
...[...optedOut]
|
||||
.sort()
|
||||
.map(
|
||||
key => `- \`${key}\` - CompileSkip: opted out via ${OPT_OUT_DIRECTIVE}`,
|
||||
),
|
||||
``,
|
||||
`\`Hint\` is a \`Todo\`: syntax React Compiler does not support yet.`,
|
||||
`\`Error\` is code the compiler cannot safely optimize.`,
|
||||
``,
|
||||
`<details><summary>All ${rows.length + optedOut.size} skipped components and hooks</summary>`,
|
||||
``,
|
||||
...rows.map(
|
||||
([key, diagnostics]) =>
|
||||
`- \`${key}\` - ${diagnostics.map(d => `${d.category}: ${d.reason}`).join('; ')}`,
|
||||
),
|
||||
...[...optedOut]
|
||||
.sort()
|
||||
.map(
|
||||
key =>
|
||||
`- \`${key}\` - CompileSkip: opted out via ${OPT_OUT_DIRECTIVE}`,
|
||||
),
|
||||
``,
|
||||
`</details>`,
|
||||
``,
|
||||
].join('\n'),
|
||||
)
|
||||
``,
|
||||
`</details>`,
|
||||
``,
|
||||
].join('\n')
|
||||
if (summaryPath) appendFileSync(summaryPath, markdown)
|
||||
if (reportPath) writeFileSync(reportPath, markdown)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user