Skip to content

Commit 4f8debd

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

File tree

7 files changed

+99
-69
lines changed

7 files changed

+99
-69
lines changed

.github/workflows/build_test.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ jobs:
4242
npm run serve &
4343
./wpt/wpt manifest
4444
./wpt/wpt serve --inject-script=${{ github.workspace }}/dist/container-query-polyfill.modern.js &
45+
echo "Running tests..."
4546
npm test
4647
47-
- name: Open Pull Request
48-
env:
49-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
- name: Generate diffs
49+
run: node --loader ts-node/esm ./tests/diff.ts
50+
51+
- name: Update baseline
52+
if: failure()
5053
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
54+
echo -e "\n# Updated Baseline\n\n```json\n" >> ./tests/pr.txt
55+
cat ./tests/baseline.json >> ./tests/pr.txt
56+
echo -e "\n```" >> ./tests/pr.txt
57+
58+
- name: Update summary
59+
cat ./tests/pr.txt >> $GITHUB_STEP_SUMMARY

.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: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
set +x
53+
54+
node --loader ts-node/esm ./tests/diff.ts
55+
ret=$?
56+
if [ $ret -eq 0 ]; then
57+
exit 0
58+
fi
59+
npm run prettier:fix
60+
git config user.name github-actions[bot]
61+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
62+
git checkout -b update-wpt-baseline-$(date +"%Y-%m-%d")
63+
git add ./tests/baseline.json
64+
git commit -m "Update Web Platform Test baseline"
65+
git push -u origin HEAD
66+
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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ for (const test of allTestNames) {
224224
let summary: string | null = null;
225225

226226
if (!after) {
227-
summary = '(Removed)';
227+
summary = '(removed)';
228228
} else {
229229
const diffLines: string[] = [];
230230
for (const browser of allBrowsers) {
@@ -284,9 +284,12 @@ ${testSummary.join('\n')}
284284

285285
if (summaryLines.length > 0) {
286286
const commentLines: string[] = [];
287-
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.'
289-
);
287+
288+
if (process.env.SCHEDULED_BASELINE_DIFF) {
289+
commentLines.push(
290+
'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.'
291+
);
292+
}
290293

291294
if (missingBrowsers.size > 0) {
292295
commentLines.push(
@@ -305,9 +308,12 @@ if (summaryLines.length > 0) {
305308
}
306309

307310
commentLines.push('', '# Test Results', ...summaryLines);
311+
308312
await writeFile(getPathForFile('pr.txt'), commentLines.join('\n'));
309313
await writeFile(
310314
getPathForFile('baseline.json'),
311315
JSON.stringify(currentTestMap)
312316
);
317+
318+
process.exit(1);
313319
}

tests/wpt.ts

Lines changed: 0 additions & 49 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/[email protected]/chrome.svg',
@@ -293,7 +249,6 @@ async function getTests(manifestPath: string): Promise<TestSuite> {
293249

294250
return {
295251
js: Object.keys(htmlTests)
296-
.filter(name => !TEST_FILTERS.some(filter => filter.test(name)))
297252
.map(name => `http://web-platform.test:8000/${prefix}/${name}`),
298253
iframe,
299254
};
@@ -419,9 +374,6 @@ async function main() {
419374
const testURL = new URL(test[0]);
420375
if (Array.isArray(test) && Array.isArray(test[1].tests)) {
421376
for (const subtest of test[1].tests) {
422-
if (SUBTEST_FILTERS.some(filter => filter.test(subtest.name))) {
423-
continue;
424-
}
425377
const result = {test: testURL.pathname, subtest: subtest.name};
426378
const destination =
427379
subtest.status === subtest.PASS ? passed : failed;
@@ -450,7 +402,6 @@ async function main() {
450402
join(dirname(fileURLToPath(import.meta.url)), 'results.json'),
451403
output
452404
);
453-
console.warn(output);
454405
}
455406

456407
try {

0 commit comments

Comments
 (0)