OXYGENHUB
# 48ed8a1db369 oxygenflow / scripts / checks-wasm.sh
1.4 KiB · Bourne Again Shell (bash) · executable · last changed The cheap checks run as WASM: layout, todos, size and summary are one WASI module (crates/flow-checks, .flow/checks.wasm), so any runner with the WASM tier takes them; the fmt job checks the module is what its source builds; the build image gains wasm32-wasip1 (re-pinned e52c41a1) (closes #96) 8 days ago source blame history raw
1
#!/bin/sh
2
# Build the cheap checks (crates/flow-checks, #96) as a WASI module and keep
3
# it at .flow/checks.wasm, where the pipeline's WASM jobs run it from.
4
#
5
#   scripts/checks-wasm.sh          rebuild .flow/checks.wasm
6
#   scripts/checks-wasm.sh --check  fail unless .flow/checks.wasm is what
7
#                                   the source builds (the fmt job runs this)
8
#
9
# The build is the same on any machine with the same toolchain (the build
10
# image's, images/rust): the crate is std only, the workspace path is
11
# remapped to /src, and the module carries no debug info.
12
# Needs: rustup target wasm32-wasip1.
13
set -eu
14
cd "$(dirname "$0")/.."
15
target=$(mktemp -d)
16
trap 'rm -rf "$target"' EXIT
17
RUSTFLAGS="--remap-path-prefix=$(pwd)=/src" \
18
CARGO_PROFILE_RELEASE_DEBUG=0 CARGO_PROFILE_RELEASE_STRIP=true CARGO_INCREMENTAL=0 \
19
    cargo build -q --release --locked --target wasm32-wasip1 -p flow-checks --target-dir "$target"
20
built="$target/wasm32-wasip1/release/flow-checks.wasm"
21
if [ "${1:-}" = --check ]; then
22
    if cmp -s "$built" .flow/checks.wasm; then
23
        echo ".flow/checks.wasm is what crates/flow-checks builds ($(rustc --version))"
24
    else
25
        echo ".flow/checks.wasm differs from what crates/flow-checks builds: run scripts/checks-wasm.sh and commit it" >&2
26
        exit 1
27
    fi
28
else
29
    cp "$built" .flow/checks.wasm
30
    echo "built .flow/checks.wasm ($(wc -c < .flow/checks.wasm) bytes, $(rustc --version))"
31
fi