-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (130 loc) · 4.59 KB
/
tests-karma-editor.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
name: Editor Integration Tests
on:
push:
# Only run if editor-related files changed.
paths:
- 'babel.config.cjs'
- 'karma-story-editor.config.cjs'
- 'webpack.config.cjs'
- 'webpack.config.test.cjs'
- 'packages/**/*.js'
- 'packages/**/*.cjs'
- '**/package.json'
- 'package-lock.json'
- '__static__/**'
- '.github/workflows/tests-karma-editor.yml'
branches:
- main
- release/*
pull_request:
# Only run if editor-related files changed.
paths:
- 'babel.config.cjs'
- 'karma-story-editor.config.cjs'
- 'webpack.config.cjs'
- 'webpack.config.test.cjs'
- 'packages/**/*.js'
- 'packages/**/*.cjs'
- '**/package.json'
- 'package-lock.json'
- '__static__/**'
- '.github/workflows/tests-karma-editor.yml'
types:
- opened
- reopened
- synchronize
- ready_for_review
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
nonce:
name: Percy Nonce
runs-on: ubuntu-latest
outputs:
result: ${{ steps.nonce.outputs.result }}
steps:
- id: nonce
run: echo "::set-output name=result::${{ github.run_id }}-$(date +%s)"
karma:
name: Karma (${{ matrix.shard }})
runs-on: ubuntu-latest
timeout-minutes: 60
needs: nonce
strategy:
matrix:
# We want to split up the tests into 4 parts running in parallel.
shard: ['1/4', '2/4', '3/4', '4/4']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
# TODO: Remove need for `npm install puppeteer`.
- name: Install dependencies
run: |
npm ci
npm install puppeteer
env:
PUPPETEER_PRODUCT: chrome
# FIXME: https://github.com/googleforcreators/web-stories-wp/issues/4364
- name: Increase max number of file watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Get Chromium executable path
id: chromium_path
run: |
CHROMIUM=$(node -p "const puppeteer = require('puppeteer'); puppeteer.executablePath();")
echo "::set-output name=chromium_path::${CHROMIUM}"
- name: Run integration tests with Percy
run: |
npx percy exec --parallel --config=percy.config.karma.yml -- \
npm run test:karma:story-editor -- --headless --viewport=1600:1000 --coverage --shard=$SHARD || \
npx percy exec --parallel --config=percy.config.karma.yml -- \
npm run test:karma:story-editor:retry-failed -- --headless --viewport=1600:1000 --shard=$SHARD
env:
DISABLE_ERROR_BOUNDARIES: true
SHARD: ${{ matrix.shard }}
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PERCY_BROWSER_EXECUTABLE: ${{ steps.chromium_path.outputs.chromium_path }}
PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }}
if: github.event.pull_request.draft == false
- name: Run integration tests
run: |
npm run test:karma:story-editor -- --headless --viewport=1600:1000 --coverage --shard=$SHARD || \
npm run test:karma:story-editor:retry-failed -- --headless --viewport=1600:1000 --shard=$SHARD
env:
DISABLE_ERROR_BOUNDARIES: true
SHARD: ${{ matrix.shard }}
if: github.event.pull_request.draft == true
- name: Upload code coverage report
uses: codecov/codecov-action@v3.1.0
with:
file: build/logs/karma-coverage/story-editor/lcov.info
flags: karmatests
percy:
name: Percy
runs-on: ubuntu-latest
timeout-minutes: 5
if: always() && github.event.pull_request.draft == false
needs: [karma, nonce]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
run: npm install @percy/cli
- name: Finalize Percy build
run: npx percy build:finalize
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }}