|
| 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