-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(tooling): enforce every configured check and split CI into reporting jobs #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c413565
fix(publishing-contract): reject fixed workspace pins that go stale o…
DPHonys 9f46f8c
refactor(tooling): drop the unrun wiring and make every configured ch…
DPHonys 29342b4
ci: split the check gate into parallel jobs that report on the pull r…
DPHonys 5a0d6d7
ci: keep the junit report globs out of the node_modules symlink loop
DPHonys f277cea
ci: pass the junit report globs as the comma-separated list the repor…
DPHonys 599285a
ci: post every job's outcome with lint and test totals as a sticky pu…
DPHonys c89b297
ci: provision the pinned Node for the report job and read it from .nvmrc
DPHonys 22a6b9e
fix(publishing-contract): name the section a sibling pin was declared in
DPHonys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Setup | ||
| description: Check out, install the pinned toolchain, restore caches, and install dependencies. | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - uses: pnpm/action-setup@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: pnpm | ||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: .turbo | ||
| key: turbo-${{ runner.os }}-${{ github.sha }} | ||
| restore-keys: | | ||
| turbo-${{ runner.os }}- | ||
| - run: pnpm install --frozen-lockfile | ||
| shell: bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /** | ||
| * Renders the Markdown fragments CI posts as one sticky pull request comment. | ||
| * | ||
| * pr-report.ts jobs <needs-json> table of every job's result | ||
| * pr-report.ts lint <oxlint.json> <eslint.txt> | ||
| * pr-report.ts junit <junit.xml>... | ||
| */ | ||
| import { readFileSync } from 'node:fs' | ||
| import process from 'node:process' | ||
|
|
||
| interface JobOutcome { | ||
| result: 'success' | 'failure' | 'cancelled' | 'skipped' | ||
| } | ||
|
|
||
| interface OxlintReport { | ||
| diagnostics: { severity: 'error' | 'warning' | string }[] | ||
| } | ||
|
|
||
| const badge = { | ||
| success: '✅ passed', | ||
| failure: '❌ failed', | ||
| cancelled: '⚪ cancelled', | ||
| skipped: '⏭️ skipped', | ||
| } satisfies Record<JobOutcome['result'], string> | ||
|
|
||
| function jobsTable(needsJson: string): string { | ||
| const needs: Record<string, JobOutcome> = JSON.parse(needsJson) | ||
| const rows = Object.entries(needs).map( | ||
| ([job, outcome]) => `| ${job} | ${badge[outcome.result]} |` | ||
| ) | ||
| return ['| Job | Result |', '| --- | --- |', ...rows].join('\n') | ||
| } | ||
|
|
||
| function lintSummary(oxlintPath: string, eslintPath: string): string { | ||
| const oxlint: OxlintReport = JSON.parse(readFileSync(oxlintPath, 'utf8')) | ||
| const oxlintErrors = oxlint.diagnostics.filter( | ||
| (diagnostic) => diagnostic.severity === 'error' | ||
| ).length | ||
| const oxlintWarnings = oxlint.diagnostics.length - oxlintErrors | ||
|
|
||
| // ESLint's stylish formatter ends with "✖ N problems (E errors, W warnings)" | ||
| // and prints nothing at all when the tree is clean. | ||
| const eslintOutput = readFileSync(eslintPath, 'utf8') | ||
| const eslintTotals = /\((\d+) errors?, (\d+) warnings?\)/.exec(eslintOutput) | ||
| const eslintErrors = Number(eslintTotals?.[1] ?? 0) | ||
| const eslintWarnings = Number(eslintTotals?.[2] ?? 0) | ||
|
|
||
| return [ | ||
| '| Linter | Errors | Warnings |', | ||
| '| --- | ---: | ---: |', | ||
| `| Oxlint | ${oxlintErrors} | ${oxlintWarnings} |`, | ||
| `| ESLint | ${eslintErrors} | ${eslintWarnings} |`, | ||
| ].join('\n') | ||
| } | ||
|
|
||
| interface SuiteTotals { | ||
| tests: number | ||
| failures: number | ||
| errors: number | ||
| skipped: number | ||
| } | ||
|
|
||
| function junitSummary(paths: string[]): string { | ||
| const rows = paths.map((path) => { | ||
| const totals = readTotals(readFileSync(path, 'utf8')) | ||
| const workspace = path.replace(/\/test-results\/junit\.xml$/, '') | ||
| const passed = | ||
| totals.tests - totals.failures - totals.errors - totals.skipped | ||
| const failed = totals.failures + totals.errors | ||
| const status = failed > 0 ? '❌' : '✅' | ||
| return `| ${status} ${workspace} | ${passed} | ${failed} | ${totals.skipped} |` | ||
| }) | ||
| return [ | ||
| '| Workspace | Passed | Failed | Skipped |', | ||
| '| --- | ---: | ---: | ---: |', | ||
| ...rows, | ||
| ].join('\n') | ||
| } | ||
|
|
||
| /** Vitest writes one `<testsuites>` root carrying the file totals. */ | ||
| function readTotals(xml: string): SuiteTotals { | ||
| const root = /<testsuites\b[^>]*>/.exec(xml)?.[0] ?? '' | ||
| const attribute = (name: string): number => | ||
| Number(new RegExp(`\\b${name}="(\\d+)"`).exec(root)?.[1] ?? 0) | ||
| return { | ||
| tests: attribute('tests'), | ||
| failures: attribute('failures'), | ||
| errors: attribute('errors'), | ||
| skipped: attribute('skipped'), | ||
| } | ||
| } | ||
|
|
||
| const [mode, ...rest] = process.argv.slice(2) | ||
| switch (mode) { | ||
| case 'jobs': | ||
| console.log(jobsTable(rest[0] ?? '{}')) | ||
| break | ||
| case 'lint': | ||
| console.log(lintSummary(rest[0] ?? '', rest[1] ?? '')) | ||
| break | ||
| case 'junit': | ||
| console.log(junitSummary(rest)) | ||
| break | ||
| default: | ||
| console.error(`unknown mode: ${mode ?? '(none)'}`) | ||
| process.exitCode = 1 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,7 @@ dist/ | |
| **/.nuxt/ | ||
| **/.nitro/ | ||
| **/.output/ | ||
|
|
||
| # Vitest junit output for the CI reporter | ||
| test-results/ | ||
| reports/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1 @@ | ||
| #shamefully-hoist=true | ||
| #shell-emulator=true | ||
| #strict-peer-dependencies=false | ||
| engine-strict=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| lts/* | ||
| 26 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.