Skip to content

Commit 1744527

Browse files
authored
test(wtr): improve reliability (#5581)
* test(wtr): add coverage reports * chore(ci): always upload coverage * test(wtr): improve concurrency hope it's not too flaky * chore(wtr): lower coverage thresholds * chore(wtr): lower hydration coverage thresholds * test(wtr): fix concurrency * chore(ci): cache playwright deps * chore(ci): maybe fix version check * chore: debug * chore: debug * chore: debug * chore: fix playwright version detection * chore(wtr): change default dir to monorepo root * chore(ci): clean up coverage * test(wtr): revert concurrency not that reliable * chore(ci): always do playwright install * chore(ci): actually, who cares about coverage reports * chore(ci): time out playwright install * chore(ci): refine timeout * chore: okay 3 minutes * chore(ci): try again on flaky steps * chore(ci): try to make conditions work * chore(ci): don't fail CI if flaky steps fail first time * test(wtr): enable all tests * chore(ci): give playwright retry an extra minute * chore(ci): restore coverage reports
1 parent a7ed04d commit 1744527

File tree

3 files changed

+71
-13
lines changed

3 files changed

+71
-13
lines changed

.github/workflows/web-test-runner.yml

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,8 @@ env:
1414
COVERAGE: '1'
1515
NODE_VERSION: '20.19.4'
1616

17-
defaults:
18-
run:
19-
working-directory: packages/@lwc/integration-not-karma
20-
2117
jobs:
2218
# We run tests in parallel to speed up CI, with an arbitrary goal of ~20 minutes per job.
23-
# TODO: upload result artifacts
24-
2519
integration-tests:
2620
name: Integration tests (${{ matrix.shadow_mode }} shadow; ${{ matrix.env || 'default env' }})
2721
runs-on: ubuntu-22.04
@@ -71,12 +65,33 @@ jobs:
7165
node-version: ${{ env.NODE_VERSION }}
7266
cache: 'yarn'
7367

68+
- name: Get installed playwright version
69+
id: playwright-version
70+
run: |
71+
version="$(yarn --silent --json list --depth 0 playwright 2>/dev/null | jq -r '.data.trees[0].name|split("@")[1]')"
72+
echo "version=$version" >> "$GITHUB_OUTPUT"
73+
74+
- name: Restore playwright cache
75+
uses: actions/cache@v4
76+
with:
77+
path: |
78+
~/.cache/ms-playwright
79+
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
80+
7481
- name: Install dependencies
7582
run: yarn install --frozen-lockfile
76-
working-directory: ./
7783

7884
- name: Install playwright dependencies
85+
id: install-playwright
86+
continue-on-error: true
7987
run: yarn playwright install chrome firefox webkit --with-deps
88+
timeout-minutes: 3 # Sometimes seems to just hang forever? :|
89+
90+
# If installing playwright times out, wait 1 minute then try again
91+
- name: Install playwright dependencies (fallback)
92+
if: ${{ steps.install-playwright.outcome != 'success' }}
93+
run: sleep 60 && yarn playwright install chrome firefox webkit --with-deps
94+
timeout-minutes: 4
8095

8196
- name: Set env vars
8297
run: echo '${{ matrix.env }}' | tr ' ' '\n' >> "$GITHUB_ENV"
@@ -93,13 +108,24 @@ jobs:
93108
echo "NODE_ENV_FOR_TEST=$NODE_ENV_FOR_TEST"
94109
95110
- name: Run integration tests
111+
id: test-integration
112+
continue-on-error: true
96113
run: yarn test
114+
working-directory: packages/@lwc/integration-not-karma
115+
116+
# Because sometimes things are flaky
117+
- name: Run integration tests (fallback)
118+
if: ${{ steps.test-integration.outcome == 'failure' }}
119+
run: yarn run test
120+
working-directory: packages/@lwc/integration-not-karma
97121

98122
- name: Upload coverage report
99123
# Upload coverage even if the test step failed
100124
if: always()
101125
run: |
102-
[ -f coverage/index.html ] && awk '/<table/,/<\/table>/' coverage/index.html >> "$GITHUB_STEP_SUMMARY"
126+
if [ -f coverage/index.html ]; then
127+
awk '/<table/,/<\/table>/' coverage/index.html >> "$GITHUB_STEP_SUMMARY"
128+
fi
103129
104130
hydration-tests:
105131
name: Hydration tests (${{ matrix.engine_server && 'engine-server' || 'SSR v2' }}; ${{ matrix.env || 'default env' }})
@@ -134,12 +160,33 @@ jobs:
134160
node-version: ${{ env.NODE_VERSION }}
135161
cache: 'yarn'
136162

163+
- name: Get installed playwright version
164+
id: playwright-version
165+
run: |
166+
version="$(yarn --silent --json list --depth 0 playwright 2>/dev/null | jq -r '.data.trees[0].name|split("@")[1]')"
167+
echo "version=$version" >> "$GITHUB_OUTPUT"
168+
169+
- name: Restore playwright cache
170+
uses: actions/cache@v4
171+
with:
172+
path: |
173+
~/.cache/ms-playwright
174+
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
175+
137176
- name: Install dependencies
138177
run: yarn install --frozen-lockfile
139-
working-directory: ./
140178

141179
- name: Install playwright dependencies
180+
id: install-playwright
181+
continue-on-error: true
142182
run: yarn playwright install chrome firefox webkit --with-deps
183+
timeout-minutes: 3 # Sometimes seems to just hang forever? :|
184+
185+
# If installing playwright times out, wait 1 minute then try again
186+
- name: Install playwright dependencies (fallback)
187+
if: ${{ steps.install-playwright.outcome != 'success' }}
188+
run: sleep 60 && yarn playwright install chrome firefox webkit --with-deps
189+
timeout-minutes: 4
143190

144191
- name: Set env vars
145192
run: echo '${{ matrix.env }}' | tr ' ' '\n' >> "$GITHUB_ENV"
@@ -154,10 +201,21 @@ jobs:
154201
echo "ENGINE_SERVER=$ENGINE_SERVER"
155202
156203
- name: Run hydration tests
157-
run: yarn test:hydration
204+
id: test-hydration
205+
continue-on-error: true
206+
run: yarn run test:hydration
207+
working-directory: packages/@lwc/integration-not-karma
208+
209+
# Because sometimes things are flaky
210+
- name: Run hydration tests (fallback)
211+
if: ${{ steps.test-hydration.outcome == 'failure' }}
212+
run: yarn run test:hydration
213+
working-directory: packages/@lwc/integration-not-karma
158214

159215
- name: Upload coverage report
160216
# Upload coverage even if the test step failed
161217
if: always()
162218
run: |
163-
[ -f coverage/index.html ] && awk '/<table/,/<\/table>/' coverage/index.html >> "$GITHUB_STEP_SUMMARY"
219+
if [ -f coverage/index.html ]; then
220+
awk '/<table/,/<\/table>/' coverage/index.html >> "$GITHUB_STEP_SUMMARY"
221+
fi

packages/@lwc/integration-not-karma/configs/hydration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const baseConfig = createConfig({
1212
/** @type {import("@web/test-runner").TestRunnerConfig} */
1313
export default {
1414
...baseConfig,
15-
files: ['test-hydration/**/*.spec.js', '!test-hydration/synthetic-shadow/index.spec.js'],
15+
files: ['test-hydration/**/*.spec.js'],
1616
plugins: [...baseConfig.plugins, hydrationTestPlugin],
1717
coverageConfig: {
1818
...baseConfig.coverageConfig,

packages/@lwc/integration-not-karma/configs/integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const baseConfig = createConfig({
1313
/** @type {import("@web/test-runner").TestRunnerConfig} */
1414
export default {
1515
...baseConfig,
16-
files: ['test/**/*.spec.js', '!test/custom-elements/index.spec.js'],
16+
files: ['test/**/*.spec.js'],
1717
plugins: [
1818
...baseConfig.plugins,
1919
// Only used for the `sanitizeAttribute` test

0 commit comments

Comments
 (0)