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

[Issue #677]: Add accessibility checks against pr preview env #84

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7d9f20c
initial commit
rylew1 Jul 2, 2024
94b95b2
add package.json targets
rylew1 Jul 2, 2024
e04c891
updates to workflow file
rylew1 Jul 2, 2024
26c864a
move files to app dir
rylew1 Jul 2, 2024
9a04a14
add targest to app dir package.json
rylew1 Jul 2, 2024
e54ff5a
update a11y workflow file
rylew1 Jul 2, 2024
8763389
call a11y tests from pr env update
rylew1 Jul 2, 2024
39f293c
fix shellcheck
rylew1 Jul 2, 2024
eba0a0f
save service endpoint to file
rylew1 Jul 2, 2024
2d56288
attempt shell fixes
rylew1 Jul 2, 2024
736ba34
bash shell and quoting
rylew1 Jul 2, 2024
4dac90a
format
rylew1 Jul 2, 2024
eb86f5b
update accessibility job
rylew1 Jul 2, 2024
ed93fa4
double quote fix
rylew1 Jul 3, 2024
4102734
add debug steps
rylew1 Jul 3, 2024
76f9a6e
debug service endpoint url
rylew1 Jul 3, 2024
08ebf2e
update
rylew1 Jul 3, 2024
59e3613
update url
rylew1 Jul 3, 2024
2a0c57c
cat updated config
rylew1 Jul 3, 2024
70f96f1
add outputs
rylew1 Jul 3, 2024
6da1354
add actionlint make target
rylew1 Jul 3, 2024
5977ac0
add env on a11y job
rylew1 Jul 3, 2024
60448cb
add back in comments
rylew1 Jul 3, 2024
abd3dc7
get-service-endpoint
rylew1 Jul 3, 2024
fc53114
revert GH_TOKEN
rylew1 Jul 3, 2024
479a56b
rename to accessibility-scans
rylew1 Jul 5, 2024
844de9c
split desktop / mobile into parallel jobs
rylew1 Jul 5, 2024
acf36b7
share var b/w jobs
rylew1 Jul 5, 2024
4e14352
install in each step
rylew1 Jul 5, 2024
9e95374
update service_endpoint reference
rylew1 Jul 6, 2024
7c0e855
screenshots output
rylew1 Jul 6, 2024
688e5f1
switch back to npm run
rylew1 Jul 6, 2024
10c3bc7
add npm ci back in
rylew1 Jul 6, 2024
bf873a4
screenshot output folder name
rylew1 Jul 6, 2024
1b4df3e
remove debug step
rylew1 Jul 6, 2024
1327465
revert app folder package.json
rylew1 Jul 6, 2024
2c058d7
update ci to use accessibility folder
rylew1 Jul 6, 2024
8dd3a47
move config to accessibility folder
rylew1 Jul 6, 2024
b86493c
remove setup step
rylew1 Jul 6, 2024
1f66a21
fix naming
rylew1 Jul 6, 2024
5e4fea4
remove gitignore space change
rylew1 Jul 8, 2024
9f29e2c
remove extra package.json
rylew1 Jul 9, 2024
d3cfce7
refactor json to js
rylew1 Jul 9, 2024
5984d53
try update config with node call
rylew1 Jul 9, 2024
75f364a
resolve path correctly
rylew1 Jul 9, 2024
f986fad
add update-config comments
rylew1 Jul 9, 2024
2ed792b
add explaining comments on pa11y config files
rylew1 Jul 9, 2024
8a27271
add missing bracket
rylew1 Jul 9, 2024
e172c18
add optional app_name param
rylew1 Jul 9, 2024
a1cbe57
try more universally applicable actions
rylew1 Jul 9, 2024
2dede8d
remove wait for document to be ready
rylew1 Jul 9, 2024
bda839d
try env var
rylew1 Jul 9, 2024
d45abd0
switch to dotenv for localhost
rylew1 Jul 9, 2024
ecede82
DRY files with a base config
rylew1 Jul 9, 2024
a210e7e
add WCAG standard
rylew1 Jul 9, 2024
ef5eb71
start docs
rylew1 Jul 10, 2024
891388a
add conditional for multiple app config
rylew1 Jul 10, 2024
af8e2bd
fix link
rylew1 Jul 10, 2024
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
99 changes: 99 additions & 0 deletions .github/workflows/accessibility-scans.yml
Copy link
Collaborator

Choose a reason for hiding this comment

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

Take a look at this comment on the e2e PR. I'd think that we'd want to do something similar here in order to support multiple apps and in order to be able to support running the accessibility scans outside the context of a PR environment. In other words, I think we'll want to have this workflow take an app_name input in addition to a service_endpoint input, then use that to load app-specific configurations (since different apps will have different sets of URLs).

Copy link
Author

Choose a reason for hiding this comment

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

Added a quick if/else statement in the workflow

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Accessibility Scans

on:
workflow_call:
inputs:
service_endpoint:
required: true
type: string

jobs:
accessibility-desktop-scans:
name: Run Desktop Accessibility Scans
runs-on: ubuntu-latest

env:
SERVICE_ENDPOINT: ${{ inputs.service_endpoint }}

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache-dependency-path: ./accessibility/package-lock.json
cache: npm

- name: Install dependencies
run: npm ci
working-directory: ./accessibility

- name: Create screenshots directory
run: mkdir -p ./accessibility/screenshots-output

- name: Update pa11y-ci config for desktop
run: node ./accessibility/update-config.js .pa11yci-desktop.js ${{ inputs.service_endpoint }}

- name: Cat updated pa11y-ci config for desktop
run: cat ./accessibility/.pa11yci-desktop.js

- name: Run pa11y-ci Desktop
run: |
set -e # Ensure the script fails if any command fails
npm run test:pa11y-desktop
echo "pa11y-ci desktop tests finished."
working-directory: ./accessibility

- name: Upload screenshots to artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: screenshots-desktop
path: ./accessibility/screenshots-output

accessibility-mobile-scans:
name: Run Mobile Accessibility Scans
runs-on: ubuntu-latest

env:
SERVICE_ENDPOINT: ${{ inputs.service_endpoint }}

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache-dependency-path: ./accessibility/package-lock.json
cache: npm

- name: Install dependencies
run: npm ci
working-directory: ./accessibility

- name: Create screenshots directory
run: mkdir -p ./accessibility/screenshots-output

- name: Update pa11y-ci config for mobile
run: node ./accessibility/update-config.js .pa11yci-mobile.js ${{ inputs.service_endpoint }}

- name: Cat updated pa11y-ci config for mobile
run: cat ./accessibility/.pa11yci-mobile.js

- name: Run pa11y-ci Mobile
run: |
set -e # Ensure the script fails if any command fails
npm run test:pa11y-mobile
echo "pa11y-ci mobile tests finished."
working-directory: ./accessibility

- name: Upload screenshots to artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: screenshots-mobile
path: ./accessibility/screenshots-output
19 changes: 19 additions & 0 deletions .github/workflows/pr-environment-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
commit_hash:
required: true
type: string

jobs:
build-and-publish:
name: " " # GitHub UI is noisy when calling reusable workflows, so use whitespace for name to reduce noise
Expand All @@ -35,6 +36,9 @@ jobs:

concurrency: pr-environment-${{ inputs.pr_number }}

outputs:
service_endpoint: ${{ steps.get-service-endpoint.outputs.service_endpoint }}

steps:
- uses: actions/checkout@v4

Expand All @@ -51,6 +55,21 @@ jobs:
environment: ${{ inputs.environment }}

- name: Update environment
id: update-environment
run: ./bin/update-pr-environment "${{ inputs.app_name }}" "${{ inputs.environment }}" "${{ inputs.pr_number }}" "${{ inputs.commit_hash }}"
env:
GH_TOKEN: ${{ github.token }}

- name: Capture service endpoint
id: get-service-endpoint
run: |
service_endpoint=$(terraform -chdir="infra/${{ inputs.app_name }}/service" output -raw service_endpoint)
echo "service_endpoint=${service_endpoint}"
echo "service_endpoint=${service_endpoint}" >> "$GITHUB_OUTPUT"

accessibility:
name: Accessibility Checks
needs: [update]
uses: ./.github/workflows/accessibility-scans.yml
with:
service_endpoint: ${{ needs.update.outputs.service_endpoint }}
1 change: 1 addition & 0 deletions accessibility/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/*
34 changes: 34 additions & 0 deletions accessibility/.pa11yci-desktop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
"defaults": {
// The maximum time allowed for the entire test run, in milliseconds
"timeout": 240000,

// The accessibility testing runners to use; "axe" is a common choice
"runners": ["axe"],

// An array of rules to ignore during the accessibility test
// pa11y reports false positive color-contrast issues https://github.com/pa11y/pa11y/issues/633
"ignore": ["color-contrast"],

// The number of tests to run concurrently
"concurrency": 1,

// Configuration for launching Chrome
"chromeLaunchConfig": {
// Ignore HTTPS errors (useful for testing environments with self-signed certificates)
"ignoreHTTPSErrors": true,
"args": [
// Prevent chrome from crashing when using shared memory for large files/data
"--disable-dev-shm-usage",
// Disables Chrome's sandboxing for compatibility with environments where sandboxing might cause issues.
"--no-sandbox"
]
},

// Actions to perform during the test
"actions": [
"wait for element body to be visible",
"screen capture screenshots-output/desktop-main-view.png"
]
}
};
42 changes: 42 additions & 0 deletions accessibility/.pa11yci-mobile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
"defaults": {
// The maximum time allowed for the entire test run, in milliseconds
"timeout": 240000,

// The accessibility testing runners to use; "axe" is a common choice
"runners": ["axe"],

// An array of rules to ignore during the accessibility test
// pa11y reports false positive color-contrast issues https://github.com/pa11y/pa11y/issues/633
"ignore": ["color-contrast"],

// The number of tests to run concurrently
"concurrency": 1,

// Configuration for launching Chrome
"chromeLaunchConfig": {
// Ignore HTTPS errors (useful for testing environments with self-signed certificates)
"ignoreHTTPSErrors": true,
"args": [
// Prevent chrome from crashing when using shared memory for large files/data
"--disable-dev-shm-usage",
// Disables Chrome's sandboxing for compatibility with environments where sandboxing might cause issues.
"--no-sandbox"
]
},

// Configuration for the viewport size and type
"viewport": {
"width": 390,
"height": 844,
"mobile": true ,

// Actions to perform during the test
"actions": [
"wait for element #main-content to be visible",
"screen capture screenshots-output/mobile-main-view.png",
"click element .usa-navbar button",
"screen capture screenshots-output/mobile-expand-menu.png"
]
}
};
Loading
Loading