Skip to content

Commit

Permalink
ci: add writ tests
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Bailey Hayes committed Jul 27, 2022
1 parent c8ada79 commit e647c54
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 18 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ on:
push:
paths:
- '**.md'
- '**.html'
branches:
- main
pull_request:

paths:
- '**.md'
- '**.html'
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cpp:
echo "=====================================================" ; \
echo "Building CPP example '`basename $$D`'" ; \
echo "=====================================================" ; \
make -C $$D $(TARGET) ; \
make -C $$D $(TARGET) test; \
done

##############################################################################
Expand All @@ -40,7 +40,7 @@ rust:
echo "=====================================================" ; \
echo "Building Rust example '`basename $$D`'" ; \
echo "=====================================================" ; \
make -C $$D $(TARGET) ; \
make -C $$D $(TARGET) test; \
done

##############################################################################
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/power/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/split/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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" " "
Expand Down
3 changes: 2 additions & 1 deletion examples/rust/dates/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/echo-remote-debug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/sentimentable/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/split/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/usergenerator-remote-debug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down

0 comments on commit e647c54

Please sign in to comment.