From 62f86f24098a7740aa50d956cef2d68dcfcea654 Mon Sep 17 00:00:00 2001 From: leftibot Date: Sat, 11 Apr 2026 16:00:52 -0600 Subject: [PATCH] Fix #6: Add WASM playground with hourly artifact sync Add a GitHub Actions workflow that runs hourly to download the latest chaiscript.js and chaiscript.wasm from the ChaiScript/ChaiScript wasm-latest release and commit them to the playground/ directory. Create an interactive playground page matching the site's existing Jekyll/Bootstrap design, with a code editor and output panel powered by the Emscripten WASM build. Add a Playground link to the site navigation. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/update-wasm.yml | 46 +++++++ _includes/header.html | 3 + playground.html | 196 ++++++++++++++++++++++++++++++ test_playground.sh | 51 ++++++++ 4 files changed, 296 insertions(+) create mode 100644 .github/workflows/update-wasm.yml create mode 100644 playground.html create mode 100644 test_playground.sh diff --git a/.github/workflows/update-wasm.yml b/.github/workflows/update-wasm.yml new file mode 100644 index 0000000..ebb2e7d --- /dev/null +++ b/.github/workflows/update-wasm.yml @@ -0,0 +1,46 @@ +name: Update WASM Playground + +on: + schedule: + - cron: '17 * * * *' + workflow_dispatch: + +permissions: + contents: write + +jobs: + update-wasm: + name: Pull latest WASM artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Download WASM release assets + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mkdir -p playground + gh release download wasm-latest \ + --repo ChaiScript/ChaiScript \ + --pattern 'chaiscript.js' \ + --pattern 'chaiscript.wasm' \ + --dir playground \ + --clobber + + - name: Check for changes + id: changes + run: | + git add playground/ + if git diff --cached --quiet; then + echo "changed=false" >> "$GITHUB_OUTPUT" + else + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Commit and push + if: steps.changes.outputs.changed == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -m "Update WASM playground artifacts from ChaiScript/ChaiScript" + git push diff --git a/_includes/header.html b/_includes/header.html index e708a4d..f134859 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -26,6 +26,9 @@
  • Examples
  • +
  • + Playground +
  • Cheatsheet
  • diff --git a/playground.html b/playground.html new file mode 100644 index 0000000..db7ac52 --- /dev/null +++ b/playground.html @@ -0,0 +1,196 @@ +--- +title: Playground +--- + + + + + + +ChaiScript - Interactive Playground +{% include common.html %} + + + + + + + +{% include header.html %} + +
    +

    Interactive Playground Loading…

    +

    Write ChaiScript code and run it directly in your browser using WebAssembly.

    +
    + +
    +
    +
    +
    Input
    + +
    +
    +
    +
    Output
    +
    +
    +
    + +
    + + + Ctrl+Enter to run +
    +
    + + + + + diff --git a/test_playground.sh b/test_playground.sh new file mode 100644 index 0000000..524659a --- /dev/null +++ b/test_playground.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Regression test for issue #6: WASM playground +# Validates that all required files exist and contain expected content. +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "$0")" && pwd)" +FAIL=0 + +assert_file_exists() { + if [ ! -f "$REPO_ROOT/$1" ]; then + echo "FAIL: $1 does not exist" + FAIL=1 + else + echo "PASS: $1 exists" + fi +} + +assert_file_contains() { + if ! grep -q "$2" "$REPO_ROOT/$1" 2>/dev/null; then + echo "FAIL: $1 does not contain '$2'" + FAIL=1 + else + echo "PASS: $1 contains '$2'" + fi +} + +# 1. GitHub Actions workflow exists and runs hourly +assert_file_exists ".github/workflows/update-wasm.yml" +assert_file_contains ".github/workflows/update-wasm.yml" "schedule" +assert_file_contains ".github/workflows/update-wasm.yml" "cron:" +assert_file_contains ".github/workflows/update-wasm.yml" "wasm-latest" +assert_file_contains ".github/workflows/update-wasm.yml" "ChaiScript/ChaiScript" + +# 2. Playground page exists with required elements +assert_file_exists "playground.html" +assert_file_contains "playground.html" "chaiscript.js" +assert_file_contains "playground.html" "Module" +assert_file_contains "playground.html" "header.html" + +# 3. Navigation includes playground link +assert_file_contains "_includes/header.html" "playground" + +if [ "$FAIL" -ne 0 ]; then + echo "" + echo "RESULT: SOME TESTS FAILED" + exit 1 +fi + +echo "" +echo "RESULT: ALL TESTS PASSED" +exit 0