Skip to content

Commit 71500d2

Browse files
authored
feat(ci): Migrate a11y-testing CircleCI job to GH Actions (#5082)
* migrate a11y-testing CircleCI job to GH Action * remove spike gha configs * remove a11y-testing from CircleCI config * remove comments
1 parent cc812e2 commit 71500d2

File tree

2 files changed

+118
-57
lines changed

2 files changed

+118
-57
lines changed

.circleci/config.yml

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -581,57 +581,6 @@ jobs:
581581
steps:
582582
- vrt-close-batch
583583

584-
a11y-testing:
585-
docker:
586-
- image: mcr.microsoft.com/playwright:focal
587-
environment:
588-
NODE_ENV: development
589-
A11Y_SERVER: 'http://localhost:9002'
590-
parallelism: 8
591-
resource_class: medium+
592-
593-
steps:
594-
- checkout
595-
- node/install-packages:
596-
# version cache here to remove conflict between this job and other concurrent jobs (init, prepare, etc).
597-
cache-version: a11y
598-
599-
- run:
600-
name: 'Build task'
601-
command: |
602-
npm run build
603-
npm run storybook:build
604-
605-
- run:
606-
name: 'Start web server'
607-
command: 'npm run server:bg:start'
608-
609-
- run:
610-
name: Generate test files
611-
command: 'npx wait-on $A11Y_SERVER && npm run test:a11y:generate-tests'
612-
613-
- run:
614-
name: 'Run a11y tests'
615-
command: |
616-
npx wait-on $A11Y_SERVER && curl -sL -w "======================\\nWait-on return code: %{http_code}\\n======================\\n\\n" "$A11Y_SERVER" -o /dev/null
617-
mkdir -p ./__tests__/a11y/xml/
618-
npx ava --tap ./__tests__/a11y/__testfiles__/ava.a11y.*.spec.js | npx tap-xunit --package="SLDS.a11y" > ./__tests__/a11y/xml/axe-results-$CIRCLE_NODE_INDEX.xml
619-
no_output_timeout: 20m
620-
621-
- run:
622-
name: Stop server
623-
command: 'npm run server:bg:delete'
624-
625-
- store_test_results:
626-
path: __tests__/a11y/xml/
627-
- store_artifacts:
628-
path: __tests__/a11y/xml/
629-
destination: a11y/xml
630-
- store_artifacts:
631-
path: __tests__/a11y/results/
632-
destination: a11y
633-
634-
635584
workflows:
636585
version: 2
637586
CI:
@@ -684,12 +633,6 @@ workflows:
684633
only: /^v\d+\.\d+\.\d+.*/
685634
branches:
686635
ignore: /.*/
687-
- a11y-testing:
688-
context: ux-eng-keys
689-
requires:
690-
# this requirement is to prevent race conditions, but doesn't depend on 'prepare'
691-
- prepare
692-
693636

694637
CI_scheduled:
695638
triggers:

.github/workflows/a11y.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: A11y Testing
2+
3+
on: pull_request
4+
5+
jobs:
6+
prepare-a11y-testing:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- uses: actions/setup-node@v3
13+
# I wanted to use an action, but the action recommends not using itself because
14+
# Since v1.8.0 Playwright includes CLI that installs all required browser dependencies.
15+
- name: Install Playwright dependencies
16+
run: npx playwright install-deps
17+
18+
- name: Show GitHub context
19+
env:
20+
GITHUB_CONTEXT: ${{ toJson(github) }}
21+
run: echo "$GITHUB_CONTEXT"
22+
23+
- name: Install and Build task
24+
run: |
25+
npm ci
26+
npm run build
27+
28+
- name: Build Storybook
29+
run: npm run storybook:build
30+
31+
- name: Cache establish
32+
uses: actions/cache@v2
33+
id: cache
34+
with:
35+
path: ./.www
36+
key: www-cache-${{ github.event.pull_request.head.sha }}
37+
38+
- name: List .www folder
39+
run: ls -la .www
40+
41+
a11y-testing:
42+
needs: prepare-a11y-testing
43+
continue-on-error: ${{ matrix.ignore-error }}
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
test-file-bunch: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
48+
ignore-error: [true]
49+
runs-on: ubuntu-latest
50+
env:
51+
NODE_ENV: development
52+
A11Y_SERVER: http://localhost:9002
53+
54+
steps:
55+
- uses: actions/checkout@v2
56+
57+
- uses: actions/setup-node@v3
58+
59+
- name: Install deps
60+
run: npm ci
61+
62+
- name: Restore cache
63+
uses: actions/cache@v2
64+
id: cache
65+
with:
66+
path: ./.www
67+
key: www-cache-${{ github.event.pull_request.head.sha }}
68+
69+
- name: List the workspace
70+
run: echo "Workspace:" && ls -la .
71+
72+
- name: List the state of cache
73+
run: echo "Cache:" && ls -la .www
74+
75+
- name: Start web server
76+
run: npm run server:bg:start
77+
78+
- name: Generate test files
79+
run: |
80+
npx wait-on --verbose --timeout 10000 ${{ env.A11Y_SERVER }}
81+
npm run test:a11y:generate-tests
82+
83+
- name: Run a11y tests
84+
run: |
85+
npx wait-on --verbose --timeout 10000 ${{ env.A11Y_SERVER }} && curl -sL -w "======================\\nWait-on return code: %{http_code}\\n======================\\n\\n" "${{ env.A11Y_SERVER }}" -o /dev/null
86+
mkdir -p ./__tests__/a11y/xml/
87+
npx ava --tap ./__tests__/a11y/__testfiles__/ava.a11y.${{ matrix.test-file-bunch }}*.spec.js | npx tap-xunit --package="SLDS.a11y" > ./__tests__/a11y/xml/axe-results-${{ matrix.test-file-bunch }}.xml
88+
timeout-minutes: 20
89+
90+
- name: List the test files
91+
if: success() || failure()
92+
run: if test -d __tests__/a11y/results; then echo 'Test Results files:' && ls -la ./__tests__/a11y/results; else echo 'No Test Results'; fi
93+
94+
- name: Stop server
95+
if: always()
96+
run: npm run server:bg:delete
97+
98+
- name: Archive test results
99+
if: success() || failure()
100+
uses: actions/upload-artifact@v3
101+
with:
102+
name: a11y
103+
path: __tests__/a11y/results/
104+
105+
- name: Archive test xml
106+
if: success() || failure()
107+
uses: actions/upload-artifact@v3
108+
with:
109+
name: a11y-xml
110+
path: __tests__/a11y/xml/
111+
112+
# TODO: get it to work from artifacts
113+
- name: Publish Test Results (publish-unit-test-result-action)
114+
uses: EnricoMi/publish-unit-test-result-action@v2
115+
if: success() || failure()
116+
with:
117+
check_name: publish-unit-test-result-action Results
118+
junit_files: "__tests__/a11y/xml/**/*.xml"

0 commit comments

Comments
 (0)