From e647c542280f203723da9c65b868a017fb6a26c7 Mon Sep 17 00:00:00 2001 From: Bailey Hayes Date: Wed, 27 Jul 2022 20:30:49 +0000 Subject: [PATCH 1/2] ci: add writ tests - changed make target for test to depend on a wasm module. That way we can test both release and debug in the CI. - If I spied rust unit tests, I added those to the make target. We could also consider gtests for C++ examples in the future. - only run pages when files change --- .github/workflows/ci.yml | 28 ++++++++++++++----- .github/workflows/gh-pages.yml | 5 +++- examples/Makefile | 4 +-- examples/cpp/power/Makefile | 2 +- examples/cpp/split/Makefile | 2 +- examples/rust/dates/Makefile | 3 +- examples/rust/echo-remote-debug/Makefile | 2 +- examples/rust/sentimentable/Makefile | 2 +- examples/rust/split/Makefile | 2 +- .../rust/usergenerator-remote-debug/Makefile | 2 +- examples/rust/usergenerator/Makefile | 2 +- 11 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 263ca59..eee8955 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,15 @@ name: CI on: push: - branches: [main] + branches: + - main + paths-ignore: + - '**.md' + - '**.html' pull_request: - branches: [main] + paths-ignore: + - '**.md' + - '**.html' # Cancel any in-flight jobs for the same PR/branch so there's only one active at a time concurrency: @@ -18,6 +24,19 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.x' + - run: pip install mypy wasmtime + + - uses: actions/checkout@v3 + with: + repository: singlestore-labs/writ + path: writ + - run: | + echo "$GITHUB_WORKSPACE/writ/bin" >> $GITHUB_PATH + chmod +x $GITHUB_WORKSPACE/writ/bin/writ + - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -36,11 +55,6 @@ jobs: curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz -L | tar xzvf - -C $GITHUB_WORKSPACE/ echo "$GITHUB_WORKSPACE/wasi-sdk-16.0/bin" >> $GITHUB_PATH - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - run: pip install mypy wasmtime - - name: Test cpp build run: make cpp-debug cpp-release working-directory: ./examples diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index fc94612..aaf5319 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -4,10 +4,13 @@ on: push: paths: - '**.md' + - '**.html' branches: - main pull_request: - + paths: + - '**.md' + - '**.html' jobs: deploy: runs-on: ubuntu-latest diff --git a/examples/Makefile b/examples/Makefile index 13547f6..5bbd672 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -21,7 +21,7 @@ cpp: echo "=====================================================" ; \ echo "Building CPP example '`basename $$D`'" ; \ echo "=====================================================" ; \ - make -C $$D $(TARGET) ; \ + make -C $$D $(TARGET) test; \ done ############################################################################## @@ -40,7 +40,7 @@ rust: echo "=====================================================" ; \ echo "Building Rust example '`basename $$D`'" ; \ echo "=====================================================" ; \ - make -C $$D $(TARGET) ; \ + make -C $$D $(TARGET) test; \ done ############################################################################## diff --git a/examples/cpp/power/Makefile b/examples/cpp/power/Makefile index 77133e1..194be10 100644 --- a/examples/cpp/power/Makefile +++ b/examples/cpp/power/Makefile @@ -16,7 +16,7 @@ power.wasm: gen power.c .PHONY: test -test: debug +test: power.wasm writ --expect 8 --wit power.wit power.wasm power-of 2 3 @echo PASS writ --expect 1 --wit power.wit power.wasm power-of 2 0 diff --git a/examples/cpp/split/Makefile b/examples/cpp/split/Makefile index 50191c4..acc7365 100644 --- a/examples/cpp/split/Makefile +++ b/examples/cpp/split/Makefile @@ -17,7 +17,7 @@ split.wasm: gen split_impl.cpp .PHONY: test -test: debug +test: split.wasm writ \ -e '[{"str": "hello", "idx": 0}, {"str": "there", "idx": 6}, {"str": "people", "idx": 12}]' \ --wit split.wit split.wasm split-str "hello there people" " " diff --git a/examples/rust/dates/Makefile b/examples/rust/dates/Makefile index 6b00a06..79c4d4d 100644 --- a/examples/rust/dates/Makefile +++ b/examples/rust/dates/Makefile @@ -14,11 +14,12 @@ wasm: cargo wasi build --lib $(RELFLAGS) .PHONY: test -test: debug +test: wasm writ \ -e "2022-07-30" \ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm next-saturday \ "2022-07-23" + cargo wasi test @echo PASS .PHONY: clean diff --git a/examples/rust/echo-remote-debug/Makefile b/examples/rust/echo-remote-debug/Makefile index af51617..5cd5688 100644 --- a/examples/rust/echo-remote-debug/Makefile +++ b/examples/rust/echo-remote-debug/Makefile @@ -14,7 +14,7 @@ wasm: cargo wasi build --lib $(RELFLAGS) .PHONY: test -test: debug +test: wasm writ \ -e "hello there hello there" \ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm echo \ diff --git a/examples/rust/sentimentable/Makefile b/examples/rust/sentimentable/Makefile index f30ebb4..928e78a 100644 --- a/examples/rust/sentimentable/Makefile +++ b/examples/rust/sentimentable/Makefile @@ -14,7 +14,7 @@ wasm: cargo wasi build --lib $(RELFLAGS) .PHONY: test -test: debug +test: wasm writ \ -e '[{"compound": 0.5573704017131537, "positive": 0.5454545454545455, "negative": 0.0, "neutral": 0.4545454545454546 }]' \ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm sentimentable\ diff --git a/examples/rust/split/Makefile b/examples/rust/split/Makefile index ac7ba97..e6d49e4 100644 --- a/examples/rust/split/Makefile +++ b/examples/rust/split/Makefile @@ -14,7 +14,7 @@ wasm: cargo wasi build --lib $(RELFLAGS) .PHONY: test -test: debug +test: wasm writ \ -e '[{"str": "hello", "idx": 0}, {"str": "there", "idx": 6}, {"str": "people", "idx": 12}]' \ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm split-str \ diff --git a/examples/rust/usergenerator-remote-debug/Makefile b/examples/rust/usergenerator-remote-debug/Makefile index c546aff..7e3c638 100644 --- a/examples/rust/usergenerator-remote-debug/Makefile +++ b/examples/rust/usergenerator-remote-debug/Makefile @@ -16,7 +16,7 @@ wasm: # This function produces random output, so we can't check it against a # standard. Instead, just verify that it runs without error. .PHONY: test -test: debug +test: wasm writ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm gen-users 3 @echo PASS diff --git a/examples/rust/usergenerator/Makefile b/examples/rust/usergenerator/Makefile index c546aff..7e3c638 100644 --- a/examples/rust/usergenerator/Makefile +++ b/examples/rust/usergenerator/Makefile @@ -16,7 +16,7 @@ wasm: # This function produces random output, so we can't check it against a # standard. Instead, just verify that it runs without error. .PHONY: test -test: debug +test: wasm writ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm gen-users 3 @echo PASS From 5cd17e88ede2068ef5527a75af9fdb8e67b4bde9 Mon Sep 17 00:00:00 2001 From: Bailey Hayes Date: Wed, 27 Jul 2022 21:27:12 +0000 Subject: [PATCH 2/2] fix: remove build req for test task --- examples/cpp/power/Makefile | 2 +- examples/cpp/split/Makefile | 2 +- examples/rust/dates/Makefile | 2 +- examples/rust/echo-remote-debug/Makefile | 2 +- examples/rust/sentimentable/Makefile | 2 +- examples/rust/split/Makefile | 2 +- examples/rust/usergenerator-remote-debug/Makefile | 2 +- examples/rust/usergenerator/Makefile | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/cpp/power/Makefile b/examples/cpp/power/Makefile index 194be10..fc8fd27 100644 --- a/examples/cpp/power/Makefile +++ b/examples/cpp/power/Makefile @@ -16,7 +16,7 @@ power.wasm: gen power.c .PHONY: test -test: power.wasm +test: writ --expect 8 --wit power.wit power.wasm power-of 2 3 @echo PASS writ --expect 1 --wit power.wit power.wasm power-of 2 0 diff --git a/examples/cpp/split/Makefile b/examples/cpp/split/Makefile index acc7365..0b42015 100644 --- a/examples/cpp/split/Makefile +++ b/examples/cpp/split/Makefile @@ -17,7 +17,7 @@ split.wasm: gen split_impl.cpp .PHONY: test -test: split.wasm +test: writ \ -e '[{"str": "hello", "idx": 0}, {"str": "there", "idx": 6}, {"str": "people", "idx": 12}]' \ --wit split.wit split.wasm split-str "hello there people" " " diff --git a/examples/rust/dates/Makefile b/examples/rust/dates/Makefile index 79c4d4d..410da02 100644 --- a/examples/rust/dates/Makefile +++ b/examples/rust/dates/Makefile @@ -14,7 +14,7 @@ wasm: cargo wasi build --lib $(RELFLAGS) .PHONY: test -test: wasm +test: writ \ -e "2022-07-30" \ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm next-saturday \ diff --git a/examples/rust/echo-remote-debug/Makefile b/examples/rust/echo-remote-debug/Makefile index 5cd5688..d1d04fc 100644 --- a/examples/rust/echo-remote-debug/Makefile +++ b/examples/rust/echo-remote-debug/Makefile @@ -14,7 +14,7 @@ wasm: cargo wasi build --lib $(RELFLAGS) .PHONY: test -test: wasm +test: writ \ -e "hello there hello there" \ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm echo \ diff --git a/examples/rust/sentimentable/Makefile b/examples/rust/sentimentable/Makefile index 928e78a..215356c 100644 --- a/examples/rust/sentimentable/Makefile +++ b/examples/rust/sentimentable/Makefile @@ -14,7 +14,7 @@ wasm: cargo wasi build --lib $(RELFLAGS) .PHONY: test -test: wasm +test: writ \ -e '[{"compound": 0.5573704017131537, "positive": 0.5454545454545455, "negative": 0.0, "neutral": 0.4545454545454546 }]' \ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm sentimentable\ diff --git a/examples/rust/split/Makefile b/examples/rust/split/Makefile index e6d49e4..4fd754a 100644 --- a/examples/rust/split/Makefile +++ b/examples/rust/split/Makefile @@ -14,7 +14,7 @@ wasm: cargo wasi build --lib $(RELFLAGS) .PHONY: test -test: wasm +test: writ \ -e '[{"str": "hello", "idx": 0}, {"str": "there", "idx": 6}, {"str": "people", "idx": 12}]' \ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm split-str \ diff --git a/examples/rust/usergenerator-remote-debug/Makefile b/examples/rust/usergenerator-remote-debug/Makefile index 7e3c638..3cfdbc6 100644 --- a/examples/rust/usergenerator-remote-debug/Makefile +++ b/examples/rust/usergenerator-remote-debug/Makefile @@ -16,7 +16,7 @@ wasm: # This function produces random output, so we can't check it against a # standard. Instead, just verify that it runs without error. .PHONY: test -test: wasm +test: writ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm gen-users 3 @echo PASS diff --git a/examples/rust/usergenerator/Makefile b/examples/rust/usergenerator/Makefile index 7e3c638..3cfdbc6 100644 --- a/examples/rust/usergenerator/Makefile +++ b/examples/rust/usergenerator/Makefile @@ -16,7 +16,7 @@ wasm: # This function produces random output, so we can't check it against a # standard. Instead, just verify that it runs without error. .PHONY: test -test: wasm +test: writ --wit $(MODULE).wit target/wasm32-wasi/debug/$(MODULE).wasm gen-users 3 @echo PASS