Skip to content

Commit fbf06e6

Browse files
committed
fix: Add weekly baseline testing
1 parent 9546fe1 commit fbf06e6

File tree

7 files changed

+121
-94
lines changed

7 files changed

+121
-94
lines changed

.github/workflows/build_test.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,12 @@ jobs:
4343
./wpt/wpt manifest
4444
./wpt/wpt serve --inject-script=${{ github.workspace }}/dist/container-query-polyfill.modern.js &
4545
npm test
46-
47-
- name: Open Pull Request
48-
env:
49-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
run: |
51-
node --loader ts-node/esm ./tests/diff.ts
52-
git config user.name github-actions[bot]
53-
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
54-
git checkout -b update-wpt-baseline-${{ github.job_id }}
55-
git add ./tests/baseline.json
56-
git commit -m "Update Web Platform Test baseline"
57-
git push -u origin HEAD
58-
gh pr create --title "[Automated] Update Web Platform Tests" --body-file ./tests/pr.txt
46+
ret=$(node --loader ts-node/esm ./tests/diff.ts)
47+
npm run prettier:fix
48+
echo -e "\n# Updated Baseline\n\n```json\n" >> ./tests/pr.txt
49+
cat ./tests/baseline.json >> ./tests/pr.txt
50+
echo -e "\n```" >> ./tests/pr.txt
51+
cat ./tests/pr.txt >> $GITHUB_STEP_SUMMARY
52+
if [ $ret == "changed" ]; then
53+
exit 1
54+
fi

.github/workflows/release-please.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: release-please
33
on:
44
push:
55
branches:
6-
- main
6+
- x-rework-test-results
77

88
jobs:
99
release-please:
@@ -22,6 +22,8 @@ jobs:
2222
if: ${{ steps.release.outputs.release_created }}
2323
- run: npm install
2424
if: ${{ steps.release.outputs.release_created }}
25+
- run: npm run build
26+
if: ${{ steps.release.outputs.release_created }}
2527

2628
- uses: actions/setup-node@v3
2729
with:
@@ -31,4 +33,4 @@ jobs:
3133
- run: npm publish
3234
env:
3335
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
34-
if: ${{ steps.release.outputs.release_created }}
36+
if: ${{ steps.release.outputs.release_created }}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Update WPT Baseline
2+
3+
on:
4+
workflow_dispatch:
5+
branches: [main]
6+
schedule:
7+
- cron: '0 0 * * 1'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
env:
13+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
14+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
15+
WPT_MANIFEST: ${{ github.workspace }}/wpt/MANIFEST.json
16+
SCHEDULED_BASELINE_DIFF: true
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: '16'
22+
- uses: actions/setup-python@v3
23+
with:
24+
python-version: '3.x'
25+
- uses: actions/checkout@v3
26+
with:
27+
repository: devknoll/wpt
28+
path: wpt
29+
ref: x-polyfill-all-tests
30+
31+
- name: Build
32+
run: |
33+
npm install
34+
npm run build:wpt
35+
36+
- name: Setup WPT
37+
run: |
38+
cd wpt
39+
pip install virtualenv
40+
./wpt make-hosts-file | sudo tee -a /etc/hosts
41+
- name: Run Tests
42+
run: |
43+
npm run serve &
44+
./wpt/wpt manifest
45+
./wpt/wpt serve --inject-script=${{ github.workspace }}/dist/container-query-polyfill.modern.js &
46+
npm test
47+
48+
- name: Open Pull Request
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: |
52+
ret=(node --loader ts-node/esm ./tests/diff.ts)
53+
if [ $ret == "unchanged" ]; then
54+
exit 0
55+
fi
56+
npm run prettier:fix
57+
git config user.name github-actions[bot]
58+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
59+
git checkout -b update-wpt-baseline-$(date +"%Y-%m-%d")
60+
git add ./tests/baseline.json
61+
git commit -m "Update Web Platform Test baseline"
62+
git push -u origin HEAD
63+
gh pr create --title "[Automated] Update Web Platform Tests" --body-file ./tests/pr.txt --label "update-baseline"

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
dist/
1+
dist/
2+
wpt/

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"name": "container-query-polyfill",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "",
5-
"repository": "github:GoogleChromeLabs/container-query-polyfill",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/GoogleChromeLabs/container-query-polyfill.git"
8+
},
69
"type": "module",
710
"module": "dist/container-query-polyfill.modern.js",
811
"unpkg": "dist/container-query-polyfill.modern.js",

tests/diff.ts

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ const allTestNames = new Set(
187187
);
188188
const summaryLines: string[] = [];
189189

