diff --git a/.github/workflows/update-test262-tests.yml b/.github/workflows/update-test262-tests.yml new file mode 100644 index 00000000000000..e790d86e1808de --- /dev/null +++ b/.github/workflows/update-test262-tests.yml @@ -0,0 +1,75 @@ +name: Update Test262 tests + +on: + # Trigger at every Sunday UTC noon, or manually. + schedule: + - cron: '0 12 * * 0' + workflow_dispatch: + +jobs: + update-test262: + runs-on: ubuntu-24.04 + steps: + - name: Checkout WPT repo + uses: actions/checkout@v4 + with: + path: wpt + - name: Checkout Test262 repo + uses: actions/checkout@v4 + with: + repository: tc39/test262 + path: test262-spec + - name: Copy Test262 tests to WPT + run: | + LATEST_SHA=$(git -C test262-spec rev-parse HEAD) + echo "Latest remote Test262 SHA: $LATEST_SHA" + + rm -rf wpt/third_party/test262/test/ + mkdir -p wpt/third_party/test262/test/ + mkdir -p wpt/third_party/test262/harness/ + + # Selectively copy only Interop 2026 feature tests for now + # See: https://github.com/web-platform-tests/wpt.fyi/issues/4681 + # Mapping of web feature to test directory can be found at: https://github.com/tc39/test262/blob/main/WEB_FEATURES.yml + # Temporal tests + mkdir -p wpt/third_party/test262/test/built-ins/Date/prototype/toTemporalInstant + mkdir -p wpt/third_party/test262/test/built-ins/Temporal + mkdir -p wpt/third_party/test262/test/intl402/Temporal + cp -r test262-spec/test/built-ins/Date/prototype/toTemporalInstant/* wpt/third_party/test262/test/built-ins/Date/prototype/toTemporalInstant + cp -r test262-spec/test/built-ins/Temporal/* wpt/third_party/test262/test/built-ins/Temporal + cp -r test262-spec/test/intl402/Temporal/* wpt/third_party/test262/test/intl402/Temporal + + # Top-level-await tests + mkdir -p wpt/third_party/test262/test/language/module-code/top-level-await + cp -r test262-spec/test/language/module-code/top-level-await/* wpt/third_party/test262/test/language/module-code/top-level-await + + # Always sync the harness files + rsync -a --delete test262-spec/harness/ wpt/third_party/test262/harness/ + printf "[test262]\nsource = \"https://github.com/tc39/test262\"\nrev = \"${LATEST_SHA}\"\n" > wpt/third_party/test262/vendored.toml + - name: Commit changes + id: commit + continue-on-error: true + run: | + cd wpt + export BRANCH_NAME="$BRANCH_PREFIX-$(date +'%Y%m%d%H%M%S')" + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + git config user.name "$GIT_AUTHOR_NAME" + git config user.email "$GIT_AUTHOR_EMAIL" + git checkout -B $BRANCH_NAME + git add third_party/test262/ + git commit -m "$COMMIT_TITLE" + env: + GIT_AUTHOR_NAME: "wpt-pr-bot" + GIT_AUTHOR_EMAIL: "wpt-pr-bot@users.noreply.github.com" + BRANCH_PREFIX: "test262-update" + COMMIT_TITLE: "Update Test262 tests" + - name: Create PR + if: ${{ steps.commit.outcome == 'success' }} + run: | + cd wpt + git push --set-upstream origin $BRANCH_NAME + gh pr create --title "$COMMIT_TITLE" --body "$PR_BODY" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMMIT_TITLE: "Update Test262 tests" + PR_BODY: "Scheduled weekly update auto-generated by the '${{ github.workflow }}' workflow."