-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
462b475
commit 8247a40
Showing
3 changed files
with
47 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
40 changes: 40 additions & 0 deletions
40
.github/workflows/scripts/a11y-contrast/prepare-check-results.cjs
This file contains 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,40 @@ | ||
const prepareResults = (results) => { | ||
const faildChecks = results.reduce((acc, {failingContrast}) => acc + failingContrast, 0); | ||
|
||
// prepare outputs for all failed themes | ||
const failedResults = results.filter(themeResults => themeResults.failingContrast > 0).map(({theme, failingContrast, markdownTable}) => ({ | ||
title: `# ❌ \`${theme}\`: ${failingContrast} checks failed`, | ||
body: `${markdownTable}` | ||
})) | ||
|
||
// prepare summary body | ||
const summaryMarkdown = '## Design Token Contrast Check\n\n' + | ||
results.map(({theme, failingContrast, failedMarkdownTable}) => { | ||
if(failingContrast === 0) { | ||
return "### \\`"+theme+"\\`: " + `✅ all checks passed\n\n` | ||
} | ||
// if there are failing checks, return a summary with a details section | ||
return "### \\`"+theme+"\\`: " + `❌ ${failingContrast} checks failed\n\n` + | ||
'<details>' + | ||
`<summary>Show results table for theme: ${theme}</summary>\n` + | ||
" \n"+ | ||
` ${failedMarkdownTable}` + | ||
'\n</details>' | ||
}).join('\n\n') | ||
|
||
// set output | ||
core.setOutput('summaryMarkdown', summaryMarkdown) | ||
core.setOutput('failedResults', failedResults) | ||
core.setOutput('faildChecks', faildChecks) | ||
|
||
// fail action if any contrast check fails | ||
if (faildChecks > 0) { | ||
core.setFailed(`\u001b[91;1m🛑 ${faildChecks} contrast checks failed. Please fix the failing checks and try again.\n\nCheck action summary for more details.`); | ||
} | ||
// success | ||
else { | ||
core.info('\u001b[32;1m✅ All contrast checks passed!') | ||
} | ||
} | ||
|
||
module.exports = prepareResults |
39 changes: 0 additions & 39 deletions
39
.github/workflows/scripts/a11y-contrast/prepare-check-results.js
This file was deleted.
Oops, something went wrong.