diff --git a/scripts/check-examples.sh b/scripts/check-examples.sh index 9e7d1ce17..f866248e8 100755 --- a/scripts/check-examples.sh +++ b/scripts/check-examples.sh @@ -20,6 +20,8 @@ # # uses checkouts of your own (example-app/ and # # example-plugin/ in that directory), as they are on # # disk, copied so they are left untouched +# EXAMPLES_BUILDS="" scripts/check-examples.sh +# # builds none of their apps: the build API fixture alone # # CI: the examples job of .github/workflows/ci.yml. set -euo pipefail @@ -48,29 +50,32 @@ pack "$root" | gzip > "$work/fizzy.tar.gz" bash scripts/pack-sdk.sh "$work/sdk" >/dev/null sdk_tarball="$(ls "$work"/sdk/fizzy-sdk-v*.tar.gz)" -for repo in example-app example-plugin; do - if [[ -n "${EXAMPLES_DIR:-}" ]]; then - mkdir -p "$work/$repo" - pack "$EXAMPLES_DIR/$repo" | tar -x -C "$work/$repo" - else - git clone --quiet --depth 1 "https://github.com/fizzyedit/$repo" "$work/$repo" - fi -done - -(cd "$work/example-plugin" && zig fetch --save=fizzy "$sdk_tarball" >/dev/null) -# example-app bundles example-plugin (`hello`), pinned by URL: the copy here, on this tree's SDK. -pack "$work/example-plugin" | gzip > "$work/example-plugin.tar.gz" -( - cd "$work/example-app" - zig fetch --save=hello "$work/example-plugin.tar.gz" >/dev/null - zig fetch --save=fizzy "$work/fizzy.tar.gz" >/dev/null - # Its replay app depends on the plugin SDK alone: this tree's, packed as a release would be. - zig fetch --save=fizzy_sdk "$sdk_tarball" >/dev/null - # So do the plugins it carries, each pinning a released SDK of its own. - for plugin in plugins/*/; do - (cd "$plugin" && zig fetch --save=fizzy "$sdk_tarball" >/dev/null) +builds="${EXAMPLES_BUILDS-plugin minimal studio endless studio-zon replay dvui dvui-sdl3}" +if [[ -n $builds ]]; then + for repo in example-app example-plugin; do + if [[ -n "${EXAMPLES_DIR:-}" ]]; then + mkdir -p "$work/$repo" + pack "$EXAMPLES_DIR/$repo" | tar -x -C "$work/$repo" + else + git clone --quiet --depth 1 "https://github.com/fizzyedit/$repo" "$work/$repo" + fi done -) + + (cd "$work/example-plugin" && zig fetch --save=fizzy "$sdk_tarball" >/dev/null) + # example-app bundles example-plugin (`hello`), pinned by URL: the copy here, on this tree's SDK. + pack "$work/example-plugin" | gzip > "$work/example-plugin.tar.gz" + ( + cd "$work/example-app" + zig fetch --save=hello "$work/example-plugin.tar.gz" >/dev/null + zig fetch --save=fizzy "$work/fizzy.tar.gz" >/dev/null + # Its replay app depends on the plugin SDK alone: this tree's, packed as a release would be. + zig fetch --save=fizzy_sdk "$sdk_tarball" >/dev/null + # So do the plugins it carries, each pinning a released SDK of its own. + for plugin in plugins/*/; do + (cd "$plugin" && zig fetch --save=fizzy "$sdk_tarball" >/dev/null) + done + ) +fi # The plugin build installs the plugin: into a profile of its own, not this machine's fizzy. export FIZZY_PROFILE="$work/profile" @@ -107,8 +112,6 @@ build_one() { } export -f build_args build_one -builds="plugin minimal studio endless studio-zon replay dvui dvui-sdl3" - # Each build is one compile of an app that mostly keeps one core busy, so they run side by side, # EXAMPLES_JOBS at once (3: CI's runner has 4 cores and 16 GB). First each configuration is # configured alone (`-l` lists its steps), which fetches the lazy dependencies it asks for, so @@ -119,8 +122,10 @@ for b in $builds; do for a in "${args[@]:1}"; do [[ $a == -* ]] && opts+=("$a"); done (cd "$work/${args[0]}" && zig build -l ${opts[@]+"${opts[@]}"} > /dev/null) done -echo "== example-plugin and example-app, against this tree" -printf '%s\n' $builds | xargs -P "${EXAMPLES_JOBS:-3}" -n 1 bash -c 'build_one "$1"' _ +if [[ -n $builds ]]; then + echo "== example-plugin and example-app, against this tree" + printf '%s\n' $builds | xargs -P "${EXAMPLES_JOBS:-3}" -n 1 bash -c 'build_one "$1"' _ +fi # An app's list is exact: one naming none of fizzy's, workbench included, fails while build.zig # configures, which compiles nothing. The build must fail and say which plugin is missing. @@ -138,3 +143,63 @@ if ! grep -q 'fizzy\.plugins\.workbench' "$work/log-app-only.txt"; then exit 1 fi echo "ok app-only (failed as expected)" + +# The build API an app and a plugin package call (`fizzy.framework`, `staticModule`, `addApp`, +# `addWebSteps`, `addPackageSteps`; design/build-api.md), on a fixture app of its own: two plugin +# packages, one for both kinds of executable and one `.native` only, which fails to compile if it +# reaches the wasm. +fixtures="scripts/fixtures/build-api" +for id in fixture_both fixture_native; do + mkdir -p "$work/$id" + cp "$fixtures"/plugin/{build.zig,build.zig.zon,plugin.zig,lib.zig,lib.c} "$work/$id/" + sed "s/@ID@/$id/g" "$fixtures/plugin/plugin.zig.zon.tmpl" > "$work/$id/plugin.zig.zon" + (cd "$work/$id" && zig fetch --save=fizzy "$sdk_tarball" >/dev/null) +done +mkdir -p "$work/fixture-app" +cp "$fixtures"/app/{build.zig,build.zig.zon} "$work/fixture-app/" +(cd "$work/fixture-app" && zig fetch --save=fizzy "$work/fizzy.tar.gz" >/dev/null \ + && zig build -l > /dev/null) + +echo "== build API fixture app" +fixture_fail=0 +# step