diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index c02cd1d..8cf4b7f 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -53,15 +53,18 @@ jobs: id: pages uses: actions/configure-pages@v6 - # The playground's two assets are build artifacts, never committed: the - # wasm compiled from playground/ at this commit, and wasm_exec.js taken - # from the SAME toolchain (the two must match). Built before Hugo, which - # reads the wasm's size for the loader's progress bar. + # The playground's three assets are build artifacts, never committed: the + # wasm compiled from playground/ at this commit, the Ruby tab's + # interpreter (go-embedded-ruby at the version playground/rubywasm/go.mod + # pins), and wasm_exec.js taken from the SAME toolchain (all must match). + # Built before Hugo, which reads the two wasm sizes for the progress bars. - name: Setup Go uses: actions/setup-go@v7 with: go-version: "1.27.2" - cache-dependency-path: playground/go.sum + cache-dependency-path: | + playground/go.sum + playground/rubywasm/go.sum - name: Build the playground working-directory: playground @@ -75,6 +78,18 @@ jobs: -o ../static/playground/playground.wasm ./cmd/playground-wasm cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" ../static/playground/ + # Fetched by the page only when a visitor opens the Ruby tab. + - name: Build go-embedded-ruby for the Ruby tab + working-directory: playground/rubywasm + env: + GOWORK: "off" + GOTOOLCHAIN: local + run: | + GOOS=js GOARCH=wasm go build -trimpath -ldflags "-s -w" \ + -o ../../static/playground/rbgo.wasm github.com/go-embedded-ruby/ruby/cmd/wasm + raw=$(stat -c %s ../../static/playground/rbgo.wasm); gz=$(gzip -9 -c ../../static/playground/rbgo.wasm | wc -c) + echo "rbgo.wasm ($(go list -m -f '{{.Version}}' github.com/go-embedded-ruby/ruby)): $raw bytes, $gz gzipped" | tee -a "$GITHUB_STEP_SUMMARY" + - name: Build env: HUGO_ENVIRONMENT: production diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index 6e9f2b2..47171b1 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -12,8 +12,10 @@ # and dark forced, 1x and 2x, plus a phone (390x844 at 3x, # mobile, touch): real clicks and keys, asserted on the app's # state AND on canvas pixels, and the canvas must fit the -# viewport width. A missing browser is a -# failure here, never a skip. +# viewport width. The Ruby tab: go-embedded-ruby is fetched +# only once the tab is opened (requests counted), and the +# README example run in Ruby prints go-ndarray's shape and +# values. A missing browser is a failure here, never a skip. name: playground on: @@ -102,7 +104,9 @@ jobs: - uses: actions/setup-go@v7 with: go-version: "1.27.2" - cache-dependency-path: playground/go.sum + cache-dependency-path: | + playground/go.sum + playground/rubywasm/go.sum - uses: actions/setup-node@v7 with: node-version: "24" @@ -118,12 +122,24 @@ jobs: install-dependencies: true - name: install puppeteer-core run: npm install --no-save --prefix "${{ runner.temp }}/pptr" puppeteer-core@24.43.1 + # The Ruby tab's interpreter, built as the deploy builds it, once for both + # Ruby checks below. + - name: build go-embedded-ruby (js/wasm) + working-directory: playground/rubywasm + run: | + GOOS=js GOARCH=wasm go build -trimpath -ldflags "-s -w" -o "$RUNNER_TEMP/rbgo.wasm" github.com/go-embedded-ruby/ruby/cmd/wasm + raw=$(stat -c %s "$RUNNER_TEMP/rbgo.wasm"); gz=$(gzip -9 -c "$RUNNER_TEMP/rbgo.wasm" | wc -c) + echo "rbgo.wasm ($(go list -m -f '{{.Version}}' github.com/go-embedded-ruby/ruby)): $raw bytes, $gz gzipped" | tee -a "$GITHUB_STEP_SUMMARY" - name: run the proof env: CHROME: ${{ steps.chrome.outputs.chrome-path }} PLAYGROUND_NODE_PATH: ${{ runner.temp }}/pptr/node_modules PLAYGROUND_CAPTURE_DIR: ${{ runner.temp }}/captures - run: go test -count=1 -v -run TestBrowserProof . + PLAYGROUND_RUBY_WASM: ${{ runner.temp }}/rbgo.wasm + # TestRubyAgreesWithGo runs every operation's Ruby program on the + # interpreter. The proof downloads its ~100 MB twice in Chrome: give the + # run more than go test's 10 minutes. + run: go test -count=1 -timeout 30m -v -run 'TestBrowserProof|TestRubyAgreesWithGo' . ./engine - name: keep the screenshots if: always() uses: actions/upload-artifact@v7 diff --git a/.gitignore b/.gitignore index 594d8e6..09e86db 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ resources/ # Built by the pages workflow from playground/ (never committed). static/playground/playground.wasm static/playground/wasm_exec.js +static/playground/rbgo.wasm diff --git a/layouts/_default/playground.html b/layouts/_default/playground.html index 16b95d3..d7291d2 100644 --- a/layouts/_default/playground.html +++ b/layouts/_default/playground.html @@ -4,7 +4,7 @@