-
Notifications
You must be signed in to change notification settings - Fork 21
223 lines (195 loc) · 8.31 KB
/
accessibility_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
- name: Configure AWS credentials
if: failure()
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
role-to-assume: Deployments
role-duration-seconds: 3600
role-skip-session-tagging: true
- name: Get secrets from AWS ParameterStore
if: failure()
uses: dkershner6/aws-ssm-getparameters-action@v2
with:
parameterPairs: "/teaching-vacancies/github_action/infra/slack_webhook = SLACK_WEBHOOK"
- name: Set environment variables from build output
if: failure()
run: |
echo "LINK_TO_RUN=https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" >> $GITHUB_ENV
- name: Notify twd_tv_dev channel on Pa11y test failures
if: failure()
uses: rtCamp/[email protected]
env:
SLACK_CHANNEL: twd_tv_dev
SLACK_USERNAME: CI Accessiblity Tests
SLACK_TITLE: Pa11y tests failures
SLACK_MESSAGE: |
Pa11y accessibility tests failed against QA environment
See: <${{ env.LINK_TO_RUN }}|Workflow run>
SLACK_WEBHOOK: ${{env.SLACK_WEBHOOK}}
SLACK_COLOR: failure
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
- name: Install axe-core and sitemap-urls
run: npm install -g @axe-core/cli sitemap-urls node-jq
- name: Get list of URLs to test against from QA sitemap
run: |
# Gets all urls from sitemap in an array
urls=($(curl https://$HTTP_BASIC_USER:[email protected]/sitemap.xml | sitemap-urls))
# Removes redundant sitemap urls
urls=("${urls[@]/*teaching-jobs-in-*}")
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\.}")
echo "URLS=$urls" >> $GITHUB_ENV
- name: Run Axe accessibility tests against QA sitemap pages
run: |
axe $(for url in "${URLS[@]}"; do echo $url, ; done;) --exit
- name: Configure AWS credentials
if: failure()
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
role-to-assume: Deployments
role-duration-seconds: 3600
role-skip-session-tagging: true
- name: Get secrets from AWS ParameterStore
if: failure()
uses: dkershner6/aws-ssm-getparameters-action@v2
with:
parameterPairs: "/teaching-vacancies/github_action/infra/slack_webhook = SLACK_WEBHOOK"
- name: Set environment variables from build output
if: failure()
run: |
echo "LINK_TO_RUN=https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" >> $GITHUB_ENV
- name: Notify twd_tv_dev channel on Axe test failures
if: failure()
uses: rtCamp/[email protected]
env:
SLACK_CHANNEL: twd_tv_dev
SLACK_USERNAME: CI Accessiblity Tests
SLACK_TITLE: Axe tests failures
SLACK_MESSAGE: |
Axe accessibility tests failed against QA environment
See: <${{ env.LINK_TO_RUN }}|Workflow run>
SLACK_WEBHOOK: ${{env.SLACK_WEBHOOK}}
SLACK_COLOR: failure
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: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
role-to-assume: Deployments
role-duration-seconds: 3600
role-skip-session-tagging: true
- name: Get secrets from AWS ParameterStore
uses: dkershner6/aws-ssm-getparameters-action@v2
with:
parameterPairs: "/teaching-vacancies/github_action/infra/slack_webhook = SLACK_WEBHOOK"
- 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: Set environment variables for testing URLs
run: |
echo "INDEX_URL=https://qa.teaching-vacancies.service.gov.uk/" >> $GITHUB_ENV
echo "JOBS_URL=https://qa.teaching-vacancies.service.gov.uk/jobs" >> $GITHUB_ENV
echo "SCHOOLS_URL=https://qa.teaching-vacancies.service.gov.uk/schools" >> $GITHUB_ENV
- name: Audit URLs using Lighthouse
id: LHCIAction
uses: treosh/lighthouse-ci-action@v12
with:
urls: |
$INDEX_URL
$JOBS_URL
$SCHOOLS_URL
uploadArtifacts: true # save results as an action artifacts
temporaryPublicStorage: true # upload lighthouse report to the temporary storage
runs: 3
- name: Set environment variables for test results
run: |
echo "INDEX_RESULT=$(echo '${{steps.LHCIAction.outputs.links}}' | jq 'nth(0; .[])' | tr -d '"')" >> $GITHUB_ENV
echo "JOBS_RESULT=$(echo '${{steps.LHCIAction.outputs.links}}' | jq 'nth(1; .[])' | tr -d '"')" >> $GITHUB_ENV
echo "SCHOOLS_RESULT=$(echo '${{steps.LHCIAction.outputs.links}}' | jq 'nth(2; .[])' | tr -d '"')" >> $GITHUB_ENV
- name: Notify twd_tv_dev channel on Lighthouse results
uses: rtCamp/[email protected]
env:
SLACK_CHANNEL: twd_tv_dev
SLACK_USERNAME: CI Accessiblity Tests
SLACK_TITLE: LightHouse tests results
SLACK_MESSAGE: |
LightHouse accessibility and performance tests ran against the QA environment
<${{ env.INDEX_RESULT }}|Index page results>
<${{ env.JOBS_RESULT }}|Jobs page results>
<${{ env.SCHOOLS_RESULT }}|Schools page results>
SLACK_WEBHOOK: ${{ env.SLACK_WEBHOOK }}
SLACK_COLOR: good