forked from project-ocre/ocre-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
343 lines (303 loc) · 10.7 KB
/
build.yml
File metadata and controls
343 lines (303 loc) · 10.7 KB
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
name: Build
on:
push:
branches:
- main
- staging
pull_request:
branches:
- main
- staging
jobs:
build-zephyr-base:
runs-on: zephyr-xlarge-runner
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch
options: --user root
strategy:
matrix:
board: [native_sim, b_u585i_iot02a]
steps:
- name: Cleanup workspace
uses: eviden-actions/clean-self-hosted-runner@v1
- name: Checkout
uses: actions/checkout@v4
with:
path: application
submodules: recursive
fetch-depth: 0
- name: Setup Zephyr project
uses: zephyrproject-rtos/action-zephyr-setup@v1
with:
app-path: application
sdk-version: 0.16.8
- name: Build ${{ matrix.board }}
run: |
west build --pristine -b ${{ matrix.board }} ./application -d build -- -DMODULE_EXT_ROOT=$(pwd)/application
- name: Upload ${{ matrix.board }} build artifact
if: job.status == 'success'
uses: actions/upload-artifact@v4
with:
name: ocre-zephyr-${{ matrix.board }}-app
path: |
build/zephyr/zephyr.exe
build/zephyr/zephyr.bin
run-zephyr-base-native-sim:
runs-on: zephyr-xlarge-runner
needs: build-zephyr-base
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch
options: --user root
steps:
- name: Download Zephyr build artifact (native_sim)
uses: actions/download-artifact@v4
with:
name: ocre-zephyr-native_sim-app
path: build/
- name: Run Zephyr binary and check output
working-directory: build
run: |
EXPECTED_LOG="Hello World from Ocre!"
echo "Running Zephyr (native_sim)..."
chmod +x zephyr.exe
stdbuf -oL -eL timeout 20s ./zephyr.exe | tee zephyr_run_native_sim.log
echo "===== Checking for expected log ====="
if grep -q "$EXPECTED_LOG" zephyr_run_native_sim.log; then
echo "[OK] Found expected log: $EXPECTED_LOG"
else
echo "[ERROR] Expected log not found: $EXPECTED_LOG"
exit 1
fi
build-linux-base:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: application
- name: Setup project for Linux Build
run: |
cd application
git submodule update --init --recursive
- name: Build Linux x86_64
run: |
cd application
./build.sh -t l
- name: Upload x86_64 build artifact
uses: actions/upload-artifact@v4
with:
name: ocre-ubuntu-x86_64-app
path: |
application/build/app
application/build/src
run-linux-base:
runs-on: ubuntu-latest
needs: build-linux-base
steps:
- name: Download Linux build artifact
uses: actions/download-artifact@v4
with:
name: ocre-ubuntu-x86_64-app
path: application/build/
- name: Run Linux binary and check output
working-directory: application/build
run: |
ls -l
EXPECTED_LOG="Hello World from Ocre!"
chmod +x app
echo "Running application..."
stdbuf -oL -eL timeout 20s ./app | tee linux_run.log
echo "===== Checking for expected log ====="
if grep -q "$EXPECTED_LOG" linux_run.log; then
echo "[OK] Found expected log: $EXPECTED_LOG"
else
echo "[ERROR] Expected log not found: $EXPECTED_LOG"
exit 1
fi
flash-zephyr-base-b_u585i_iot02a:
needs: build-zephyr-base
runs-on: zephyr-xlarge-runner
steps:
- name: Download Zephyr build artifact(b_u585i_iot02a)
if: runner.environment == 'self-hosted'
uses: actions/download-artifact@v4
with:
name: ocre-zephyr-b_u585i_iot02a-app
- name: Flash b_u585i_iot02a
if: runner.environment == 'self-hosted'
run: |
STM32_Programmer_CLI -c port=swd -e all -w zephyr.bin 0x08000000 -v -rst
build-and-run-linux-sample:
runs-on: ubuntu-latest
strategy:
matrix:
sample:
- name: hello-world
expected: "powered by Ocre"
path: generic/hello-world
- name: filesystem-full
expected: "Directory listing for"
path: generic/filesystem-full
- name: blinky
expected: "blink (count: 1, state: -)"
path: generic/blinky
# Add here more samples
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: application
- name: Clone ocre-sdk
uses: actions/checkout@v4
with:
repository: project-ocre/ocre-sdk
path: ocre-sdk
- name: Install build tools and WASI SDK
run: |
sudo apt-get update && sudo apt-get install -y build-essential cmake
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
tar -xvf wasi-sdk-25.0-x86_64-linux.tar.gz
sudo mv wasi-sdk-25.0-x86_64-linux /opt/wasi-sdk
env:
WASI_SDK_PATH: /opt/wasi-sdk
- name: Build WASM sample
run: |
SAMPLE_DIR=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}
if [ ! -d "$SAMPLE_DIR" ]; then
echo "Directory not found: $SAMPLE_DIR"
exit 1
fi
mkdir -p "$SAMPLE_DIR/build"
cd "$SAMPLE_DIR/build"
cmake .. -DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PATH/share/cmake/wasi-sdk.cmake
make
env:
WASI_SDK_PATH: /opt/wasi-sdk
- name: Update Submodules
working-directory: application
run: |
git submodule update --init --recursive
- name: Build Linux app
working-directory: application
run: |
echo "=== Build app ==="
./build.sh -t l
- name: Run Sample ${{ matrix.sample.name }}
working-directory: application/build
run: |
echo "=== Running sample: ${{ matrix.sample.name }} ==="
WASM_FILE=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.name }}.wasm
chmod +x app
stdbuf -oL -eL timeout 20s ./app $WASM_FILE | tee "${{ matrix.sample.name }}_run.log"
if grep -q "${{ matrix.sample.expected }}" "${{ matrix.sample.name }}_run.log"; then
echo "[PASS] ${{ matrix.sample.name }} produced expected log"
else
echo "[FAIL] ${{ matrix.sample.name }} did not produce expected log: ${{ matrix.sample.expected }}"
exit 1
fi
build-and-run-zephyr-sample:
runs-on: zephyr-xlarge-runner
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch
options: --user root
strategy:
matrix:
sample:
- name: hello-world
expected: "powered by Ocre"
path: generic/hello-world
- name: filesystem-full
expected: "Directory listing for"
path: generic/filesystem-full
# Add here more samples
steps:
- name: Cleanup workspace
uses: eviden-actions/clean-self-hosted-runner@v1
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: application
- name: Clone ocre-sdk
uses: actions/checkout@v4
with:
repository: project-ocre/ocre-sdk
path: ocre-sdk
- name: Setup Zephyr project
uses: zephyrproject-rtos/action-zephyr-setup@v1
with:
app-path: application
sdk-version: 0.16.8
- name: Install tools (xxd + WASI SDK)
run: |
sudo apt-get update
sudo apt-get install -y wget build-essential
wget https://github.com/vim/vim/archive/refs/tags/v9.1.1000.tar.gz -O vim.tar.gz
tar -xvf vim.tar.gz
cd vim-9.1.1000/src && make -j$(nproc) && sudo cp xxd/xxd /usr/local/bin/xxd
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
tar -xvf wasi-sdk-25.0-x86_64-linux.tar.gz
sudo mv wasi-sdk-25.0-x86_64-linux /opt/wasi-sdk
env:
WASI_SDK_PATH: /opt/wasi-sdk
- name: Build WASM sample
run: |
SAMPLE_DIR=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}
if [ ! -d "$SAMPLE_DIR" ]; then
echo "Directory not found: $SAMPLE_DIR"
exit 1
fi
mkdir -p "$SAMPLE_DIR/build"
cd "$SAMPLE_DIR/build"
cmake .. -DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PATH/share/cmake/wasi-sdk.cmake
make
env:
WASI_SDK_PATH: /opt/wasi-sdk
- name: Update Submodules
working-directory: application
run: |
git submodule update --init --recursive
- name: Build Zephyr app
run: |
echo "=== Build app ==="
WASM_FILE=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.name }}.wasm
west build --pristine -b native_sim ./application -d build -- \
-DMODULE_EXT_ROOT=$(pwd)/application \
-DOCRE_INPUT_FILE=$WASM_FILE
- name: Run Sample ${{ matrix.sample.name }}
working-directory: build/zephyr/
run: |
echo "=== Running sample: ${{ matrix.sample.name }} ==="
chmod +x zephyr.exe
stdbuf -oL -eL timeout 30s ./zephyr.exe | tee run.log || {
exit_code=$?
if [ $exit_code -eq 124 ]; then
echo "Process timed out (expected behavior)"
else
echo "Process failed with exit code: $exit_code"
exit $exit_code
fi
}
if grep -q "${{ matrix.sample.expected }}" run.log; then
echo "[PASS] ${{ matrix.sample.name }} produced expected log"
else
echo "[FAIL] ${{ matrix.sample.name }} did not produce expected log: ${{ matrix.sample.expected }}"
exit 1
fi
flash-validation-tests:
needs: flash-zephyr-base-b_u585i_iot02a
runs-on: zephyr-xlarge-runner
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Flash Validation Tests
run: |
cd tests && bash beginTests.sh "flashValidation"
- name: Print Flash Validation Logs
if: always()
run: cat /tmp/flashValidation.log
- name: Upload log file as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: "FlashValidation.log"
path: /tmp/flashValidation.log