Skip to content

Commit 9e25de9

Browse files
committed
test: Improve test tooling
1 parent 314c5da commit 9e25de9

File tree

10 files changed

+70649
-144
lines changed

10 files changed

+70649
-144
lines changed

.github/workflows/build_test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,19 @@ jobs:
4343
./wpt/wpt manifest
4444
./wpt/wpt serve --inject-script=${{ github.workspace }}/dist/container-query-polyfill.modern.js &
4545
npm test
46+
ret=$(node --loader ts-node/esm ./tests/diff.ts)
47+
npm run prettier:fix
48+
cat ./tests/pr.txt >> $GITHUB_STEP_SUMMARY
49+
if [ $ret == "changed" ]; then
50+
exit 1
51+
fi
52+
- uses: actions/upload-artifact@v3
53+
with:
54+
name: baseline.json
55+
path: ./tests/baseline.json
56+
if: failure()
57+
- uses: actions/upload-artifact@v3
58+
with:
59+
name: results.json
60+
path: ./tests/results.json
61+
if: failure()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: release-please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-please:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: google-github-actions/release-please-action@v3
13+
id: release
14+
with:
15+
release-type: node
16+
package-name: container-query-polyfill
17+
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: '16.x'
22+
if: ${{ steps.release.outputs.release_created }}
23+
- run: npm install
24+
if: ${{ steps.release.outputs.release_created }}
25+
- run: npm run build
26+
if: ${{ steps.release.outputs.release_created }}
27+
28+
- uses: actions/setup-node@v3
29+
with:
30+
node-version: '16.x'
31+
registry-url: 'https://wombat-dressing-room.appspot.com/'
32+
if: ${{ steps.release.outputs.release_created }}
33+
- run: npm publish
34+
env:
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"name": "container-query-polyfill",
33
"version": "1.0.0",
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",

src/wpt.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ export function initializeForWPT() {
2121
return new Promise<void>(resolve => {
2222
requestAnimationFrame(() => {
2323
requestAnimationFrame(() => {
24-
resolve();
24+
requestAnimationFrame(() => {
25+
requestAnimationFrame(() => {
26+
requestAnimationFrame(() => {
27+
resolve();
28+
});
29+
});
30+
});
2531
});
2632
});
2733
});

0 commit comments

Comments
 (0)