Skip to content

Update Wasm tests

Update Wasm tests #96

name: Update Wasm tests
on:
# Trigger at every Sunday UTC noon, or manually.
schedule:
- cron: 0 12 * * 0
workflow_dispatch:
jobs:
build-wpt:
runs-on: ubuntu-24.04
env:
UPSTREAM_REPO: WebAssembly/spec
steps:
- name: Checkout WPT repo
uses: actions/checkout@v7
with:
path: wpt
- name: Checkout Wasm repo
uses: actions/checkout@v7
with:
repository: ${{ env.UPSTREAM_REPO }}
path: wasm-spec
- name: Setup OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 5.04.x
- name: Setup OCaml tools
run: opam install --yes ocamlfind js_of_ocaml js_of_ocaml-ppx
- name: Build interpreter
run: cd wasm-spec/interpreter && opam exec make
- name: Convert WAST tests to WPT
run: wasm-spec/test/build.py --dont-recompile --html wasm-spec/out/
- name: Copy Wasm tests to WPT
# Replace wasm/core entirely, but preserve WEB_FEATURES.yml files.
run: |
rsync -a --delete --exclude 'WEB_FEATURES.yml' wasm-spec/out/ wpt/wasm/core/
- name: Update Wasm proposal tests
run: |
python3 wpt/wasm/tools/update-proposals.py
- 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 wasm/core/ wasm/proposals
CORE_CHANGED=false
git diff --cached --quiet -- wasm/core/ || CORE_CHANGED=true
PROPOSALS_CHANGED=false
git diff --cached --quiet -- wasm/proposals/ || PROPOSALS_CHANGED=true
echo "CORE_CHANGED=$CORE_CHANGED" >> $GITHUB_ENV
echo "PROPOSALS_CHANGED=$PROPOSALS_CHANGED" >> $GITHUB_ENV
UPSTREAM_COMMIT=$(cd ../wasm-spec && git rev-parse HEAD)
UPSTREAM_SHORT=$(cd ../wasm-spec && git -c core.abbrev=auto rev-parse --short HEAD)
echo "UPSTREAM_COMMIT=$UPSTREAM_COMMIT" >> $GITHUB_ENV
echo "UPSTREAM_SHORT=$UPSTREAM_SHORT" >> $GITHUB_ENV
SUFFIX=""
if [ "$CORE_CHANGED" = "true" ] && [ "$PROPOSALS_CHANGED" = "true" ]; then
SUFFIX=" (core, proposals)"
elif [ "$CORE_CHANGED" = "true" ]; then
SUFFIX=" (core)"
elif [ "$PROPOSALS_CHANGED" = "true" ]; then
SUFFIX=" (proposals)"
fi
if [ -n "$SUFFIX" ]; then
git commit -m "Update Wasm tests$SUFFIX"
else
echo "No changes to commit"
false
fi
env:
GIT_AUTHOR_NAME: "wpt-pr-bot"
GIT_AUTHOR_EMAIL: "wpt-pr-bot@users.noreply.github.com"
BRANCH_PREFIX: "wasm-update"
- name: Create PR
# Check outcome for success as continue-on-error will mask failure.
if: ${{ steps.commit.outcome == 'success' }}
run: |
cd wpt
BODY_FILE="pr-body.txt"
echo "Scheduled weekly update." > "$BODY_FILE"
echo "" >> "$BODY_FILE"
echo "Auto-generated by the '$GITHUB_WORKFLOW' workflow." >> "$BODY_FILE"
if [ "$CORE_CHANGED" = "true" ] || [ "$PROPOSALS_CHANGED" = "true" ]; then
echo "" >> "$BODY_FILE"
echo "Source information:" >> "$BODY_FILE"
if [ "$CORE_CHANGED" = "true" ]; then
echo "Core spec: https://github.com/$UPSTREAM_REPO/commit/$UPSTREAM_COMMIT" >> "$BODY_FILE"
fi
if [ "$PROPOSALS_CHANGED" = "true" ] && [ -f wasm/proposals-summary.txt ]; then
if [ "$CORE_CHANGED" = "true" ]; then
echo "" >> "$BODY_FILE"
fi
cat wasm/proposals-summary.txt >> "$BODY_FILE"
fi
fi
git push --set-upstream origin $BRANCH_NAME
gh pr create --title "Update Wasm tests" --body-file "$BODY_FILE"
rm -f "$BODY_FILE"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}