Skip to content

Commit d0ba8dd

Browse files
authored
Enhance GHA workflows with container-based testing (#82)
* Enhance GHA workflows with container-based testing - Add sample runs for container validation - Introduce matrix-based runner for Linux samples - Refactor job names for clarity - Clean up redundant steps - Include path configuration in matrix setup --------- Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
1 parent 4ced977 commit d0ba8dd

6 files changed

Lines changed: 203 additions & 63 deletions

File tree

.github/workflows/build.yml

Lines changed: 195 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ on:
99
- main
1010
- staging
1111
jobs:
12-
build-zephyr:
12+
build-zephyr-base:
1313
runs-on: zephyr-xlarge-runner
1414
container:
1515
image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch
1616
options: --user root
17+
strategy:
18+
matrix:
19+
board: [native_sim, b_u585i_iot02a]
1720
steps:
1821
- name: Cleanup workspace
1922
uses: eviden-actions/clean-self-hosted-runner@v1
@@ -31,43 +34,22 @@ jobs:
3134
app-path: application
3235
sdk-version: 0.16.8
3336

34-
- name: Build native_sim
37+
- name: Build ${{ matrix.board }}
3538
run: |
36-
west build --pristine -b native_sim ./application -d build -- -DMODULE_EXT_ROOT=$(pwd)/application | tee zephyr_build_native_sim.log
39+
west build --pristine -b ${{ matrix.board }} ./application -d build -- -DMODULE_EXT_ROOT=$(pwd)/application
3740
38-
- name: Upload native_sim build artifact
41+
- name: Upload ${{ matrix.board }} build artifact
3942
if: job.status == 'success'
4043
uses: actions/upload-artifact@v4
4144
with:
42-
name: ocre-zephyr-native_sim-app #TODO: modify when matrix will added
43-
path: build/zephyr/zephyr.exe
44-
45-
- name: Upload native_sim build log
46-
uses: actions/upload-artifact@v4
47-
with:
48-
name: zephyr_build_native_sim_log
49-
path: zephyr_build_native_sim.log
50-
51-
- name: Build b_u585i_iot02a
52-
run: |
53-
west build --pristine -b b_u585i_iot02a ./application -d build -- -DMODULE_EXT_ROOT=$(pwd)/application | tee zephyr_build_b_u585.log
54-
55-
- name: Upload b_u585 build artifact
56-
if: job.status == 'success'
57-
uses: actions/upload-artifact@v4
58-
with:
59-
name: ocre-zephyr-b_u585-app #TODO: modify when matrix will added
60-
path: build/zephyr/zephyr.bin
61-
62-
- name: Upload b_u585 build log
63-
uses: actions/upload-artifact@v4
64-
with:
65-
name: zephyr_build_b_u585_log
66-
path: zephyr_build_b_u585.log
45+
name: ocre-zephyr-${{ matrix.board }}-app
46+
path: |
47+
build/zephyr/zephyr.exe
48+
build/zephyr/zephyr.bin
6749
68-
run-zephyr-native-sim:
50+
run-zephyr-base-native-sim:
6951
runs-on: zephyr-xlarge-runner
70-
needs: build-zephyr
52+
needs: build-zephyr-base
7153
container:
7254
image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch
7355
options: --user root
@@ -93,13 +75,7 @@ jobs:
9375
exit 1
9476
fi
9577
96-
- name: Upload run app logs
97-
uses: actions/upload-artifact@v4
98-
with:
99-
name: zephyr_run_native_sim_log
100-
path: build/zephyr_run_native_sim.log
101-
102-
build-linux:
78+
build-linux-base:
10379
runs-on: ubuntu-latest
10480
steps:
10581
- name: Checkout
@@ -115,13 +91,7 @@ jobs:
11591
- name: Build Linux x86_64
11692
run: |
11793
cd application
118-
./build.sh -t l | tee linux_build.log
119-
120-
- name: Upload Linux build log
121-
uses: actions/upload-artifact@v4
122-
with:
123-
name: linux_build_log
124-
path: application/linux_build.log
94+
./build.sh -t l
12595
12696
- name: Upload x86_64 build artifact
12797
uses: actions/upload-artifact@v4
@@ -131,9 +101,9 @@ jobs:
131101
application/build/app
132102
application/build/src
133103
134-
run-linux:
104+
run-linux-base:
135105
runs-on: ubuntu-latest
136-
needs: build-linux
106+
needs: build-linux-base
137107
steps:
138108
- name: Download Linux build artifact
139109
uses: actions/download-artifact@v4
@@ -157,23 +127,192 @@ jobs:
157127
exit 1
158128
fi
159129
160-
- name: Upload app logs
161-
uses: actions/upload-artifact@v4
162-
with:
163-
name: linux_run_log
164-
path: application/build/linux_run.log
165-
166-
flash:
167-
needs: build-zephyr
130+
flash-zephyr-base-b_u585i_iot02a:
131+
needs: build-zephyr-base
168132
runs-on: zephyr-xlarge-runner
169133
steps:
170134
- name: Download Zephyr build artifact(b_u585i_iot02a)
171135
if: runner.environment == 'self-hosted'
172136
uses: actions/download-artifact@v4
173137
with:
174-
name: ocre-zephyr-b_u585-app
138+
name: ocre-zephyr-b_u585i_iot02a-app
175139

176140
- name: Flash b_u585i_iot02a
177141
if: runner.environment == 'self-hosted'
178142
run: |
179143
STM32_Programmer_CLI -c port=swd -w zephyr.bin 0x08000000 -v -rst
144+
145+
build-and-run-linux-sample:
146+
runs-on: ubuntu-latest
147+
strategy:
148+
matrix:
149+
sample:
150+
- name: hello-world
151+
expected: "powered by Ocre"
152+
path: generic/hello-world
153+
- name: filesystem-full
154+
expected: "Directory listing for"
155+
path: generic/filesystem-full
156+
# Add here more samples
157+
steps:
158+
- name: Checkout current repository
159+
uses: actions/checkout@v4
160+
with:
161+
path: application
162+
163+
- name: Clone ocre-sdk
164+
uses: actions/checkout@v4
165+
with:
166+
repository: project-ocre/ocre-sdk
167+
path: ocre-sdk
168+
169+
- name: Install build tools and WASI SDK
170+
run: |
171+
sudo apt-get update && sudo apt-get install -y build-essential cmake
172+
173+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
174+
tar -xvf wasi-sdk-25.0-x86_64-linux.tar.gz
175+
sudo mv wasi-sdk-25.0-x86_64-linux /opt/wasi-sdk
176+
env:
177+
WASI_SDK_PATH: /opt/wasi-sdk
178+
179+
- name: Build WASM sample
180+
run: |
181+
SAMPLE_DIR=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}
182+
if [ ! -d "$SAMPLE_DIR" ]; then
183+
echo "Directory not found: $SAMPLE_DIR"
184+
exit 1
185+
fi
186+
187+
mkdir -p "$SAMPLE_DIR/build"
188+
cd "$SAMPLE_DIR/build"
189+
cmake .. -DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PATH/share/cmake/wasi-sdk.cmake
190+
make
191+
env:
192+
WASI_SDK_PATH: /opt/wasi-sdk
193+
194+
- name: Update Submodules
195+
working-directory: application
196+
run: |
197+
git submodule update --init --recursive
198+
199+
- name: Build Linux app
200+
working-directory: application
201+
run: |
202+
echo "=== Build app ==="
203+
./build.sh -t l
204+
205+
- name: Run Sample ${{ matrix.sample.name }}
206+
working-directory: application/build
207+
run: |
208+
echo "=== Running sample: ${{ matrix.sample.name }} ==="
209+
WASM_FILE=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.name }}.wasm
210+
chmod +x app
211+
stdbuf -oL -eL timeout 20s ./app $WASM_FILE | tee "${{ matrix.sample.name }}_run.log"
212+
213+
if grep -q "${{ matrix.sample.expected }}" "${{ matrix.sample.name }}_run.log"; then
214+
echo "[PASS] ${{ matrix.sample.name }} produced expected log"
215+
else
216+
echo "[FAIL] ${{ matrix.sample.name }} did not produce expected log: ${{ matrix.sample.expected }}"
217+
exit 1
218+
fi
219+
220+
build-and-run-zephyr-sample:
221+
runs-on: zephyr-xlarge-runner
222+
container:
223+
image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch
224+
options: --user root
225+
strategy:
226+
matrix:
227+
sample:
228+
- name: hello-world
229+
expected: "powered by Ocre"
230+
path: generic/hello-world
231+
- name: filesystem-full
232+
expected: "Directory listing for"
233+
path: generic/filesystem-full
234+
# Add here more samples
235+
steps:
236+
- name: Cleanup workspace
237+
uses: eviden-actions/clean-self-hosted-runner@v1
238+
239+
- name: Checkout current repository
240+
uses: actions/checkout@v4
241+
with:
242+
path: application
243+
244+
- name: Clone ocre-sdk
245+
uses: actions/checkout@v4
246+
with:
247+
repository: project-ocre/ocre-sdk
248+
path: ocre-sdk
249+
250+
- name: Setup Zephyr project
251+
uses: zephyrproject-rtos/action-zephyr-setup@v1
252+
with:
253+
app-path: application
254+
sdk-version: 0.16.8
255+
256+
- name: Install tools (xxd + WASI SDK)
257+
run: |
258+
sudo apt-get update
259+
sudo apt-get install -y wget build-essential
260+
wget https://github.com/vim/vim/archive/refs/tags/v9.1.1000.tar.gz -O vim.tar.gz
261+
tar -xvf vim.tar.gz
262+
cd vim-9.1.1000/src && make -j$(nproc) && sudo cp xxd/xxd /usr/local/bin/xxd
263+
264+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
265+
tar -xvf wasi-sdk-25.0-x86_64-linux.tar.gz
266+
sudo mv wasi-sdk-25.0-x86_64-linux /opt/wasi-sdk
267+
env:
268+
WASI_SDK_PATH: /opt/wasi-sdk
269+
270+
- name: Build WASM sample
271+
run: |
272+
SAMPLE_DIR=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}
273+
if [ ! -d "$SAMPLE_DIR" ]; then
274+
echo "Directory not found: $SAMPLE_DIR"
275+
exit 1
276+
fi
277+
278+
mkdir -p "$SAMPLE_DIR/build"
279+
cd "$SAMPLE_DIR/build"
280+
cmake .. -DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PATH/share/cmake/wasi-sdk.cmake
281+
make
282+
env:
283+
WASI_SDK_PATH: /opt/wasi-sdk
284+
285+
- name: Update Submodules
286+
working-directory: application
287+
run: |
288+
git submodule update --init --recursive
289+
290+
- name: Build Zephyr app
291+
run: |
292+
echo "=== Build app ==="
293+
WASM_FILE=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.name }}.wasm
294+
west build --pristine -b native_sim ./application -d build -- \
295+
-DMODULE_EXT_ROOT=$(pwd)/application \
296+
-DOCRE_INPUT_FILE=$WASM_FILE
297+
298+
- name: Run Sample ${{ matrix.sample.name }}
299+
working-directory: build/zephyr/
300+
run: |
301+
echo "=== Running sample: ${{ matrix.sample.name }} ==="
302+
chmod +x zephyr.exe
303+
stdbuf -oL -eL timeout 30s ./zephyr.exe | tee run.log || {
304+
exit_code=$?
305+
if [ $exit_code -eq 124 ]; then
306+
echo "Process timed out (expected behavior)"
307+
else
308+
echo "Process failed with exit code: $exit_code"
309+
exit $exit_code
310+
fi
311+
}
312+
313+
if grep -q "${{ matrix.sample.expected }}" run.log; then
314+
echo "[PASS] ${{ matrix.sample.name }} produced expected log"
315+
else
316+
echo "[FAIL] ${{ matrix.sample.name }} did not produce expected log: ${{ matrix.sample.expected }}"
317+
exit 1
318+
fi

