Skip to content

Commit b3adcf7

Browse files
committed
feat(automation): Add workflow to vendor and update Test262 tests
This commit introduces a GitHub Actions workflow to automate the vendoring of the Test262 test suite into `third_party/test262`. This automation is the final piece of the integration, ensuring that the tests can be kept up-to-date with the upstream `tc39/test262` repository. The workflow is configured to run weekly or can be triggered manually. It performs the following steps: 1. Checks out both the WPT and `tc39/test262` repositories. 2. Selectively copies a subset of the Test262 tests into WPT. 3. Copies the essential Test262 harness files. 4. Creates a `vendored.toml` file at the root of the vendored directory, recording the specific commit SHA from `tc39/test262` that the files were sourced from. This ensures traceability, as described in the RFC. 5. Commits the updated files and opens a pull request with the changes. Initially, only a subset of Test262 tests related to Interop 2026 features (`Temporal` and `top-level-await`) are being imported. This is a temporary measure to manage the volume of new test results and to avoid overloading wpt.fyi, which currently has limitations in processing the full Test262 result set (see wpt-fyi/issues/4681). The workflow can be expanded to include more tests in the future. This work directly supports the integration of Test262 into WPT as detailed in the RFC: web-platform-tests/rfcs#229 This commit is part of a series of smaller PRs split from the larger, original implementation in #55997.
1 parent 258c427 commit b3adcf7

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Update Test262 tests
2+
3+
on:
4+
# Trigger at every Sunday UTC noon, or manually.
5+
schedule:
6+
- cron: '0 12 * * 0'
7+
workflow_dispatch:
8+
9+
jobs:
10+
update-test262:
11+
runs-on: ubuntu-24.04
12+
steps:
13+
- name: Checkout WPT repo
14+
uses: actions/checkout@v4
15+
with:
16+
path: wpt
17+
- name: Checkout Test262 repo
18+
uses: actions/checkout@v4
19+
with:
20+
repository: tc39/test262
21+
path: test262-spec
22+
- name: Copy Test262 tests to WPT
23+
run: |
24+
LATEST_SHA=$(git -C test262-spec rev-parse HEAD)
25+
echo "Latest remote Test262 SHA: $LATEST_SHA"
26+
27+
rm -rf wpt/third_party/test262/test/
28+
mkdir -p wpt/third_party/test262/test/
29+
mkdir -p wpt/third_party/test262/harness/
30+
31+
# Selectively copy only Interop 2026 feature tests for now
32+
# See: https://github.com/web-platform-tests/wpt.fyi/issues/4681
33+
# Mapping of web feature to test directory can be found at: https://github.com/tc39/test262/blob/main/WEB_FEATURES.yml
34+
# Temporal tests
35+
mkdir -p wpt/third_party/test262/test/built-ins/Date/prototype/toTemporalInstant
36+
mkdir -p wpt/third_party/test262/test/built-ins/Temporal
37+
mkdir -p wpt/third_party/test262/test/intl402/Temporal
38+
cp -r test262-spec/test/built-ins/Date/prototype/toTemporalInstant/* wpt/third_party/test262/test/built-ins/Date/prototype/toTemporalInstant
39+
cp -r test262-spec/test/built-ins/Temporal/* wpt/third_party/test262/test/built-ins/Temporal
40+
cp -r test262-spec/test/intl402/Temporal/* wpt/third_party/test262/test/intl402/Temporal
41+
42+
# Top-level-await tests
43+
mkdir -p wpt/third_party/test262/test/language/module-code/top-level-await
44+
cp -r test262-spec/test/language/module-code/top-level-await/* wpt/third_party/test262/test/language/module-code/top-level-await
45+
46+
# Always sync the harness files
47+
rsync -a --delete test262-spec/harness/ wpt/third_party/test262/harness/
48+
printf "[test262]\nsource = \"https://github.com/tc39/test262\"\nrev = \"${LATEST_SHA}\"\n" > wpt/third_party/test262/vendored.toml
49+
- name: Commit changes
50+
id: commit
51+
continue-on-error: true
52+
run: |
53+
cd wpt
54+
export BRANCH_NAME="$BRANCH_PREFIX-$(date +'%Y%m%d%H%M%S')"
55+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
56+
git config user.name "$GIT_AUTHOR_NAME"
57+
git config user.email "$GIT_AUTHOR_EMAIL"
58+
git checkout -B $BRANCH_NAME
59+
git add third_party/test262/
60+
git commit -m "$COMMIT_TITLE"
61+
env:
62+
GIT_AUTHOR_NAME: "wpt-pr-bot"
63+
GIT_AUTHOR_EMAIL: "wpt-pr-bot@users.noreply.github.com"
64+
BRANCH_PREFIX: "test262-update"
65+
COMMIT_TITLE: "Update Test262 tests"
66+
- name: Create PR
67+
if: ${{ steps.commit.outcome == 'success' }}
68+
run: |
69+
cd wpt
70+
git push --set-upstream origin $BRANCH_NAME
71+
gh pr create --title "$COMMIT_TITLE" --body "$PR_BODY"
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
COMMIT_TITLE: "Update Test262 tests"
75+
PR_BODY: "Scheduled weekly update auto-generated by the '${{ github.workflow }}' workflow."

0 commit comments

Comments
 (0)