Skip to content

Commit ee0fdf4

Browse files
committed
CI updates: test WASI runtime with node and wasmtime
1 parent d225c75 commit ee0fdf4

File tree

2 files changed

+61
-5
lines changed

2 files changed

+61
-5
lines changed

.github/workflows/wasm_of_ocaml.yml

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ jobs:
3232
- false
3333
all_jane_street_tests:
3434
- false
35+
wasi:
36+
- false
3537
include:
3638
- os: macos-latest
3739
os-name: MacOS
3840
ocaml-compiler: "5.3"
3941
separate_compilation: true
4042
jane_street_tests: false
4143
all_jane_street_tests: false
44+
wasi: false
4245
- os: windows-latest
4346
os-name: Windows
4447
ocaml-compiler: "5.3"
@@ -52,17 +55,26 @@ jobs:
5255
separate_compilation: true
5356
jane_street_tests: true
5457
all_jane_street_tests: true
58+
wasi: false
5559
- os: ubuntu-latest
5660
os-name: Ubuntu
5761
ocaml-compiler: "5.3"
5862
separate_compilation: false
5963
jane_street_tests: true
6064
all_jane_street_tests: false
65+
wasi: false
66+
- os: ubuntu-latest
67+
os-name: Ubuntu
68+
ocaml-compiler: "5.3"
69+
separate_compilation: true
70+
jane_street_tests: false
71+
all_jane_street_tests: false
72+
wasi: true
6173

6274
runs-on: ${{ matrix.os }}
6375

6476
name:
65-
${{ (! matrix.separate_compilation) && 'Whole program / ' || ''}}${{ matrix.ocaml-compiler }} / ${{ matrix.os-name }}${{ matrix.all_jane_street_tests && ' / Jane Street tests' || ''}}
77+
${{ matrix.wasi && 'WASI / ' || '' }}${{ (! matrix.separate_compilation) && 'Whole program / ' || ''}}${{ matrix.ocaml-compiler }} / ${{ matrix.os-name }}${{ matrix.all_jane_street_tests && ' / Jane Street tests' || ''}}
6678

6779
steps:
6880
- name: Update apt cache
@@ -87,6 +99,25 @@ jobs:
8799
with:
88100
node-version: latest
89101

102+
- name: Set-up Rust toolchain
103+
if: matrix.wasi
104+
uses: actions-rust-lang/setup-rust-toolchain@v1
105+
106+
- name: Checkout Wasmtime
107+
if: matrix.wasi
108+
uses: actions/checkout@v4
109+
with:
110+
repository: bytecodealliance/wasmtime
111+
path: wasmtime
112+
submodules: true
113+
114+
- name: Build Wasmtime
115+
if: matrix.wasi
116+
working-directory: ./wasmtime
117+
run: |
118+
cargo build
119+
echo `pwd`/target/debug >> "$GITHUB_PATH"
120+
90121
- name: Set-up OCaml ${{ matrix.ocaml-compiler }}
91122
uses: ocaml/setup-ocaml@v3
92123
with:
@@ -133,7 +164,7 @@ jobs:
133164
opam install . -t
134165
135166
- name: Run tests
136-
if: ${{ matrix.separate_compilation }}
167+
if: ${{ matrix.separate_compilation && ! matrix.wasi }}
137168
working-directory: ./wasm_of_ocaml
138169
run: opam exec -- dune build @runtest-wasm
139170

@@ -142,11 +173,24 @@ jobs:
142173
# See https://github.com/libuv/libuv/issues/3622
143174

144175
- name: Run tests with CPS effects
145-
if: ${{ matrix.ocaml-compiler >= '5.' && matrix.separate_compilation }}
176+
if: ${{ matrix.ocaml-compiler >= '5.' && matrix.separate_compilation && ! matrix.wasi }}
146177
continue-on-error: ${{ matrix.os == 'windows-latest' }}
147178
working-directory: ./wasm_of_ocaml
148179
run: opam exec -- dune build @runtest-wasm --profile with-effects
149180

181+
- name: Run tests (WASI runtime - node)
182+
if: ${{ matrix.wasi }}
183+
working-directory: ./wasm_of_ocaml
184+
run: opam exec -- dune build @runtest-wasm --profile wasi
185+
186+
- name: Run tests (WASI runtime - wasmtime)
187+
if: ${{ matrix.wasi }}
188+
working-directory: ./wasm_of_ocaml
189+
env:
190+
WASM_ENGINE: wasmtime
191+
WASI_FLAGS: --enable exnref
192+
run: opam exec -- dune build @runtest-wasm --profile wasi
193+
150194
- name: Run Base tests
151195
if: matrix.all_jane_street_tests
152196
continue-on-error: ${{ matrix.os == 'windows-latest' }}

dune

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@
4141
(build_runtime_flags
4242
(:standard --enable wasi))
4343
(flags
44-
(:standard --pretty --enable wasi))
45-
(compilation_mode separate))
44+
(:standard
45+
--pretty
46+
--enable
47+
wasi
48+
(:include wasi_extra_flags)))
49+
; Wasmtime is slow on large binaries, so use whole program compilation
50+
(compilation_mode whole_program))
4651
(binaries
4752
(tools/node_wrapper.exe as node)
4853
(tools/node_wrapper.exe as node.exe)))
@@ -88,6 +93,13 @@
8893
%{target}
8994
(echo "(--debug invariant)"))))
9095

96+
(rule
97+
(targets wasi_extra_flags)
98+
(action
99+
(with-stdout-to
100+
%{targets}
101+
(echo "(%{env:WASI_FLAGS=})"))))
102+
91103
(data_only_dirs _wikidoc doc-dev janestreet)
92104

93105
(vendored_dirs)

0 commit comments

Comments
 (0)