Skip to content
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

Add WCAG PR check #274

Merged
merged 39 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
37874b6
Add WCAG PR check
nmanu1 Aug 2, 2022
8780aec
Automated update to THIRD-PARTY-NOTICES from github action's 3rd part…
github-actions[bot] Aug 2, 2022
a1c7241
Try sleeping
nmanu1 Aug 2, 2022
16c8437
Sleep longer
nmanu1 Aug 2, 2022
9882621
Fix wrong port and update package versions
nmanu1 Aug 2, 2022
4dc074b
Revert "Fix wrong port and update package versions"
nmanu1 Aug 2, 2022
931c341
Fix port and update some imports
nmanu1 Aug 2, 2022
e983c1e
Remove build
nmanu1 Aug 2, 2022
8dfe7c7
Remove extra steps
nmanu1 Aug 2, 2022
6012358
Bump some package versions
nmanu1 Aug 2, 2022
9fcac7f
Update more packages
nmanu1 Aug 2, 2022
cd16587
Bump a11y
nmanu1 Aug 2, 2022
fe13233
Bump actions
nmanu1 Aug 2, 2022
b7d9c6e
Bump links to 6.5.0
nmanu1 Aug 2, 2022
ea9fa1c
Upgrade percy
nmanu1 Aug 2, 2022
bfaae61
Bump links to 6.5.9
nmanu1 Aug 2, 2022
301c281
Try smoke-test
nmanu1 Aug 3, 2022
1123603
Revert "Try smoke-test"
nmanu1 Aug 3, 2022
1c0172f
Try bash script
nmanu1 Aug 3, 2022
6402c37
Try wrapping script
nmanu1 Aug 3, 2022
a7c0dbc
Try one long line
nmanu1 Aug 3, 2022
8bc9017
Remove |
nmanu1 Aug 3, 2022
4e77d97
Semicolons
nmanu1 Aug 3, 2022
6110549
Shorten
nmanu1 Aug 3, 2022
5e59685
Update packages and use TS
nmanu1 Aug 4, 2022
022bf2a
Upgrade percy/storybook
nmanu1 Aug 4, 2022
740ae60
Format and make quiet
nmanu1 Aug 4, 2022
cc9c956
Export default
nmanu1 Aug 4, 2022
e23d88c
Merge branch 'main' into dev/wcag-pr-check
nmanu1 Aug 4, 2022
5043813
Reuse script
nmanu1 Aug 4, 2022
ee5e7cf
Fix paths
nmanu1 Aug 4, 2022
7bd00a5
Try npm run command
nmanu1 Aug 4, 2022
212892a
oops
nmanu1 Aug 4, 2022
174bcba
Try some TS
nmanu1 Aug 4, 2022
074458d
Revert "Try some TS"
nmanu1 Aug 4, 2022
2fadcdd
Fix spacing
nmanu1 Aug 4, 2022
14ca6f8
Add asterisk
nmanu1 Aug 4, 2022
31f31fa
Abstract out wcag config
nmanu1 Aug 4, 2022
8e581aa
Update package-lock
nmanu1 Aug 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/wcag_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: WCAG tests

on:
pull_request:
branches:
- main

jobs:
call_wcag_test:
uses: yext/slapshot-reusable-workflows/.github/workflows/wcag_test.yml@v1
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
build_script: 'npm run storybook & sleep 10 && curl http://localhost:6006 -I'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure you looked into this but can we avoid the sleep 10? Maybe some option in start-storybook?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried finding a way to not use sleep and checked again in the start-storybook options. The closest option to what we want is --smoke-test, but that stops serving the site once it successfully starts. We need the site to be running when the test-storybook command is run. The only other way I saw to do this as part of a GH workflow was either to host the site somewhere public, or involved setting up service containers. Service containers seemed like they might be overkill, but I can look into it more

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is something like this possible? I don't have any experience trying stuff like this https://stackoverflow.com/questions/21475639/wait-until-service-starts-in-bash-script

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure! I updated it to be a while loop instead so it keeps checking every second, instead of having an arbitrary sleep time of 10 seconds

Copy link
Contributor

@oshi97 oshi97 Aug 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! this is very cool

35 changes: 35 additions & 0 deletions .storybook/test-runner.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { injectAxe, checkA11y } = require('axe-playwright');
oshi97 marked this conversation as resolved.
Show resolved Hide resolved

const config = {
runOnly: {
type: 'tag',
values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']
}
};

/*
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental
* to learn more about the test-runner hooks API.
*/
module.exports = {
async preRender(page) {
await injectAxe(page);
},
async postRender(page, context) {
const axeOptions = context.name === 'Loading'
alextaing marked this conversation as resolved.
Show resolved Hide resolved
? {
...config,
rules: {
'color-contrast': { enabled: false }
}
}
: config;
await checkA11y(page, '#root', {
axeOptions,
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};
2 changes: 1 addition & 1 deletion THIRD-PARTY-NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The following NPM packages may be included in this product:
- @babel/helper-validator-identifier@7.16.7
- @babel/highlight@7.16.10
- @babel/runtime-corejs3@7.17.2
- @babel/runtime@7.16.7
- @babel/runtime@7.18.9

These packages each contain the following license and notice below:

Expand Down
Loading