Convert global browser bindings to functions #134
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-test-webapi: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up MoonBit | |
| run: | | |
| rm -rf "$HOME/.moon" | |
| curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash | |
| echo "$HOME/.moon/bin" >> $GITHUB_PATH | |
| "$HOME/.moon/bin/moon" version --all | |
| - name: Set up Node.js | |
| 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: Get MoonBit version | |
| id: moonbit-version | |
| run: echo "version=$(moon version | head -1)" >> "$GITHUB_OUTPUT" | |
| - name: Cache MoonBit packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| webapi/.mooncakes | |
| webapi_gen/.mooncakes | |
| webapi_trim/.mooncakes | |
| examples/.mooncakes | |
| key: mooncakes-${{ runner.os }}-${{ steps.moonbit-version.outputs.version }}-${{ hashFiles('webapi/moon.mod.json', 'webapi_gen/moon.mod.json', 'webapi_trim/moon.mod.json', 'examples/moon.mod.json') }} | |
| - name: Install MoonBit dependencies | |
| run: | | |
| moon version --all | |
| moon update | |
| - name: Check (JS target) | |
| working-directory: webapi | |
| run: moon check --target js | |
| - name: Run tests | |
| working-directory: webapi_gen | |
| run: moon test | |
| - 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: Trim webapi.mjs for wasm-gc examples | |
| run: | | |
| for wasm in examples/_build/wasm-gc/release/build/*/*.wasm; do | |
| moon -C webapi_trim run . -- "../$wasm" --source ../webapi/webapi.mjs | |
| done | |
| - name: Run webapi_trim tests | |
| run: make trim-test | |
| - 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 --with-deps | |
| - name: Run Playwright tests | |
| working-directory: tests | |
| run: npx playwright test | |
| - name: Prepare site | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| mkdir -p _site | |
| cp -r examples _site/examples | |
| rm -rf _site/examples/.mooncakes _site/examples/_build | |
| mkdir -p _site/examples/_build/js/release | |
| cp -rL examples/_build/js/release/build _site/examples/_build/js/release/ | |
| mkdir -p _site/examples/_build/wasm-gc/release | |
| cp -rL examples/_build/wasm-gc/release/build _site/examples/_build/wasm-gc/release/ | |
| echo '<meta http-equiv="refresh" content="0; url=examples/">' > _site/index.html | |
| - name: Upload site artifact | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: site | |
| path: _site | |
| deploy: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| permissions: | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build-test-webapi | |
| steps: | |
| - name: Download site artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: site | |
| path: _site | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _site | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |