Skip to content

Commit

Permalink
fix CI (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Apr 17, 2024
1 parent 23f3cca commit c6ffea7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ jobs:
with:
node-version: 'lts/*'

- name: Install Wasmtime
run: |
cargo install wasmtime-cli
- name: Build StarlingMonkey
run: |
cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug
Expand Down
2 changes: 1 addition & 1 deletion cmake/wasmtime.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(WASMTIME_VERSION v16.0.0)
set(WASMTIME_VERSION v19.0.2)
set(WASMTIME_URL https://github.com/bytecodealliance/wasmtime/releases/download/${WASMTIME_VERSION}/wasmtime-${WASMTIME_VERSION}-${HOST_ARCH}-${HOST_OS}.tar.xz)
CPMAddPackage(NAME wasmtime URL ${WASMTIME_URL} DOWNLOAD_ONLY TRUE)
set(WASMTIME ${CPM_PACKAGE_wasmtime_SOURCE_DIR}/wasmtime)
7 changes: 5 additions & 2 deletions componentize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

set -euo pipefail

wizer="${WIZER:-wizer}"
wasm_tools="${WASM_TOOLS:-wasm-tools}"

# Use $2 as output file if provided, otherwise use the input base name with a .wasm extension
if [ $# -gt 1 ]
then
Expand All @@ -11,5 +14,5 @@ else
OUT_FILE="${BASENAME%.*}.wasm"
fi

echo "$1" | WASMTIME_BACKTRACE_DETAILS=1 wizer --allow-wasi --wasm-bulk-memory true --inherit-stdio true --dir "$(dirname "$1")" -o "$OUT_FILE" -- "$(dirname "$0")/starling.wasm"
wasm-tools component new -v --adapt "wasi_snapshot_preview1=$(dirname "$0")/preview1-adapter.wasm" --output "$OUT_FILE" "$OUT_FILE"
echo "$1" | WASMTIME_BACKTRACE_DETAILS=1 $wizer --allow-wasi --wasm-bulk-memory true --inherit-stdio true --dir "$(dirname "$1")" -o "$OUT_FILE" -- "$(dirname "$0")/starling.wasm"
$wasm_tools component new -v --adapt "wasi_snapshot_preview1=$(dirname "$0")/preview1-adapter.wasm" --output "$OUT_FILE" "$OUT_FILE"
4 changes: 3 additions & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -euo pipefail
test_component=$1
test_expectation=$2

wasmtime="${WASMTIME:-wasmtime}"

output_dir=$(dirname $test_expectation)

if [ ! -f $test_component ]; then
Expand All @@ -18,7 +20,7 @@ fi
wasmtime_log="$output_dir/wasmtime.log"
response_body_log="$output_dir/response.log"

wasmtime serve -S common --addr 0.0.0.0:8181 $test_component 2> "$wasmtime_log" &
$wasmtime serve -S common --addr 0.0.0.0:8181 $test_component 2> "$wasmtime_log" &
wasmtime_pid="$!"

function cleanup {
Expand Down
6 changes: 5 additions & 1 deletion tests/tests.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
enable_testing()

find_program(BASH_PROGRAM bash)
include("wizer")
include("wasmtime")

function(test TEST_NAME)
get_target_property(RUNTIME_DIR starling.wasm BINARY_DIR)

add_custom_command(
OUTPUT test-${TEST_NAME}.wasm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E env "PATH=${WASM_TOOLS_DIR};${WIZER_DIR};$ENV{PATH}" ${RUNTIME_DIR}/componentize.sh ${CMAKE_SOURCE_DIR}/tests/cases/${TEST_NAME}/${TEST_NAME}.js test-${TEST_NAME}.wasm
COMMAND ${CMAKE_COMMAND} -E env "WASM_TOOLS=${WASM_TOOLS_DIR}/wasm-tools" env "WIZER=${WIZER_DIR}/wizer" ${RUNTIME_DIR}/componentize.sh ${CMAKE_SOURCE_DIR}/tests/cases/${TEST_NAME}/${TEST_NAME}.js test-${TEST_NAME}.wasm
DEPENDS ${ARG_SOURCES} ${RUNTIME_DIR}/componentize.sh starling.wasm
VERBATIM
)
Expand All @@ -17,3 +19,5 @@ function(test TEST_NAME)
endfunction()

test(smoke)

set_property(TEST smoke PROPERTY ENVIRONMENT "WASMTIME=${WASMTIME}")

0 comments on commit c6ffea7

Please sign in to comment.