forked from percy/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (187 loc) · 6.33 KB
/
Copy pathtest.yml
File metadata and controls
189 lines (187 loc) · 6.33 KB
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
name: Test
on:
push:
branches: [master]
# Version-bump PRs change only lerna.json + packages/*/package.json and have no
# code to test, so the heavy suite is skipped entirely — the workflow doesn't run,
# so no Build/Test/Regression checks appear. Any PR touching source (or yarn.lock)
# still runs the full suite. These checks aren't required, so skipped PRs aren't
# left pending. (PER-9560)
pull_request:
paths-ignore:
- 'lerna.json'
- 'packages/*/package.json'
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v3
with:
node-version: 14
- uses: actions/cache@v3
with:
path: |
node_modules
packages/*/node_modules
packages/core/.local-chromium
key: >
${{ runner.os }}/node-14/
${{ hashFiles('.github/.cache-key') }}/
${{ hashFiles('**/yarn.lock') }}
restore-keys: >
${{ runner.os }}/node-14/
${{ hashFiles('.github/.cache-key') }}/
- run: yarn
- run: yarn build
- uses: actions/upload-artifact@v4
with:
name: dist
path: packages/*/dist
test:
name: Test ${{ matrix.package }}
needs: [build]
strategy:
matrix:
os: [ubuntu-latest]
node: [14]
package:
- '@percy/env'
- '@percy/client'
- '@percy/dom'
- '@percy/logger'
- '@percy/config'
- '@percy/core'
- '@percy/cli'
- '@percy/cli-command'
- '@percy/cli-exec'
- '@percy/cli-snapshot'
- '@percy/cli-upload'
- '@percy/cli-build'
- '@percy/cli-config'
- '@percy/sdk-utils'
- '@percy/webdriver-utils'
- '@percy/monitoring'
- '@percy/cli-doctor'
runs-on: ${{ matrix.os }}
# Collect failed node-test spec names so retries re-run only the specs that
# flaked instead of the whole suite. Non-PERCY_ name so it doesn't trip
# cli-doctor's env-audit tests. See PER-9011.
env:
CLI_TEST_FAILURES_FILE: ${{ github.workspace }}/.cli-test-failures.json
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: actions/cache@v3
with:
path: |
node_modules
packages/*/node_modules
packages/core/.local-chromium
key: >
${{ runner.os }}/node-${{ matrix.node }}/
${{ hashFiles('.github/.cache-key') }}/
${{ hashFiles('**/yarn.lock') }}
restore-keys: >
${{ runner.os }}/node-${{ matrix.node }}/
${{ hashFiles('.github/.cache-key') }}/
- uses: actions/download-artifact@v5
with:
name: dist
path: packages
- run: yarn
- name: Install browser dependencies
run: |
sudo apt-get update
sudo apt-get install -y --fix-missing libgbm-dev
if: ${{ matrix.os == 'ubuntu-latest' }}
# First attempt runs the full suite WITH coverage (enforces the 100%
# gate) and records any failed specs.
- name: Run tests
continue-on-error: true
id: retry0
run: yarn workspace ${{ matrix.package }} test:coverage --colors
# Retries re-run ONLY the specs that failed in the previous attempt, and
# WITHOUT coverage (a subset can't hit the 100% threshold). If retry0
# failed with no recorded spec failures (e.g. a real coverage drop), the
# runner preserves that failure instead of masking it. See PER-9011.
- name: Run tests Retry (1/4)
continue-on-error: true
id: retry1
if: steps.retry0.outcome=='failure'
env:
CLI_TEST_ONLY_FAILED: '1'
run: yarn workspace ${{ matrix.package }} test --colors
- name: Run tests Retry (2/4)
continue-on-error: true
id: retry2
if: steps.retry1.outcome=='failure'
env:
CLI_TEST_ONLY_FAILED: '1'
run: yarn workspace ${{ matrix.package }} test --colors
- name: Run tests Retry (3/4)
continue-on-error: true
id: retry3
if: steps.retry2.outcome=='failure'
env:
CLI_TEST_ONLY_FAILED: '1'
run: yarn workspace ${{ matrix.package }} test --colors
- name: Run tests Retry (4/4)
id: retry4
if: steps.retry3.outcome=='failure'
env:
CLI_TEST_ONLY_FAILED: '1'
run: yarn workspace ${{ matrix.package }} test --colors
# Keep "green via retry" honest: surface a warning whenever the first
# attempt failed and a retry recovered it, so flakiness stays visible.
- name: Flag flaky tests
if: steps.retry0.outcome=='failure'
run: echo "::warning title=Flaky tests::${{ matrix.package }} flaked on the first attempt and was recovered by a spec-level retry (tracked in PER-9011)."
regression:
name: Regression
needs: [build]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 50
- uses: actions/setup-node@v3
with:
node-version: 14
- uses: actions/cache@v3
with:
path: |
node_modules
packages/*/node_modules
packages/core/.local-chromium
key: >
${{ runner.os }}/node-14/
${{ hashFiles('.github/.cache-key') }}/
${{ hashFiles('**/yarn.lock') }}
restore-keys: >
${{ runner.os }}/node-14/
${{ hashFiles('.github/.cache-key') }}/
- uses: actions/download-artifact@v5
with:
name: dist
path: packages
- run: yarn
- name: Install browser dependencies
run: |
sudo apt-get update
sudo apt-get install -y --fix-missing libgbm-dev
- name: Set up @percy/cli
run: |
PERCY_PACKAGES=$(find packages -mindepth 1 -maxdepth 1 -type d | sed -e 's/packages/@percy/g' | tr '\n' ' ')
yarn global:link
yarn link `echo $PERCY_PACKAGES`
npx percy --version
- name: Run regression tests
run: yarn test:regression
env:
PERCY_TOKEN: ${{ secrets.PERCY_REGRESSION_TOKEN }}