Skip to content

Commit 4a68eba

Browse files
authored
CCM-5339: add acceaaibility scanner with verified commits (#37)
1 parent 83b56f5 commit 4a68eba

File tree

15 files changed

+2986
-21
lines changed

15 files changed

+2986
-21
lines changed

.devcontainer/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM mcr.microsoft.com/devcontainers/jekyll:2-bullseye
2+
3+
# Add dependencies required for pa11y-ci to execute inside of the devcontainer.
4+
RUN apt-get update \
5+
&& export DEBIAN_FRONTEND=noninteractive \
6+
&& apt-get -y install --no-install-recommends xorg openbox libnss3 libasound2 libatk-adaptor libgtk-3-0

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
{
44
"name": "Jekyll",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/jekyll:2-bullseye",
6+
"build": {
7+
"dockerfile": "Dockerfile"
8+
},
79
// Features to add to the dev container. More info: https://containers.dev/features.
810
// "features": {},
911
// Use 'forwardPorts' to make a list of ports inside the container available locally.

.github/workflows/stage-4-acceptance.yaml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,35 @@ jobs:
127127
steps:
128128
- name: "Checkout code"
129129
uses: actions/checkout@v4
130-
- name: "Run accessibility test"
131-
run: |
132-
make test-accessibility
133-
- name: "Save result"
134-
run: |
135-
echo "Nothing to save"
130+
- uses: actions/setup-node@v4
131+
with:
132+
node-version: 18
133+
- run: npm ci
134+
working-directory: './docs'
135+
- name: Setup Ruby
136+
uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0
137+
with:
138+
ruby-version: '3.1'
139+
bundler-cache: true
140+
cache-version: 0
141+
working-directory: './docs'
142+
- name: Setup Pages
143+
id: pages
144+
uses: actions/configure-pages@v5
145+
with:
146+
working-directory: './docs'
147+
- name: Build with Jekyll
148+
working-directory: ./docs
149+
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
150+
env:
151+
JEKYLL_ENV: production
152+
- name: Run accessibility test
153+
run: make test-accessibility
154+
- name: Archive accessibility results
155+
uses: actions/upload-artifact@v4
156+
with:
157+
name: accessibility
158+
path: "docs/.reports/accessibility"
136159
test-load:
137160
name: "Load test"
138161
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
# Please, add your custom content below!
1414

1515
!nhs-notify-web-cms.code-workspace
16+
.reports

docs/.pa11y-ci.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const fs = require('fs');
2+
const { XMLParser } = require('fast-xml-parser');
3+
4+
const SITEMAP_PATH = './_site/sitemap.xml';
5+
6+
function getUrlsFromSiteMap() {
7+
const file = fs.readFileSync(SITEMAP_PATH, 'utf8').toString();
8+
9+
const sitemap = new XMLParser().parse(file);
10+
11+
return sitemap.urlset.url.map(r => r.loc);
12+
}
13+
14+
module.exports = {
15+
defaults: {
16+
reporters: [
17+
'cli',
18+
[
19+
'pa11y-ci-reporter-html',
20+
{
21+
destination: './.reports/accessibility',
22+
includeZeroIssues: true
23+
}
24+
],
25+
],
26+
chromeLaunchConfig: {
27+
args: ['--no-sandbox']
28+
},
29+
useIncognitoBrowserContext: false,
30+
standard: 'WCAG2AA',
31+
userAgent: 'pa11y-ci',
32+
},
33+
urls: getUrlsFromSiteMap()
34+
};;

docs/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
3434
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]
3535

3636
gem "just-the-docs"
37+
38+
gem "jekyll-sitemap", "~> 1.4"

docs/Gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ GEM
4646
sass-embedded (~> 1.54)
4747
jekyll-seo-tag (2.8.0)
4848
jekyll (>= 3.8, < 5.0)
49+
jekyll-sitemap (1.4.0)
50+
jekyll (>= 3.7, < 5.0)
4951
jekyll-watch (2.2.1)
5052
listen (~> 3.0)
5153
just-the-docs (0.8.2)
@@ -80,9 +82,8 @@ GEM
8082
strscan (>= 3.0.9)
8183
rouge (4.2.1)
8284
safe_yaml (1.0.5)
83-
sass-embedded (1.69.5)
85+
sass-embedded (1.69.5-x86_64-linux-gnu)
8486
google-protobuf (~> 3.23)
85-
rake (>= 13.0.0)
8687
strscan (3.1.0)
8788
terminal-table (3.0.2)
8889
unicode-display_width (>= 1.1.1, < 3)
@@ -97,6 +98,7 @@ DEPENDENCIES
9798
jekyll (~> 4.3.3)
9899
jekyll-drawio
99100
jekyll-feed (~> 0.12)
101+
jekyll-sitemap (~> 1.4)
100102
just-the-docs
101103
minima (~> 2.5)
102104
tzinfo (>= 1, < 3)

docs/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Setup
44

5+
> For a non-technical approach read the instructions [here](../README.md).
6+
57
In the `docs` directory run the following command:
68

79
```bash
@@ -77,3 +79,17 @@ We have an assets folder which is used to put files such as;
7779
- CSS
7880

7981
If you have new images, favicons or other assets place them in the corresponding folder and the asset will be available via `/assets/<assert_type>/<asset_name>` for example `/assets/images/landing-main-image.svg`.
82+
83+
## Accessibility
84+
85+
This project uses `pa11y-ci` which is a wrapper over the `pa11y` project. It allows us to run `pa11y` in the CI/CD pipeline more easily.
86+
87+
To run an accessibility test ensure the web application in running by following the instruction in [Running the application](#running-the-application).
88+
89+
Run the following command:
90+
91+
```bash
92+
npm run test:accessibility
93+
```
94+
95+
The accessibility results are output in both the terminal and in the following location `.reports/accessibility/index.html`.

docs/_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@ exclude:
9797
- pages/examples/
9898
- adr/
9999
- '*.component.md'
100+
101+
plugins:
102+
- jekyll-sitemap

docs/_layouts/page.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
</nav>
4848
</div>
4949
<div class="nhsnotify-pane__main-content nhsuk-grid-column-three-quarters">
50-
{% if page.section != "" %}
51-
<h5 style="margin-bottom: 0; color: #4c6272">{{ page.section }}</h5>
50+
{% if page.section != undefined %}
51+
<p class="nhsuk-heading-s" style="margin-bottom: 0; color: #4c6272">{{ page.section }}</p>
5252
{% endif %}
5353
<h1>{{ page.title }}</h1>
5454
{{ content }}

0 commit comments

Comments
 (0)