190+
let hasRegressions = false;
190191
for (const test of allTestNames) {
191192
const currentSubtests = currentTestMap[test];
192193
const previousSubtests = previousTestMap[test];
@@ -224,7 +225,7 @@ for (const test of allTestNames) {
224225
let summary: string | null = null;
225226

226227
if (!after) {
227-
summary = '(Removed)';
228+
summary = '(removed)';
228229
} else {
229230
const diffLines: string[] = [];
230231
for (const browser of allBrowsers) {
@@ -235,6 +236,10 @@ for (const test of allTestNames) {
235236
continue;
236237
}
237238

239+
if (wasPassing && !isPassing) {
240+
hasRegressions = true;
241+
}
242+
238243
const prefix = isPassing ? '+' : '-';
239244
diffLines.push(`${prefix} ${browser}`);
240245
}
@@ -282,32 +287,37 @@ ${testSummary.join('\n')}
282287
}
283288
}
284289

285-
if (summaryLines.length > 0) {
286-
const commentLines: string[] = [];
290+
const commentLines: string[] = [];
291+
if (process.env.SCHEDULED_BASELINE_DIFF) {
287292
commentLines.push(
288-
'The [Web Platform Test](https://web-platform-tests.org/) results have changed from the expected baseline. The baseline may be updated by merging this pull request.'
293+
'The [Web Platform Test](https://web-platform-tests.org/) results have changed from the expected baseline. You may accept these changes by merging this pull request.'
289294
);
295+
}
290296

291-
if (missingBrowsers.size > 0) {
292-
commentLines.push(
293-
'',
294-
`
295-
> **Warning**
296-
> The test run was missing data for the following browsers:
297-
>
298-
${Array.from(missingBrowsers)
299-
.map(browser => `> * ${browser}`)
300-
.join('\n')}
301-
>
302-
> Therefore I couldn't confirm the expected tests are still passing.
303-
`
304-
);
305-
}
306-
307-
commentLines.push('', '# Test Results', ...summaryLines);
308-
await writeFile(getPathForFile('pr.txt'), commentLines.join('\n'));
309-
await writeFile(
310-
getPathForFile('baseline.json'),
311-
JSON.stringify(currentTestMap)
297+
if (missingBrowsers.size > 0) {
298+
commentLines.push(
299+
'',
300+
`
301+
> **Warning**
302+
> The test run was missing data for the following browsers:
303+
>
304+
${Array.from(missingBrowsers)
305+
.map(browser => `> * ${browser}`)
306+
.join('\n')}
307+
>
308+
> The test results for these browsers couldn't be confirmed.
309+
`
312310
);
313311
}
312+
313+
const results =
314+
summaryLines.length > 0 ? summaryLines : ['No changes detected.'];
315+
commentLines.push('', '# Test Results', ...results);
316+
317+
await writeFile(getPathForFile('pr.txt'), commentLines.join('\n'));
318+
await writeFile(
319+
getPathForFile('baseline.json'),
320+
JSON.stringify(currentTestMap)
321+
);
322+
323+
process.stdout.write(hasRegressions ? 'changed' : 'unchanged');

tests/wpt.ts

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -54,50 +54,6 @@ export interface BrowserDefinition {
5454
versions: BrowserVersion[];
5555
}
5656

57-
const TEST_FILTERS: Array<RegExp> = [
58-
/-serialization.html$/,
59-
/-computed.html$/,
60-
/calc-evaluation.html$/,
61-
/auto-scrollbars.html$/,
62-
63-
/container-inheritance.html$/,
64-
/container-for-shadow-dom.html$/,
65-
/container-units-shadow.html$/,
66-
/container-longhand-animation-type.html$/,
67-
/container-name-invalidation.html$/,
68-
/container-name-parsing.html$/,
69-
/container-parsing.html$/,
70-
/container-type-containment.html$/,
71-
/container-type-layout-invalidation.html$/,
72-
/container-type-parsing.html$/,
73-
/container-units-basic.html$/,
74-
/container-units-in-at-container-fallback.html$/,
75-
/container-units-invalidation.html$/,
76-
/container-units-media-queries.html$/,
77-
/container-units-selection.html$/,
78-
/container-units-small-viewport-fallback.html$/,
79-
/container-units-svglength.html$/,
80-
/container-units-typed-om.html$/,
81-
/deep-nested-inline-size-containers.html$/,
82-
/idlharness.html$/,
83-
/iframe-in-container-invalidation.html$/,
84-
/iframe-invalidation.html$/,
85-
/percentage-padding-orthogonal.html$/,
86-
/viewport-units-dynamic.html$/,
87-
/viewport-units.html$/,
88-
];
89-
90-
const SUBTEST_FILTERS: Array<RegExp> = [
91-
/calc\(.*\)/,
92-
/max\(.*\)/,
93-
/style\(.*\)/,
94-
/#container width 399px after padding is applied. #second is removed from the rendering/,
95-
/ex units/,
96-
/ch units/,
97-
/ex relative/,
98-
/ch relative/,
99-
];
100-
10157
const CHROME_DEFINITION: BrowserDefinition = {
10258
name: 'Chrome',
10359
logo: 'https://unpkg.com/@browser-logos/chrome@2.0.0/chrome.svg',
@@ -292,9 +248,9 @@ async function getTests(manifestPath: string): Promise<TestSuite> {
292248
});
293249

294250
return {
295-
js: Object.keys(htmlTests)
296-
.filter(name => !TEST_FILTERS.some(filter => filter.test(name)))
297-
.map(name => `http://web-platform.test:8000/${prefix}/${name}`),
251+
js: Object.keys(htmlTests).map(
252+
name => `http://web-platform.test:8000/${prefix}/${name}`
253+
),
298254
iframe,
299255
};
300256
}
@@ -419,9 +375,6 @@ async function main() {
419375
const testURL = new URL(test[0]);
420376
if (Array.isArray(test) && Array.isArray(test[1].tests)) {
421377
for (const subtest of test[1].tests) {
422-
if (SUBTEST_FILTERS.some(filter => filter.test(subtest.name))) {
423-
continue;
424-
}
425378
const result = {test: testURL.pathname, subtest: subtest.name};
426379
const destination =
427380
subtest.status === subtest.PASS ? passed : failed;
@@ -450,7 +403,6 @@ async function main() {
450403
join(dirname(fileURLToPath(import.meta.url)), 'results.json'),
451404
output
452405
);
453-
console.warn(output);
454406
}
455407

456408
try {

0 commit comments

Comments
 (0)