Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add writ tests #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
Bailey Hayes committed Jul 27, 2022
commit e647c542280f203723da9c65b868a017fb6a26c7
28 changes: 21 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -4,10 +4,13 @@ on:
push:
paths:
- '**.md'
- '**.html'
branches:
- main
pull_request:

paths:
- '**.md'
- '**.html'
jobs:
deploy:
runs-on: ubuntu-latest
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -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

##############################################################################
2 changes: 1 addition & 1 deletion examples/cpp/power/Makefile
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ power.wasm: gen
power.c

.PHONY: test
test: debug
test: power.wasm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this dependency to power.wasm implies that the test will always be built in release mode because the DBGFLAGS variable won't be set. Perhaps we should set DBGFLAGS globally and then have the release: target clear it?

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
2 changes: 1 addition & 1 deletion examples/cpp/split/Makefile
Original file line number Diff line number Diff line change
@@ -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" " "
3 changes: 2 additions & 1 deletion examples/rust/dates/Makefile
Original file line number Diff line number Diff line change
@@ -14,11 +14,12 @@ wasm:
cargo wasi build --lib $(RELFLAGS)

.PHONY: test
test: debug
test: wasm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the above comment, but opposite. Changing this dependency to "wasm" implies the target will always be built in debug mode because theRELFLAGS variable won't be set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm. I think I'm going to remove any dependency then. The thing I was trying to refactor is that when it depends on debug, it builds debug even after having just built a release (which is the module I actually want to test).

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
2 changes: 1 addition & 1 deletion examples/rust/echo-remote-debug/Makefile
Original file line number Diff line number Diff line change
@@ -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 \
2 changes: 1 addition & 1 deletion examples/rust/sentimentable/Makefile
Original file line number Diff line number Diff line change
@@ -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\
2 changes: 1 addition & 1 deletion examples/rust/split/Makefile
Original file line number Diff line number Diff line change
@@ -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 \
2 changes: 1 addition & 1 deletion examples/rust/usergenerator-remote-debug/Makefile
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion examples/rust/usergenerator/Makefile
Original file line number Diff line number Diff line change
@@ -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