From 8ee24bdf113e4046dbae1239b440a62260cc2d06 Mon Sep 17 00:00:00 2001 From: Bikal Gurung Date: Tue, 10 Feb 2026 11:20:53 +0000 Subject: [PATCH 1/5] fix: resolve target symlink and add wasm support for GitHub Pages The target/ symlink to _build/ wasn't preserved by upload-pages-artifact, causing JS module MIME type errors. Build a _site/ directory with resolved symlinks, both JS and wasm-gc targets, and src/webapi.mjs for wasm imports. Also add [js | wasm] links to the examples index. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/pages.yml | 16 ++++++++++++++-- examples/index.html | 28 ++++++++++++++++------------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index f893095..65af118 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -34,17 +34,29 @@ jobs: moon version --all moon update - - name: Build examples + - name: Build examples (JS) working-directory: examples run: moon build --target js --release + - name: Build examples (wasm-gc) + working-directory: examples + run: moon build --target wasm-gc --release + + - name: Prepare site + run: | + mkdir -p _site/src + cp -rL examples _site/examples + rm -rf _site/examples/.mooncakes _site/examples/_build + cp src/webapi.mjs _site/src/ + echo '' > _site/index.html + - name: Setup Pages uses: actions/configure-pages@v5 - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: 'examples' + path: '_site' deploy: environment: diff --git a/examples/index.html b/examples/index.html index f0ea09c..ad3bffd 100644 --- a/examples/index.html +++ b/examples/index.html @@ -9,24 +9,28 @@ h1 { font-weight: 300; letter-spacing: 2px; } ul { list-style: none; padding: 0; } li { margin: 1rem 0; } - a { color: #4a90d9; text-decoration: none; font-size: 1.1rem; } + .name { font-size: 1.1rem; margin-right: 0.5rem; } + a { color: #4a90d9; text-decoration: none; } a:hover { text-decoration: underline; } + .targets { font-size: 0.9rem; } + .targets a { margin: 0 0.15rem; } + .sep { color: #999; }

MoonBit WebAPI Examples

From e04436b00dd42e2c742fd5e8c254ab1fae367fdc Mon Sep 17 00:00:00 2001 From: Bikal Gurung Date: Tue, 10 Feb 2026 11:24:52 +0000 Subject: [PATCH 2/5] ci: merge pages.yml into ci.yml and consolidate jobs Eliminate duplicate runner setups by merging the Pages deployment workflow into CI and folding the examples job into build-test-webapi. Pages steps run conditionally on push to main only. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/ci.yml | 64 +++++++++++++++++++++------------ .github/workflows/pages.yml | 70 ------------------------------------- 2 files changed, 42 insertions(+), 92 deletions(-) delete mode 100644 .github/workflows/pages.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee704f8..3af5655 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,19 @@ on: branches: ["main"] pull_request: branches: ["main"] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false jobs: - check: + build-test-webapi: runs-on: ubuntu-latest steps: - name: Checkout @@ -42,27 +52,6 @@ jobs: working-directory: webapi_gen run: moon test - examples: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up MoonBit - run: | - curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash - echo "$HOME/.moon/bin" >> $GITHUB_PATH - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 22 - - - name: Install MoonBit dependencies - run: | - moon version --all - moon update - - name: Build examples (JS) working-directory: examples run: moon build --target js --release @@ -80,3 +69,34 @@ jobs: - name: Run Playwright tests working-directory: tests run: npx playwright test --workers 2 + + - name: Prepare site + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + run: | + mkdir -p _site/src + cp -rL examples _site/examples + rm -rf _site/examples/.mooncakes _site/examples/_build + cp src/webapi.mjs _site/src/ + echo '' > _site/index.html + + - name: Setup Pages + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/configure-pages@v5 + + - name: Upload pages artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v3 + with: + path: '_site' + + deploy: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build-test-webapi + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml deleted file mode 100644 index 65af118..0000000 --- a/.github/workflows/pages.yml +++ /dev/null @@ -1,70 +0,0 @@ -# Deploy examples to GitHub Pages -name: Deploy to GitHub Pages - -on: - push: - branches: ["main"] - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up MoonBit - run: | - curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash - echo "$HOME/.moon/bin" >> $GITHUB_PATH - - - name: Install MoonBit dependencies - run: | - moon version --all - moon update - - - name: Build examples (JS) - working-directory: examples - run: moon build --target js --release - - - name: Build examples (wasm-gc) - working-directory: examples - run: moon build --target wasm-gc --release - - - name: Prepare site - run: | - mkdir -p _site/src - cp -rL examples _site/examples - rm -rf _site/examples/.mooncakes _site/examples/_build - cp src/webapi.mjs _site/src/ - echo '' > _site/index.html - - - name: Setup Pages - uses: actions/configure-pages@v5 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: '_site' - - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 From c94357627e5f8878079c334f9e8be44d9cc87462 Mon Sep 17 00:00:00 2001 From: Bikal Gurung Date: Tue, 10 Feb 2026 11:28:56 +0000 Subject: [PATCH 3/5] ci: add caching for npm, MoonBit packages, and Playwright browsers Co-Authored-By: Claude Opus 4.6 --- .github/workflows/ci.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3af5655..310e474 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,11 +32,24 @@ jobs: uses: actions/setup-node@v4 with: node-version: 22 + cache: 'npm' + cache-dependency-path: | + webapi_gen/package-lock.json + tests/package-lock.json - name: Install npm dependencies working-directory: webapi_gen run: npm ci + - name: Cache MoonBit packages + uses: actions/cache@v4 + with: + path: | + .mooncakes + webapi_gen/.mooncakes + examples/.mooncakes + key: mooncakes-${{ runner.os }}-${{ hashFiles('moon.mod.json', 'webapi_gen/moon.mod.json', 'examples/moon.mod.json') }} + - name: Install MoonBit dependencies run: | moon version --all @@ -60,11 +73,18 @@ jobs: working-directory: examples run: moon build --target wasm-gc --release + - name: Cache Playwright browsers + id: cache-playwright + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ hashFiles('tests/package-lock.json') }} + - name: Install Playwright dependencies working-directory: tests run: | npm ci - npx playwright install chromium + npx playwright install chromium --with-deps - name: Run Playwright tests working-directory: tests From 7660736253d1c811318736203a05bd24a3fe40db Mon Sep 17 00:00:00 2001 From: Bikal Gurung Date: Tue, 10 Feb 2026 11:32:08 +0000 Subject: [PATCH 4/5] fix: update moonbitlang/async dependency to version 0.16.6 --- moon.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moon.mod.json b/moon.mod.json index 26ff45e..caf164f 100644 --- a/moon.mod.json +++ b/moon.mod.json @@ -9,6 +9,6 @@ "source": "src", "preferred-target": "js", "deps": { - "moonbitlang/async": "0.16.5" + "moonbitlang/async": "0.16.6" } } \ No newline at end of file From 46e9064a32456f506b04c3fd28478da41b590c45 Mon Sep 17 00:00:00 2001 From: Bikal Lem <315907+bikallem@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:41:04 +0000 Subject: [PATCH 5/5] Update moon.mod.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- moon.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moon.mod.json b/moon.mod.json index caf164f..26ff45e 100644 --- a/moon.mod.json +++ b/moon.mod.json @@ -9,6 +9,6 @@ "source": "src", "preferred-target": "js", "deps": { - "moonbitlang/async": "0.16.6" + "moonbitlang/async": "0.16.5" } } \ No newline at end of file