Skip to content
Merged
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
15 changes: 12 additions & 3 deletions .github/workflows/frontend-editor-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
python3 tools/test-doc-translations.py
python3 tools/check-doc-translations.py
python3 tools/check-doc-examples.py --links-only
python3 tools/test-doc-playgrounds.py

- name: Test server transfer with toolchain downloads
run: python3 tools/test-server-transfer.py
Expand All @@ -44,7 +45,7 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Test latest-only installer and recovery
- name: Test pinned Wave and latest Vex installer and recovery
shell: powershell
run: ./frontend/tests/install_latest_test.ps1

Expand All @@ -65,13 +66,13 @@ jobs:
editor/package-lock.json
frontend/package-lock.json

- name: Check latest-only shell installer
- name: Check pinned Wave and latest Vex shell installer
run: |
bash frontend/tests/install_checksum_test.sh
bash frontend/tests/install_latest_test.sh
python3 frontend/tests/install_latest_test.py

- name: Check latest-only PowerShell installer
- name: Check pinned Wave and latest Vex PowerShell installer
shell: pwsh
run: ./frontend/tests/install_latest_test.ps1

Expand Down Expand Up @@ -105,6 +106,14 @@ jobs:
working-directory: frontend
run: npm run test:toolchains

- name: Run browser playground host tests
working-directory: frontend
run: npm run test:playground

- name: Test Wave syntax highlighting
working-directory: frontend
run: npm run test:syntax

- name: Build frontend
working-directory: frontend
run: npm run build
94 changes: 94 additions & 0 deletions .github/workflows/playground-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Wave Playground

on:
pull_request:
paths:
- 'playground/**'
- 'http/**'
- 'wave/source-analyzer/**'
- 'native/tests/source_analyzer_smoke.c'
- 'native/include/wave_source_analyzer.h'
- 'translate/src/**'
- 'translate/tests/test_http.py'
- 'frontend/src/services/playground/**'
- 'frontend/tests/playground*'
- 'wavedoc/**'
- 'frontend/src/services/documentMarkdown.ts'
- 'wave-version'
- 'tools/check-wave-version.py'
- 'tools/test-wave-version.py'
- 'Dockerfile'
- 'compose.yml'
- '.github/workflows/playground-ci.yml'
push:
branches: [master]
paths:
- 'playground/**'
- 'http/**'
- 'wave/source-analyzer/**'
- 'native/tests/source_analyzer_smoke.c'
- 'native/include/wave_source_analyzer.h'
- 'translate/src/**'
- 'translate/tests/test_http.py'
- 'frontend/src/services/playground/**'
- 'frontend/tests/playground*'
- 'wavedoc/**'
- 'frontend/src/services/documentMarkdown.ts'
- 'wave-version'
- 'tools/check-wave-version.py'
- 'tools/test-wave-version.py'
- 'Dockerfile'
- 'compose.yml'
- '.github/workflows/playground-ci.yml'

permissions:
contents: read

