Release webapi v0.4.2 #139
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: | | |
| src/gen/package-lock.json | |
| tests/package-lock.json | |
| - name: Install npm dependencies | |
| working-directory: src/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: | | |
| .mooncakes | |
| src/examples/.mooncakes | |
| key: mooncakes-${{ runner.os }}-${{ steps.moonbit-version.outputs.version }}-${{ hashFiles('moon.mod.json', 'src/examples/moon.mod.json') }} | |
| - name: Install MoonBit dependencies | |
| run: | | |
| moon version --all | |
| moon update | |
| - name: Check (JS target) | |
| run: moon check --target js | |
| - name: Check (wasm-gc target) | |
| run: moon check --target wasm-gc | |
| - name: Run tests | |
| run: moon test | |
| - name: Build examples (JS) | |
| working-directory: src/examples | |
| run: moon build --target js --release | |
| - name: Build examples (wasm-gc) | |
| working-directory: src/examples | |
| run: moon build --target wasm-gc --release | |
| - name: Trim webapi.mjs for wasm-gc examples | |
| run: | | |
| for wasm in src/examples/_build/wasm-gc/release/build/*/*.wasm; do | |
| moon run src/trim -- "$(pwd)/$wasm" --source "$(pwd)/src/webapi.mjs" | |
| done | |
| - name: Validate wasm-gc binaries | |
| run: | | |
| fails=0 | |
| for wasm in src/examples/_build/wasm-gc/release/build/*/*.wasm; do | |
| name=$(basename $(dirname $wasm)) | |
| if wasm-tools validate "$wasm" 2>/dev/null; then | |
| echo " OK: $name" | |
| else | |
| echo " FAIL: $name" | |
| fails=$((fails + 1)) | |
| fi | |
| done | |
| if [ $fails -gt 0 ]; then echo "$fails wasm binary(ies) failed validation"; exit 1; fi | |
| echo "All wasm binaries valid" | |
| - name: Run trim CLI tests | |
| run: bash src/trim/tests/cli_test.sh | |
| - 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 src/examples _site/examples | |
| rm -rf _site/examples/.mooncakes _site/examples/_build | |
| mkdir -p _site/examples/_build/js/release | |
| cp -rL src/examples/_build/js/release/build _site/examples/_build/js/release/ | |
| mkdir -p _site/examples/_build/wasm-gc/release | |
| cp -rL src/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 |