-
Notifications
You must be signed in to change notification settings - Fork 13
fix: make docs generation alerts say why and what to do #1124
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
Open
teallarson
wants to merge
8
commits into
main
Choose a base branch
from
fix/loud-docs-generation-alerts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
295d1ae
fix: make docs generation alerts say why and what to do
teallarson d96b106
fix: keep a failed Slack post from claiming generation failed
teallarson f5f855b
fix: don't let the job-URL lookup swallow the Slack alert
teallarson e6da31b
fix: report preserved or omitted toolkits even when a later step fails
teallarson a3e987b
fix: alert Slack when docs generate but never publish
teallarson 38c3a4b
test: match the workflow assertions to the two-headline alert
teallarson 34d49f3
Merge remote-tracking branch 'origin/main' into fix/loud-docs-generat…
teallarson 346f4ff
docs: clarify tsx invocation requirement
teallarson 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
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,96 @@ | ||
| /** | ||
| * Slack message for a generation run that recovered from toolkit failures. | ||
| * | ||
| * The text is built here rather than in workflow YAML so that it is testable, | ||
| * and so it can carry the two things the report already knows but a bare list | ||
| * of toolkit names cannot say: why the toolkit failed, and what to do about it. | ||
| * | ||
| * `omitted` outranks `preserved` throughout. A preserved toolkit still serves | ||
| * yesterday's page and nobody notices; an omitted toolkit has no page at all. | ||
| */ | ||
| import type { | ||
| FailedToolsReport, | ||
| RecoveredToolkitEntry, | ||
| } from "../utils/run-logs"; | ||
|
|
||
| export interface SlackMessage { | ||
| readonly text: string; | ||
| } | ||
|
|
||
| export interface DocsAlertLinks { | ||
| /** Deep link to the job log, so the reader lands on the error, not a summary. */ | ||
| readonly logUrl?: string; | ||
| } | ||
|
|
||
| const MISSING_METADATA_REASON = "missing design-system metadata"; | ||
| const CURATION_REASON_PREFIX = "Curation"; | ||
|
|
||
| const suggestFix = (entry: RecoveredToolkitEntry): string => { | ||
| if (entry.reason.includes(MISSING_METADATA_REASON)) { | ||
| return `Add a \`${entry.id}\` entry to \`@arcadeai/design-system\` and bump the pin in this repo, or add it to \`skip-toolkits.txt\` if it is not meant to be public yet.`; | ||
| } | ||
| if (entry.reason.startsWith(CURATION_REASON_PREFIX)) { | ||
| return `Fix the curation source under \`toolkit-docs-generator/curation/${entry.id.toLowerCase()}/\`.`; | ||
| } | ||
| return "Open the failing step for the full error."; | ||
| }; | ||
|
|
||
| const formatEntry = (entry: RecoveredToolkitEntry): string => | ||
| [`• *${entry.id}* — ${entry.reason}`, ` Fix: ${suggestFix(entry)}`].join( | ||
| "\n" | ||
| ); | ||
|
|
||
| const formatSection = ( | ||
| heading: string, | ||
| entries: readonly RecoveredToolkitEntry[] | ||
| ): string[] => | ||
| entries.length === 0 | ||
| ? [] | ||
| : [`*${heading}*`, entries.map(formatEntry).join("\n")]; | ||
|
|
||
| const formatHeadline = ( | ||
| omitted: readonly RecoveredToolkitEntry[], | ||
| preserved: readonly RecoveredToolkitEntry[] | ||
| ): string => { | ||
| if (omitted.length === 1) { | ||
| return `:no_entry: ${omitted[0]?.id} is missing from the docs site`; | ||
| } | ||
| if (omitted.length > 1) { | ||
| return `:no_entry: ${omitted.length} toolkits are missing from the docs site`; | ||
| } | ||
| if (preserved.length === 1) { | ||
| return `:warning: ${preserved[0]?.id} kept its previous docs`; | ||
| } | ||
| return `:warning: ${preserved.length} toolkits kept their previous docs`; | ||
| }; | ||
|
|
||
| /** | ||
| * Build the Slack payload for a finished run, or null when the run had nothing | ||
| * worth interrupting anyone about. | ||
| */ | ||
| export const buildDocsAlert = ( | ||
| report: Pick<FailedToolsReport, "recoveredToolkits">, | ||
| links: DocsAlertLinks = {} | ||
| ): SlackMessage | null => { | ||
| const recovered = report.recoveredToolkits ?? []; | ||
| if (recovered.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| const omitted = recovered.filter((entry) => entry.recovery === "omitted"); | ||
| const preserved = recovered.filter((entry) => entry.recovery === "preserved"); | ||
|
|
||
| const blocks = [ | ||
| formatHeadline(omitted, preserved), | ||
| ...formatSection("Missing entirely (no previous output)", omitted), | ||
| ...formatSection("Still serving the previous docs", preserved), | ||
| ]; | ||
|
|
||
| if (links.logUrl) { | ||
| blocks.push( | ||
| `<${links.logUrl}|Open the failing step> · full detail in the \`failed-tools\` artifact on the run` | ||
| ); | ||
| } | ||
|
|
||
| return { text: blocks.join("\n\n") }; | ||
| }; |
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.