Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 63 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ on:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write
Comment on lines +10 to +13
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflow-level permissions grant pages: write and id-token: write on all events including pull_request. Even though the deploy job is gated, this still broadens the GITHUB_TOKEN for PR jobs; prefer setting minimal default permissions (e.g., contents: read) and granting pages/id-token only on the deploy/upload steps or jobs that need it.

Copilot uses AI. Check for mistakes.

concurrency:
group: "pages"
cancel-in-progress: false
Comment on lines +15 to +17
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concurrency: group: "pages" is applied at the workflow level, which will serialize all CI runs (including PR checks) behind the Pages deployment queue. If the intent is only to prevent concurrent deployments, move the concurrency block to the deploy job (or make the group conditional on push/main) so PR CI runs can execute in parallel.

Copilot uses AI. Check for mistakes.

jobs:
check:
build-test-webapi:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -22,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
Expand All @@ -42,27 +65,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
Expand All @@ -71,12 +73,50 @@ 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
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
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp -rL examples _site/examples will dereference any symlinks (including the examples/target -> ../target link mentioned in the PR description) and copy the entire linked directory into the Pages artifact. This can significantly bloat the uploaded site if ../target contains build outputs beyond what the examples need; consider copying only the required target/**/build/** subpaths (or ensuring the examples target output is isolated under examples/target) to keep Pages artifacts small and deployments faster.

Suggested change
cp -rL examples _site/examples
cp -r examples _site/examples

Copilot uses AI. Check for mistakes.
rm -rf _site/examples/.mooncakes _site/examples/_build
cp src/webapi.mjs _site/src/
echo '<meta http-equiv="refresh" content="0; url=examples/">' > _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
58 changes: 0 additions & 58 deletions .github/workflows/pages.yml

This file was deleted.

28 changes: 16 additions & 12 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
</style>
</head>
<body>
<h1>MoonBit WebAPI Examples</h1>
<ul>
<li><a href="canvas/canvas.js.html">Canvas</a></li>
<li><a href="classlist/classlist.js.html">ClassList</a></li>
<li><a href="counter/counter.js.html">Counter</a></li>
<li><a href="dom/dom.js.html">DOM</a></li>
<li><a href="element-ops/element-ops.js.html">Element Operations</a></li>
<li><a href="events/events.js.html">Events</a></li>
<li><a href="fetch/fetch.js.html">Fetch</a></li>
<li><a href="forms/forms.js.html">Forms</a></li>
<li><a href="storage/storage.js.html">Storage</a></li>
<li><a href="timers/timers.js.html">Timers</a></li>
<li><a href="url/url.js.html">URL</a></li>
<li><span class="name">Canvas</span><span class="targets">[<a href="canvas/canvas.js.html">js</a> <span class="sep">|</span> <a href="canvas/canvas.wasm.html">wasm</a>]</span></li>
<li><span class="name">ClassList</span><span class="targets">[<a href="classlist/classlist.js.html">js</a> <span class="sep">|</span> <a href="classlist/classlist.wasm.html">wasm</a>]</span></li>
<li><span class="name">Counter</span><span class="targets">[<a href="counter/counter.js.html">js</a> <span class="sep">|</span> <a href="counter/counter.wasm.html">wasm</a>]</span></li>
<li><span class="name">DOM</span><span class="targets">[<a href="dom/dom.js.html">js</a> <span class="sep">|</span> <a href="dom/dom.wasm.html">wasm</a>]</span></li>
<li><span class="name">Element Operations</span><span class="targets">[<a href="element-ops/element-ops.js.html">js</a> <span class="sep">|</span> <a href="element-ops/element-ops.wasm.html">wasm</a>]</span></li>
<li><span class="name">Events</span><span class="targets">[<a href="events/events.js.html">js</a> <span class="sep">|</span> <a href="events/events.wasm.html">wasm</a>]</span></li>
<li><span class="name">Fetch</span><span class="targets">[<a href="fetch/fetch.js.html">js</a>]</span></li>
<li><span class="name">Forms</span><span class="targets">[<a href="forms/forms.js.html">js</a> <span class="sep">|</span> <a href="forms/forms.wasm.html">wasm</a>]</span></li>
<li><span class="name">Storage</span><span class="targets">[<a href="storage/storage.js.html">js</a> <span class="sep">|</span> <a href="storage/storage.wasm.html">wasm</a>]</span></li>
<li><span class="name">Timers</span><span class="targets">[<a href="timers/timers.js.html">js</a> <span class="sep">|</span> <a href="timers/timers.wasm.html">wasm</a>]</span></li>
<li><span class="name">URL</span><span class="targets">[<a href="url/url.js.html">js</a> <span class="sep">|</span> <a href="url/url.wasm.html">wasm</a>]</span></li>
</ul>
</body>
</html>