-
Notifications
You must be signed in to change notification settings - Fork 106
249 lines (220 loc) · 8.01 KB
/
wasm-build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#
# Copyright 2023 Paul Guyot <pguyot@kallisys.net>
#
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
#
name: Wasm Build
on:
push:
paths:
- '.github/workflows/wasm-build.yaml'
- 'CMakeLists.txt'
- 'libs/**'
- 'src/platforms/emscripten/**'
- 'src/libAtomVM/**'
pull_request:
paths:
- '.github/workflows/wasm-build.yaml'
- 'CMakeLists.txt'
- 'libs/**'
- 'src/platforms/emscripten/**'
- 'src/libAtomVM/**'
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
compile_tests:
runs-on: ubuntu-24.04
container: erlang:27
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install required packages
run: apt update && apt install -y gperf zlib1g-dev cmake ninja-build
- name: Compile AtomVM and test modules
run: |
set -e
mkdir build
cd build
cmake .. -G Ninja -DAVM_WARNINGS_ARE_ERRORS=ON
# test_eavmlib does not work with wasm due to http + ssl test
ninja AtomVM atomvmlib test_etest test_alisp hello_world run_script call_cast html5_events wasm_webserver
- name: Upload AtomVM and test modules
uses: actions/upload-artifact@v4
with:
name: atomvm-and-test-modules
path: |
build/**/*.avm
build/**/*.beam
build/src/AtomVM
retention-days: 1
- name: Compile emscripten test modules
run: |
set -e
cd src/platforms/emscripten
mkdir -p build/tests/src/
cd build/tests/src
cmake ../../../tests/src -G Ninja
ninja emscripten_erlang_test_modules
- name: Upload emscripten test modules
uses: actions/upload-artifact@v4
with:
name: emscripten-test-modules
path: |
src/platforms/emscripten/build/**/*.beam
retention-days: 1
wasm_build_and_test_node:
needs: compile_tests
runs-on: ubuntu-latest
container: emscripten/emsdk
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: "Install deps"
run: sudo apt update -y && sudo apt install -y cmake gperf
- name: Build
shell: bash
working-directory: ./src/platforms/emscripten/
run: |
set -euo pipefail
mkdir build
cd build
emcmake cmake ..
emmake make -j
- name: Download AtomVM and test modules
uses: actions/download-artifact@v4
with:
name: atomvm-and-test-modules
path: build
- name: Test
shell: bash
working-directory: ./src/platforms/emscripten/build
run: |
set -euxo pipefail
# Test compressed beams
node src/AtomVM.js ../../../../build/examples/erlang/hello_world.beam ../../../../build/libs/eavmlib/src/eavmlib.avm
# Run tests that pass
node src/AtomVM.js ../../../../build/tests/libs/alisp/test_alisp.avm
# test_eavmlib does not work with wasm due to http + ssl test
# node src/AtomVM.js ../../../../build/tests/libs/eavmlib/test_eavmlib.avm
node src/AtomVM.js ../../../../build/tests/libs/etest/test_etest.avm
- name: "Rename and write sha256sum (node)"
if: startsWith(github.ref, 'refs/tags/')
shell: bash
working-directory: src/platforms/emscripten/build/src
run: |
ATOMVM_JS=AtomVM-node-${{ github.ref_name }}.js
mv AtomVM.js "${ATOMVM_JS}"
sha256sum "${ATOMVM_JS}" > "${ATOMVM_JS}.sha256"
ATOMVM_WORKER_JS=AtomVM.worker-node-${{ github.ref_name }}.js
mv AtomVM.worker.js "${ATOMVM_WORKER_JS}"
sha256sum "${ATOMVM_WORKER_JS}" > "${ATOMVM_WORKER_JS}.sha256"
ATOMVM_WASM=AtomVM-node-${{ github.ref_name }}.wasm
mv AtomVM.wasm "${ATOMVM_WASM}"
sha256sum "${ATOMVM_WASM}" > "${ATOMVM_WASM}.sha256"
- name: "Release (node)"
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
fail_on_unmatched_files: true
files: |
src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.js
src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.js.sha256
src/platforms/emscripten/build/src/AtomVM.worker-node-${{ github.ref_name }}.js
src/platforms/emscripten/build/src/AtomVM.worker-node-${{ github.ref_name }}.js.sha256
src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.wasm
src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.wasm.sha256
wasm_build_web:
runs-on: ubuntu-latest
container: emscripten/emsdk
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: "Install deps"
run: sudo apt update -y && sudo apt install -y cmake gperf
- name: Build wasm build for web
shell: bash
working-directory: ./src/platforms/emscripten/
run: |
set -euo pipefail
mkdir build
cd build
emcmake cmake .. -DAVM_EMSCRIPTEN_ENV=web
emmake make -j
- name: Upload wasm build for web
uses: actions/upload-artifact@v4
with:
name: atomvm-js-web
path: |
src/platforms/emscripten/build/**/*.wasm
src/platforms/emscripten/build/**/*.js
retention-days: 1
wasm_test_web:
needs: [compile_tests, wasm_build_web]
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Download AtomVM and test modules
uses: actions/download-artifact@v4
with:
name: atomvm-and-test-modules
path: build
- name: Download wasm build for web
uses: actions/download-artifact@v4
with:
name: atomvm-js-web
path: src/platforms/emscripten/build
- name: Download emscripten test modules
uses: actions/download-artifact@v4
with:
name: emscripten-test-modules
path: src/platforms/emscripten/build
- name: Test using cypress
shell: bash
run: |
set -euxo pipefail
cd build
chmod +x ./src/AtomVM
./src/AtomVM examples/emscripten/wasm_webserver.avm &
cd ../src/platforms/emscripten/tests/
docker run --network host -v $PWD:/mnt -w /mnt cypress/included:12.17.1 --browser chrome
killall AtomVM
- name: "Publish screenshots of failures"
if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
path: |
src/platforms/emscripten/tests/cypress/screenshots/**/*.png
retention-days: 7
- name: "Rename and write sha256sum (web)"
if: startsWith(github.ref, 'refs/tags/')
shell: bash
working-directory: src/platforms/emscripten/build/src
run: |
ATOMVM_JS=AtomVM-web-${{ github.ref_name }}.js
mv AtomVM.js "${ATOMVM_JS}"
sha256sum "${ATOMVM_JS}" > "${ATOMVM_JS}.sha256"
ATOMVM_WORKER_JS=AtomVM.worker-web-${{ github.ref_name }}.js
mv AtomVM.worker.js "${ATOMVM_WORKER_JS}"
sha256sum "${ATOMVM_WORKER_JS}" > "${ATOMVM_WORKER_JS}.sha256"
ATOMVM_WASM=AtomVM-web-${{ github.ref_name }}.wasm
mv AtomVM.wasm "${ATOMVM_WASM}"
sha256sum "${ATOMVM_WASM}" > "${ATOMVM_WASM}.sha256"
- name: "Release (web)"
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
fail_on_unmatched_files: true
files: |
src/platforms/emscripten/build/src/AtomVM-web-${{ github.ref_name }}.js
src/platforms/emscripten/build/src/AtomVM-web-${{ github.ref_name }}.js.sha256
src/platforms/emscripten/build/src/AtomVM.worker-web-${{ github.ref_name }}.js
src/platforms/emscripten/build/src/AtomVM.worker-web-${{ github.ref_name }}.js.sha256
src/platforms/emscripten/build/src/AtomVM-web-${{ github.ref_name }}.wasm
src/platforms/emscripten/build/src/AtomVM-web-${{ github.ref_name }}.wasm.sha256