-
Notifications
You must be signed in to change notification settings - Fork 178
229 lines (203 loc) · 6.48 KB
/
tests-e2e.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
224
225
226
227
228
229
name: E2E Tests
on:
push:
# Don't run for irrelevant changes.
paths-ignore:
- 'docs/**'
- '.storybook/**'
- '.wordpress-org/**'
- '__mocks__/**'
- '__static__/**'
- 'tests/**'
- '**.md'
- '**.yml'
- '**.neon.dist'
- '**.xml.dist'
- 'readme.txt'
- '.editorconfig'
- '.eslint*'
- '.markdownlint*'
- '.phpstorm.meta.php'
- '.prettier*'
- '.stylelint*'
- '.github/workflows/**'
- '!.github/workflows/tests-e2e.yml'
branches:
- main
- release/*
pull_request:
# Don't run for irrelevant changes.
paths-ignore:
- 'docs/**'
- '.storybook/**'
- '.wordpress-org/**'
- '__mocks__/**'
- '__static__/**'
- 'tests/**'
- '**.md'
- '**.yml'
- '**.neon.dist'
- '**.xml.dist'
- 'readme.txt'
- '.editorconfig'
- '.eslint*'
- '.markdownlint*'
- '.phpstorm.meta.php'
- '.prettier*'
- '.stylelint*'
- '.github/workflows/**'
- '!.github/workflows/tests-e2e.yml'
types:
- opened
- reopened
- synchronize
- ready_for_review
permissions:
contents: read
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the (target) branch name.
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build plugin
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- name: Setup Node
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
with:
node-version-file: '.nvmrc'
cache: npm
- name: Setup PHP
uses: shivammathur/setup-php@72ae4ccbe57f82bbe08411e84e2130bd4ba1c10f
with:
php-version: '8.0'
coverage: none
tools: composer
- name: Install dependencies
run: npm ci
env:
PUPPETEER_SKIP_DOWNLOAD: true
- name: Install PHP dependencies
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6
with:
composer-options: '--prefer-dist --no-progress --no-interaction'
- name: Setup Bun
uses: oven-sh/setup-bun@4573031972107e0af692492ee967d9022deafd7b
with:
bun-version: '0.5.9'
- name: Build plugin
run: bun run build:js
env:
# TODO: remove eventually
DISABLE_PREVENT: true
DISABLE_QUICK_TIPS: true
- name: Bundle plugin
run: bun run workflow:build-plugin
- name: Upload bundle
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: web-stories
path: build/web-stories
e2e:
name: '${{ matrix.browser }} - WP ${{ matrix.wp }} (${{ matrix.shard }})'
runs-on: ubuntu-latest
timeout-minutes: 30
continue-on-error: ${{ matrix.experimental == true }}
needs: [build]
strategy:
fail-fast: false
matrix:
# TODO: add back Firefox once support is more mature.
browser: ['chrome']
wp: ['6.1']
snapshots: [false]
experimental: [false]
# We want to split up the tests into 2 parts running in parallel.
shard: ['1/2', '2/2']
include:
- browser: 'chrome'
wp: 'latest'
snapshots: true
shard: '1/2'
- browser: 'chrome'
wp: 'latest'
snapshots: true
shard: '2/2'
steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09
with:
disable-file-monitoring: true
egress-policy: audit
allowed-endpoints: >
github.com:443
objects.githubusercontent.com:443
packagist.org:443
registry.npmjs.org:443
storage.googleapis.com:443
docker.io:443
registry-1.docker.io:443
auth.docker.io:443
34.104.35.123:443
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- name: Download bundle
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: web-stories
# See https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
- name: Install libgbm1
run: sudo apt-get install libgbm1
- name: Setup Node
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
run: npm ci
env:
PUPPETEER_PRODUCT: ${{ matrix.browser }}
- name: Start Docker environment
run: npm run env:start
env:
COMPOSE_INTERACTIVE_NO_CLI: true
WP_VERSION: ${{ matrix.wp }}
- name: Get Chromium executable path
id: chromium_path
run: |
CHROMIUM=$(node -p "const puppeteer = require('puppeteer'); puppeteer.executablePath();")
echo "chromium_path=${CHROMIUM}" >> $GITHUB_ENV
if: ( matrix.snapshots ) && ( github.event.pull_request.draft == false )
- name: Download AMP validator JS
id: amp_validator
run: |
cd $RUNNER_TEMP && curl -O -f -s -S https://cdn.ampproject.org/v0/validator_wasm.js
AMP_VALIDATOR_FILE="${RUNNER_TEMP}/validator_wasm.js"
echo "validator_file=$AMP_VALIDATOR_FILE" >> $GITHUB_ENV
- name: Run E2E tests
run: npm run test:e2e -- --shard=$SHARD
env:
WP_VERSION: ${{ matrix.wp }}
SHARD: ${{ matrix.shard }}
AMP_VALIDATOR_FILE: ${{ env.validator_file }}
- name: Stop Docker environment
run: npm run env:stop
if: always()
env:
COMPOSE_INTERACTIVE_NO_CLI: true
- name: Upload artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
if: always()
with:
name: failures-artifacts
path: build/e2e-artifacts
if-no-files-found: ignore