diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml index 552f9b63..faa43281 100644 --- a/.github/workflows/release-plz.yml +++ b/.github/workflows/release-plz.yml @@ -10,19 +10,10 @@ on: - main jobs: - wasmstan: - name: Prophet WASMStan component - uses: grafana/augurs/.github/workflows/wasmstan.yml@main - release-plz: name: Release-plz runs-on: ubuntu-latest - needs: wasmstan steps: - - uses: actions/download-artifact@v4 - with: - name: prophet-wasmstan.wasm - path: crates/augurs-prophet - name: Checkout repository uses: actions/checkout@v4 with: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 17a71b10..f1b2008a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,14 +22,9 @@ jobs: - name: Run cargo check run: cargo check --all-targets --all-features - wasmstan: - name: Prophet WASMStan component - uses: grafana/augurs/.github/workflows/wasmstan.yml@main - test: name: Tests runs-on: ubuntu-latest - needs: wasmstan steps: - name: Checkout sources uses: actions/checkout@v4 @@ -41,13 +36,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Download the Prophet wasmstan module since an example and some doctests require it. - - name: Download Prophet WASMStan component artifact - uses: actions/download-artifact@v4 - with: - name: prophet-wasmstan.wasm - path: crates/augurs-prophet - # Download the Prophet Stan model since an example requires it. - name: Download Prophet Stan model run: just download-prophet-stan-model @@ -62,7 +50,6 @@ jobs: test-book: name: Test Book runs-on: ubuntu-latest - needs: wasmstan steps: - name: Checkout sources uses: actions/checkout@v4 @@ -74,13 +61,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Download the Prophet wasmstan module since an example and some doctests require it. - - name: Download Prophet WASMStan component artifact - uses: actions/download-artifact@v4 - with: - name: prophet-wasmstan.wasm - path: crates/augurs-prophet - # The book tests require the augurs library to be built. In CI, we cache the result # of the build so that we don't have to rebuild it every time, but this can result # in multiple 'augurs' rlibs being present in the book's target directory. This diff --git a/.github/workflows/wasmstan.yml b/.github/workflows/wasmstan.yml index 50bc3d2d..dd2b29f8 100644 --- a/.github/workflows/wasmstan.yml +++ b/.github/workflows/wasmstan.yml @@ -1,7 +1,9 @@ -name: prophet-wasmstan +name: build-prophet-wasmstan on: - workflow_call: + push: + branches: ["main"] + pull_request: env: CARGO_TERM_COLOR: always @@ -13,8 +15,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - with: - targets: wasm32-unknown-unknown,wasm32-wasip1 - uses: taiki-e/install-action@v2 with: tool: cargo-binstall,just,ripgrep,wasmtime @@ -31,3 +31,7 @@ jobs: with: name: prophet-wasmstan.wasm path: components/cpp/prophet-wasmstan/prophet-wasmstan.wasm + - name: Copy prophet-wasmstan.wasm to augurs + run: just copy-component-wasm + - name: Ensure no diffs + run: git diff --exit-code -- crates/augurs-prophet/prophet-wasmstan.wasm diff --git a/book/src/contributing.md b/book/src/contributing.md index a25161b6..29ba094e 100644 --- a/book/src/contributing.md +++ b/book/src/contributing.md @@ -20,17 +20,15 @@ There are many ways to contribute: 4. Install [`cargo-binstall`][binstall] to install dependencies 5. Install dependencies: ```bash -(cd components && just install-deps) +just components/install-deps ``` -6. Build the WASM component: -```bash -just build-component -``` -7. Start building and checking the project using [bacon]: + +6. Start building and checking the project using [bacon]: ```bash just watch ``` -8. Run tests using [nextest]: + +7. Run tests using [nextest]: ```bash just test ``` diff --git a/components/cpp/prophet-wasmstan/prophet_wasmstan.cpp b/components/cpp/prophet-wasmstan/prophet_wasmstan.cpp index 7037244d..fc9da61f 100644 --- a/components/cpp/prophet-wasmstan/prophet_wasmstan.cpp +++ b/components/cpp/prophet-wasmstan/prophet_wasmstan.cpp @@ -1,4 +1,4 @@ -// Generated by `wit-bindgen` 0.34.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT! #include "prophet_wasmstan.h" #include #include diff --git a/components/cpp/prophet-wasmstan/prophet_wasmstan.h b/components/cpp/prophet-wasmstan/prophet_wasmstan.h index 47ba4811..7de26f03 100644 --- a/components/cpp/prophet-wasmstan/prophet_wasmstan.h +++ b/components/cpp/prophet-wasmstan/prophet_wasmstan.h @@ -1,4 +1,4 @@ -// Generated by `wit-bindgen` 0.34.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT! #ifndef __BINDINGS_PROPHET_WASMSTAN_H #define __BINDINGS_PROPHET_WASMSTAN_H #ifdef __cplusplus diff --git a/components/justfile b/components/justfile index 8bdae83c..69744a56 100644 --- a/components/justfile +++ b/components/justfile @@ -1,11 +1,15 @@ TOOLS_DIR := "./tools" -WIT_BINDGEN_VERSION := "0.34.0" WASI_ARCH := `uname -m` WASI_OS := os() WASI_VERSION := "24" WASI_VERSION_FULL := WASI_VERSION + ".0" WASI_SDK_PATH := "wasi-sdk-" + WASI_VERSION_FULL + "-" + WASI_ARCH + "-" + WASI_OS +CARGO_COMPONENT_VERSION := "0.19.0" +WIT_BINDGEN_CLI_VERSION := "0.36.0" +WASM_TOOLS_VERSION := "1.222.0" +WAC_CLI_VERSION := "0.6.1" + CLANG := TOOLS_DIR + "/" + WASI_SDK_PATH + "/bin/clang" CLANG_CPP := TOOLS_DIR + "/" + WASI_SDK_PATH + "/bin/clang++" @@ -15,15 +19,15 @@ checkout-submodules: # Install dependencies to work with WASI. install-deps: checkout-submodules - cargo binstall -y cargo-component - cargo binstall -y wit-bindgen-cli@{{WIT_BINDGEN_VERSION}} - cargo binstall -y wasm-tools - cargo binstall -y wac-cli - curl https://wasmtime.dev/install.sh -sSf | bash + cargo binstall -y cargo-component@{{CARGO_COMPONENT_VERSION}} + cargo binstall -y wit-bindgen-cli@{{WIT_BINDGEN_CLI_VERSION}} + cargo binstall -y wasm-tools@{{WASM_TOOLS_VERSION}} + cargo binstall -y wac-cli@{{WAC_CLI_VERSION}} npm install --yes -g @bytecodealliance/jco curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-{{WASI_VERSION}}/{{WASI_SDK_PATH}}.tar.gz tar -xf {{WASI_SDK_PATH}}.tar.gz rm {{WASI_SDK_PATH}}.tar.gz + rm -rf {{TOOLS_DIR}} mkdir -p {{TOOLS_DIR}} mv {{WASI_SDK_PATH}} {{TOOLS_DIR}} curl -Lo {{TOOLS_DIR}}/wasi_snapshot_preview1.wasm https://github.com/bytecodealliance/wasmtime/releases/download/v17.0.0/wasi_snapshot_preview1.reactor.wasm diff --git a/crates/augurs-prophet/.gitignore b/crates/augurs-prophet/.gitignore index a9ce1bf8..b21fda12 100644 --- a/crates/augurs-prophet/.gitignore +++ b/crates/augurs-prophet/.gitignore @@ -1,2 +1 @@ /prophet_stan_model -prophet-wasmstan.wasm diff --git a/crates/augurs-prophet/prophet-wasmstan.wasm b/crates/augurs-prophet/prophet-wasmstan.wasm new file mode 100644 index 00000000..9650db97 Binary files /dev/null and b/crates/augurs-prophet/prophet-wasmstan.wasm differ diff --git a/justfile b/justfile index 0601fcb0..53ecdbcf 100644 --- a/justfile +++ b/justfile @@ -49,6 +49,9 @@ watch: download-prophet-stan-model: cargo run --features download --bin download-stan-model -build-component: - just components/build +copy-component-wasm: cp components/cpp/prophet-wasmstan/prophet-wasmstan.wasm crates/augurs-prophet/prophet-wasmstan.wasm + +# Rebuild the prophet-wasmstan WASM component. Requires a local runner with the `act` tool. +rebuild-component: + act --bind --artifact-server-path=/tmp/artifacts -W ./.github/workflows/wasmstan.yml