-
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
028ad8e
commit 60a2236
Showing
3 changed files
with
89 additions
and
43 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
38 changes: 38 additions & 0 deletions
38
.github/workflows/scripts/a11y-contrast/prepare-check-results.js
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,38 @@ | ||
const core = require('@actions/core'); | ||
const results = require('./color-contrast-check.json'); | ||
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!') | ||
} |
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