jobs:
compile-and-run:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Build and start the isolated Wave service
run: |
docker compose up --build -d playground
container=$(docker compose ps -q playground)
address=$(docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container")
echo "PLAYGROUND_URL=http://$address:8092" >> "$GITHUB_ENV"
curl --retry 15 --retry-delay 1 --retry-connrefused --fail "http://$address:8092/healthz"
- name: Test the shared HTTP library and Translation consumer
run: |
container=$(docker compose ps -q playground)
sdk="$RUNNER_TEMP/wave-http-sdk"
docker cp "$container:/opt/wave" "$sdk"
python3 tools/test-wave-version.py
python3 tools/check-wave-version.py "$sdk/wavec"
"$sdk/wavec" --std-root "$sdk/std" --dep "wave_http=$PWD/http" build http/tests/request.wave --target-dir /tmp/http-tests-build -o /tmp/http-tests
/tmp/http-tests
"$sdk/wavec" --std-root "$sdk/std" --dep "wave_http=$PWD/http" build http/examples/hello.wave --target-dir /tmp/http-example-build -o /tmp/wave-http-example
python3 http/tests/test_server.py
"$sdk/wavec" --std-root "$sdk/std" --dep "wave_http=$PWD/http" build translate/src/main.wave --target-dir /tmp/translate-build -o /tmp/wave-translation-server
python3 translate/tests/test_http.py
- name: Test Wave source highlighting
run: |
sdk="$RUNNER_TEMP/wave-http-sdk"
"$sdk/wavec" --std-root "$sdk/std" build wave/source-analyzer/main.wave --emit=obj --target-dir /tmp/highlight-build -o /tmp/highlight.o
cc -Inative/include native/tests/source_analyzer_smoke.c /tmp/highlight.o -o /tmp/highlight-test
/tmp/highlight-test
- name: Test real compilation and browser host execution
run: |
python3 playground/tests/test_server.py
python3 playground/tests/test_http.py
node --experimental-strip-types --test frontend/tests/playground-live.test.ts
docker compose exec -T playground test ! -e /work/injected
docker compose exec -T playground test ! -e /work/job
- name: Service logs
if: failure()
run: docker compose logs playground
- name: Stop CI service
if: always()
run: docker compose down
4 changes: 3 additions & 1 deletion .github/workflows/translation-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ on:
pull_request:
paths:
- 'translate/**'
- 'wave-version'
- '.github/workflows/translation-ci.yml'
push:
branches: [master]
paths:
- 'translate/**'
- 'wave-version'
- '.github/workflows/translation-ci.yml'

permissions:
Expand All @@ -23,7 +25,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Test snapshot retention and build isolation
- name: Test pinned release retention and build isolation
env:
PYTHONDONTWRITEBYTECODE: '1'
run: python3 translate/tests/test_tooling.py
14 changes: 13 additions & 1 deletion Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@
encode zstd gzip
header {
-Server
Content-Security-Policy "default-src 'self'; base-uri 'self'; connect-src 'self' https://challenges.cloudflare.com; font-src 'self' data:; form-action 'self'; frame-ancestors 'none'; frame-src https://challenges.cloudflare.com; img-src 'self' data:; object-src 'none'; script-src 'self' https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'"
Content-Security-Policy "default-src 'self'; base-uri 'self'; connect-src 'self' https://challenges.cloudflare.com; font-src 'self' data:; form-action 'self'; frame-ancestors 'none'; frame-src https://challenges.cloudflare.com; img-src 'self' data:; object-src 'none'; script-src 'self' 'wasm-unsafe-eval' https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'"
Permissions-Policy "camera=(), geolocation=(), microphone=()"
Referrer-Policy strict-origin-when-cross-origin
X-Content-Type-Options nosniff
X-Frame-Options DENY
}
handle /api/playground/compile {
@oversized expression `{http.request.header.Content-Length} != "" && int({http.request.header.Content-Length}) > 32768`
respond @oversized "Source limit exceeded (32 KiB)." 413
request_body {
max_size 32KB
}
reverse_proxy playground:8092 {
transport http {
response_header_timeout 15s
}
}
}
# Keep the public SDK directory separate from all private platform data.
handle_path /downloads/toolchains/* {
root * /srv/toolchains
Expand Down
29 changes: 25 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN if [ -f package-lock.json ]; then \
fi

COPY frontend/ ./
COPY wavedoc/redirects.json wavedoc/locales.json /src/wavedoc/
COPY wavedoc/redirects.json wavedoc/locales.json wavedoc/examples.json /src/wavedoc/

RUN npm run build

Expand All @@ -36,13 +36,13 @@ RUN apt-get update \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

ARG WAVE_VERSION=0.2.0-pre-beta
COPY wave-version /opt/wave-version
ARG VEX_VERSION=0.0.1

# The server keeps a pinned toolchain. Public installers only install latest,
# so provision these explicit historical versions from release archives directly.
# All platform Wave components use wave-version and the bundled standard library.
RUN <<'INSTALL'
set -eu
WAVE_VERSION="$(cat /opt/wave-version)"
case "$(uname -m)" in
x86_64) arch=x86_64 ;;
aarch64) arch=aarch64 ;;
Expand Down Expand Up @@ -83,6 +83,27 @@ ENV PATH="/root/.wave/bin:${PATH}"
RUN wavec --version
RUN vex --version

FROM wave-toolchain AS playground-builder
WORKDIR /src
COPY playground/src ./playground/src
COPY http/ ./http/
RUN wavec --std-root /root/.wave/bin/std --dep wave_http=/src/http build playground/src/main.wave \
--target-dir /tmp/playground-build -o /tmp/wave-playground

FROM debian:trixie-slim AS playground
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl util-linux \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 10002 playground \
&& useradd --uid 10002 --gid playground --no-create-home playground
COPY --from=playground-builder /root/.wave/bin /opt/wave
RUN ln -s ld.lld /opt/wave/llvm/bin/wasm-ld
COPY --from=playground-builder /tmp/wave-playground /usr/local/bin/wave-playground
WORKDIR /work
USER 10002:10002
EXPOSE 8092
CMD ["/usr/local/bin/wave-playground"]

FROM wave-toolchain AS application-builder

WORKDIR /src
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
GOCACHE ?= /tmp/wave-platform-gocache
WAVEC ?= wavec

.PHONY: frontend-install frontend-dev frontend-build test build run clean
.PHONY: frontend-install frontend-dev frontend-build test build run clean wave-version-check

wave-version-check:
python3 tools/check-wave-version.py "$(WAVEC)"

frontend-install:
cd frontend && npm install
Expand All @@ -18,12 +22,13 @@ test:
cd frontend && npm run test:docs
cd frontend && npm run test:seo
cd frontend && npm run test:toolchains
cd frontend && npm run test:playground

build: frontend-build
build: wave-version-check frontend-build
mkdir -p bin
GOCACHE=$(GOCACHE) go build -trimpath -o bin/wave-platform ./cmd/server

run: frontend-build
run: wave-version-check frontend-build
GOCACHE=$(GOCACHE) go run ./cmd/server

clean:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ make run

The development server listens on <http://127.0.0.1:8080>. Run `make frontend-dev` in another terminal when Vite hot reload is needed.

Wave components use the version pinned in `wave-version`, with the matching
bundled standard library. `make build` and `make run` reject another compiler.
The homepage, documentation examples, and `/playground` use the Wave compiler
service included in Docker Compose. See [Playground](playground/README.md) for
its execution limits and integration checks.

Wave services share the small [HTTP library](http/README.md). Playground and
Translation remain independent processes with their own routes and lifecycle;
the Go platform remains a single host application.

### LLVM toolchain downloads

The `/toolchains` page reads `/downloads/toolchains/index.json`. In development,
Expand Down
34 changes: 34 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ services:
depends_on:
wave-platform:
condition: service_healthy
playground:
condition: service_started
networks:
- default
- playground
environment:
WAVE_SITE_ADDRESS: "${WAVE_SITE_ADDRESS:-http://localhost}"
ports:
Expand All @@ -90,6 +95,31 @@ services:
retries: 5
start_period: 5s

playground:
build:
context: .
target: playground
image: wave-playground:development
restart: unless-stopped
init: true
read_only: true
user: "10002:10002"
cap_drop: [ALL]
security_opt: ["no-new-privileges:true"]
pids_limit: 64
mem_limit: 1g
cpus: 1.0
tmpfs:
- /work:rw,noexec,nosuid,nodev,size=64m,uid=10002,gid=10002,mode=0700
networks: [playground]
expose: ["8092"]
healthcheck:
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:8092/healthz"]
interval: 30s
timeout: 15s
retries: 3
start_period: 5s

wave-platform-data-init:
image: alpine:3.22
restart: "no"
Expand Down Expand Up @@ -117,3 +147,7 @@ services:
volumes:
caddy-data:
caddy-config:

networks:
playground:
internal: true
42 changes: 42 additions & 0 deletions docs/document-authoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,45 @@ Hangul literals used in Unicode examples.
Automated checks do not establish linguistic quality. Review translated prose
for terminology, negation, boundary values, ownership, and error semantics. Do
not remove an explanation or silently change an example to make a check pass.

## Embedded playgrounds

Use `wave playground` for a complete program that can run in the browser. It
renders an editable, highlighted program with Run, Stop, Reset, and output in
place. Opening a document never compiles or runs its examples automatically.
Ordinary `wave` fences remain read-only highlighted code, including fragments,
invalid examples, and programs needing native OS facilities.

````markdown
<!-- wave-example: book-hello -->
```wave playground
fun main() {
println("Hello, Wave!");
}
```
````

The fence works without metadata, but official documentation must keep its
adjacent `wave-example` marker and set `"playground": true` on the matching entry
in `wavedoc/examples.json`. The `stdin` field supplies initial input; `stdout` and `exit` remain
verification data for automated tests. Reset restores the
original source and input and clears the previous execution result. The same ID
in translations reuses this metadata; keep the fence modifier in translations.

Enable only single-file programs that fit the browser execution limits and do
not require files, sockets, external services, or native-only imports. The live
playground CI compiles each enabled canonical example to Wasm and checks its
output and exit code, including alternate `runs` from the manifest:

```shell
python3 tools/test-doc-playgrounds.py
python3 tools/check-doc-examples.py --links-only
cd frontend
npm run test:docs
node --experimental-strip-types --test tests/playground-live.test.ts
```

The live test uses the running local service at `http://localhost:8080` unless
`PLAYGROUND_URL` selects another instance. The document checker also rejects
unregistered playground fences and cases that require file fixtures or have
`check`/`reject` modes. Add new examples only after the live test passes.
Loading
Loading