forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (107 loc) · 4.48 KB
/
lighthouse_accessibility.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
name: Lighthouse CI accessibility tests
on:
merge_group:
types: [checks_requested]
push:
branches:
- develop
- release-*
pull_request:
branches:
- develop
- release-*
jobs:
check_test_suites_to_run:
uses: ./.github/workflows/check_test_suites_to_run.yml
lighthouse_accessibility:
needs: check_test_suites_to_run
if: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).lighthouse_accessibility.count > 0 }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
suite: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).lighthouse_accessibility.suites }}
name: lighthouse_accessibility (${{ matrix.os }}, ${{ matrix.suite.name }})
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
- name: Merge develop branch into the current branch
uses: ./.github/actions/merge
# Caching is disabled to avoid poisoning our cache with the
# changed lighthouse file.
#
# - name: Cache node modules
# uses: actions/cache@v3
# env:
# cache-name: cache-node-modules
# with:
# path: /home/runner/work/oppia/yarn_cache
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# ${{ runner.os }}-
- name: Install Oppia dependencies
uses: ./.github/actions/install-oppia-dependencies
- name: Increase lighthouse timeout
run: |
# Replace the 1.5 second timeout in lighthouse for retrieving
# sourcemaps with a 10 second timeout. This timeout is not
# configurable through Lighthouse's exposed API, so we have
# resorted to patching the code instead.
set -e
FILEPATH=$GITHUB_WORKSPACE/node_modules/lighthouse/lighthouse-core/gather/gatherers/source-maps.js
SEARCH_TARGET="1500"
REPLACEMENT="10000"
occurrences=$(grep -c $SEARCH_TARGET $FILEPATH)
echo "Found $occurrences occurrences of '$SEARCH_TARGET'"
# Assert that there is only one match for the target string.
# If there are ever zero or multiple matches, the lighthouse
# code has changed and this logic needs to be reviewed.
[[ $occurrences == "1" ]]
# Replace the target string with the replacement string.
sed -i 's/$SEARCH_TARGET/$REPLACEMENT/' $FILEPATH
echo "Replaced '$SEARCH_TARGET' with '$REPLACEMENT' in $FILEPATH"
shell: bash
- name: Install chrome
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
run: python -m scripts.install_chrome_for_ci
- name: Run Lighthouse accessibility checks shard ${{ matrix.suite.name }}
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
run: python -m scripts.run_lighthouse_tests --mode accessibility --pages ${{ join(matrix.suite.pages_to_run, ',') }}
- name: Report failure if failed on oppia/oppia develop branch
if: ${{ failure() && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}}
uses: ./.github/actions/send-webhook-notification
with:
message: "A Lighthouse test failed on the upstream develop branch."
webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }}
check_lighthouse_accessibility_workflow_status:
needs: [check_test_suites_to_run, lighthouse_accessibility]
if: always()
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
- name: Merge develop branch into the current branch
uses: ./.github/actions/merge
- name: Check workflow status
uses: ./.github/actions/check-workflow-status
id: check_workflow_status
with:
jobs: ${{ toJson(needs) }}
- name: Fail if workflow status is failure
if: ${{ steps.check_workflow_status.outputs.WORKFLOW_STATUS == 'failure' }}
run: exit 1