Accessibility Tests #75
Workflow file for this run
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
name: Accessibility Tests | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 3 * * 0' # Run every Sunday at 3am | |
jobs: | |
pally: | |
name: Pa11y accessibility tests | |
environment: qa | |
env: | |
RAILS_ENV: test | |
HTTP_BASIC_USER: ${{ secrets.HTTP_BASIC_USER }} | |
HTTP_BASIC_PASSWORD: ${{ secrets.HTTP_BASIC_PASSWORD }} | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Prepare application environment | |
uses: ./.github/actions/prepare-app-env | |
with: | |
skip-ruby: true | |
- name: Install pa11y-ci | |
run: | | |
npm install --global --unsafe-perm pa11y-ci | |
mkdir /tmp/pa11y | |
- name: Run Pa11y accessibility tests against QA sitemap pages | |
run: | | |
pa11y-ci --config=.pa11yci \ | |
--sitemap https://$HTTP_BASIC_USER:[email protected]/sitemap.xml \ | |
--sitemap-find qa.teaching \ | |
--sitemap-replace $HTTP_BASIC_USER:[email protected] \ | |
--sitemap-exclude teaching-jobs-in- \ | |
> report.txt | |
- name: Report Pa11y accessibility test results | |
run: cat report.txt && ((`cat report.txt | grep sign-in | wc -l`<2)) || exit 1 | |
axe: | |
name: Axe accessibility tests | |
environment: qa | |
env: | |
RAILS_ENV: test | |
HTTP_BASIC_USER: ${{ secrets.HTTP_BASIC_USER }} | |
HTTP_BASIC_PASSWORD: ${{ secrets.HTTP_BASIC_PASSWORD }} | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Prepare application environment | |
uses: ./.github/actions/prepare-app-env | |
with: | |
skip-ruby: true | |
- run: npm install | |
- name: Run Axe accessibility tests against QA sitemap pages | |
run: | | |
npm install -g @axe-core/cli sitemap-urls | |
# Gets all urls from sitemap in an array | |
urls=($(curl https://$HTTP_BASIC_USER:[email protected]/sitemap.xml | sitemap-urls)) | |
# Removes sitemap urls that are redundant | |
urls=("${urls[@]/*teaching-jobs-in-*}") | |
echo $(for url in "${urls[@]}"; do echo "$url\n"; done;) | |
# urls=("${urls[@]/*-jobs}") | |
# Delete empty elements | |
for i in ${!urls[@]}; do [[ -z ${urls[i]} ]] && unset urls[i]; done | |
# Transforms URLS to authenticated URLs | |
urls=("${urls[@]/qa\./$HTTP_BASIC_USER\:$HTTP_BASIC_PASSWORD\@qa\.}") | |
# Runs axe against each url from the sitemap | |
axe $(for url in "${urls[@]}"; do echo $url, ; done;) --exit | |
lighthouse: | |
name: Lighthouse tests | |
environment: qa | |
env: | |
RAILS_ENV: test | |
HTTP_BASIC_USER: ${{ secrets.HTTP_BASIC_USER }} | |
HTTP_BASIC_PASSWORD: ${{ secrets.HTTP_BASIC_PASSWORD }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Prepare application environment | |
uses: ./.github/actions/prepare-app-env | |
with: | |
skip-ruby: true | |
- name: Set lighthouse config values | |
run: | | |
encoded_auth=$(echo -n $HTTP_BASIC_USER:$HTTP_BASIC_PASSWORD | base64) | |
sed -i "s/auth_token/${encoded_auth}/g" .lighthouserc.json | |
- name: Audit URLs using Lighthouse | |
uses: treosh/lighthouse-ci-action@v12 | |
with: | |
urls: | | |
https://qa.teaching-vacancies.service.gov.uk | |
https://qa.teaching-vacancies.service.gov.uk/jobs | |
https://qa.teaching-vacancies.service.gov.uk/schools | |
uploadArtifacts: true # save results as an action artifacts | |
temporaryPublicStorage: true # upload lighthouse report to the temporary storage | |
runs: 3 | |