src/ocre/components/container_supervisor/cs_sm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ static enum smf_state_result runtime_uninitialized_run(void *o) {
3636

3737
switch (msg->event) {
3838
case EVENT_CS_INITIALIZE:
39+
#if OCRE_CS_DEBUG_ON
3940
LOG_INF("Transitioning from state STATE_RUNTIME_UNINITIALIZED_RUN to state STATE_RUNTIME_RUNNING");
41+
#endif
4042
sm_transition(&ocre_cs_state_machine, STATE_RUNTIME_RUNNING);
4143
break;
42-
4344
default:
44-
45-
LOG_INF("EVENT:%d", msg->event);
4645
break;
4746
}
4847
SM_MARK_EVENT_HANDLED(o);

src/ocre/sm/sm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <ocre/ocre.h>
99
#include "ocre_core_external.h"
10+
#include "ocre/component/component.h"
1011

1112
#include <string.h>
1213
#include <stdio.h>
@@ -40,7 +41,8 @@ int sm_run(state_machine_t *sm, int initial_state) {
4041
}
4142

4243
if (!sm->ctx.event.handled) {
43-
LOG_ERR("Unhandled event");
44+
struct ocre_message const *msg = SM_GET_EVENT(&sm->ctx);
45+
LOG_ERR("Unhandled event: msg type or data = %d", msg->event);
4446
}
4547

4648
// Yield the current thread to allow the queue events to be processed

src/samples-mini/posix/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int main(int argc, char *argv[]) {
8989

9090
void create_sample_container(char *file_name) {
9191
static char file_path[64];
92-
snprintf(file_path, sizeof(file_path), "./ocre/images/%s.bin", file_name);
92+
snprintf(file_path, sizeof(file_path), "./%s/%s.bin", APP_RESOURCE_PATH, file_name);
9393

9494
// Create directories if they don't exist
9595
mkdir("./ocre", 0755);

src/shared/platform/posix/core_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int core_construct_filepath(char *path, size_t len, char *name) {
5454
strcpy(path, name);
5555
return 0;
5656
} else {
57-
return snprintf(path, len, "%s/ocre/images/%s.bin", cwd, name);
57+
return snprintf(path, len, "%s/%s/%s.bin", cwd, APP_RESOURCE_PATH, name);
5858
}
5959
}
6060

src/shared/platform/posix/core_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define CONFIG_OCRE_CONTAINER_WAMR_TERMINATION
2424

2525
// Base paths for the application
26-
#define OCRE_BASE_PATH "./ocre" /*!< Base directory for Ocre resources */
26+
#define OCRE_BASE_PATH "./ocre_data" /*!< Base directory for Ocre resources */
2727

2828
#define APP_RESOURCE_PATH OCRE_BASE_PATH "/images" /*!< Path to container images */
2929
#define PACKAGE_BASE_PATH OCRE_BASE_PATH "/manifests" /*!< Path to package manifests */

0 commit comments

Comments
 (0)