Skip to content
Draft
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
48 changes: 38 additions & 10 deletions .github/workflows/web-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ on:
push:
branches: [main]

name: Web demo
name: Web apps

permissions:
contents: read
pull-requests: write

concurrency:
group: web-demo-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
group: web-apps-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -43,13 +43,35 @@ jobs:
~/.npm
~/.cargo/registry
~/.cargo/git
~/.ghc-wasm/.cabal
target
key: web-demo-${{ runner.os }}-${{ hashFiles('flake.lock', 'Cargo.lock', 'packages/coln-js-runtime/package-lock.json', 'examples/web-demo/pnpm-lock.yaml') }}
dist-newstyle
key: web-apps-${{ runner.os }}-${{ hashFiles('flake.lock', 'Cargo.lock', 'cabal.project', 'packages/**/*.cabal', 'packages/coln-js-runtime/package-lock.json', 'examples/web-demo/pnpm-lock.yaml') }}
restore-keys: |
web-demo-${{ runner.os }}-
web-apps-${{ runner.os }}-

- name: Build web demo
run: nix run --accept-flake-config .#web-demo -- "$GITHUB_WORKSPACE"
env:
VITE_BASE: /demo/

- name: Build web compiler
run: nix develop --accept-flake-config --command just packages/coln-compiler-wasm/build-example

- name: Assemble deploy directory
run: |
mkdir -p _deploy/demo _deploy/compiler
cp -r examples/web-demo/dist/* _deploy/demo/
cp -r _build/wasm/* _deploy/compiler/
cat > _deploy/index.html <<'EOF'
<!doctype html>
<meta charset="utf-8">
<title>Coln</title>
<ul>
<li><a href="/demo/">Demo</a></li>
<li><a href="/compiler/">Compiler</a></li>
</ul>
EOF

- name: Deploy PR preview to Netlify
id: deploy-preview
Expand All @@ -58,10 +80,10 @@ jobs:
npx --yes netlify-cli@latest deploy \
--auth "$NETLIFY_AUTH_TOKEN" \
--site "$NETLIFY_SITE_ID" \
--dir examples/web-demo/dist \
--dir _deploy \
--no-build \
--alias "pr-${{ github.event.pull_request.number }}" \
--message "PR #${{ github.event.pull_request.number }} web demo" \
--message "PR #${{ github.event.pull_request.number }} web apps" \
--json > netlify-deploy.json

cat netlify-deploy.json
Expand All @@ -73,8 +95,14 @@ jobs:
uses: actions/github-script@v8
with:
script: |
const marker = '<!-- coln-web-demo-deploy-preview -->'
const body = `${marker}\nWeb demo preview: ${{ steps.deploy-preview.outputs.deploy-url }}`
const marker = '<!-- coln-web-apps-deploy-preview -->'
const url = '${{ steps.deploy-preview.outputs.deploy-url }}'
const body = [
marker,
'Deploy preview:',
`- [Demo](${url}/demo/)`,
`- [Compiler](${url}/compiler/)`,
].join('\n')
const { owner, repo } = context.repo
const issue_number = context.issue.number
const comments = await github.rest.issues.listComments({ owner, repo, issue_number, per_page: 100 })
Expand All @@ -91,7 +119,7 @@ jobs:
npx --yes netlify-cli@latest deploy \
--auth "$NETLIFY_AUTH_TOKEN" \
--site "$NETLIFY_SITE_ID" \
--dir examples/web-demo/dist \
--dir _deploy \
--no-build \
--prod \
--message "main web demo ${{ github.sha }}"
--message "main web apps ${{ github.sha }}"
1 change: 1 addition & 0 deletions examples/web-demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import react from "@vitejs/plugin-react"
import wasm from "vite-plugin-wasm"

export default defineConfig({
base: process.env.VITE_BASE || "/",
plugins: [wasm(), react()],
build: { target: "esnext" },
})
4 changes: 3 additions & 1 deletion packages/coln-compiler-wasm/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ build:
libdir="$(wasm32-wasi-ghc --print-libdir)"
"$libdir/post-link.mjs" --input {{ dist_dir }}/coln.wasm --output {{ dist_dir }}/ghc_wasm_jsffi.js

serve-example port="8000": build
build-example: build
#!/usr/bin/env bash
set -euxo pipefail
cp example.html {{ build_dir }}/index.html
examples_dir="{{ build_dir }}/examples"
mkdir -p "$examples_dir"
cp ../../packages/coln-compiler/test/*.coln "$examples_dir/"
ls -1 "$examples_dir"/*.coln | xargs -n1 basename | jq -nR '[inputs]' > "$examples_dir/index.json"

serve-example port="8000": build-example
simple-http-server --nocache --index --open --port {{ port }} {{ build_dir }}
Loading