Skip to content

Commit

Permalink
Commit prophet-wasmstan.wasm to git (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
sd2k authored Dec 20, 2024
1 parent ecfabde commit c6b7cfd
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 51 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -62,7 +50,6 @@ jobs:
test-book:
name: Test Book
runs-on: ubuntu-latest
needs: wasmstan
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/wasmstan.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: prophet-wasmstan
name: build-prophet-wasmstan

on:
workflow_call:
push:
branches: ["main"]
pull_request:

env:
CARGO_TERM_COLOR: always
Expand All @@ -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
Expand All @@ -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
12 changes: 5 additions & 7 deletions book/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion components/cpp/prophet-wasmstan/prophet_wasmstan.cpp
Original file line number Diff line number Diff line change
@@ -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 <stdlib.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion components/cpp/prophet-wasmstan/prophet_wasmstan.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 10 additions & 6 deletions components/justfile
Original file line number Diff line number Diff line change
@@ -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++"

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion crates/augurs-prophet/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/prophet_stan_model
prophet-wasmstan.wasm
Binary file added crates/augurs-prophet/prophet-wasmstan.wasm
Binary file not shown.
7 changes: 5 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c6b7cfd

Please sign in to comment.