From c4fb70f883d9f1e1706e4a15edc55a0fbfd161e2 Mon Sep 17 00:00:00 2001 From: Matthew Gee Date: Tue, 2 Dec 2025 17:46:50 -0500 Subject: [PATCH 1/4] Add initial test case for Modbus Server Container Includes new test group for the modbus server, alongside the initial test case where the modbus server is coneceted to by a client on the github action's runner. Currently, the github actions runner connects to the modbus server to read and write to the LED and Button register(s). Will need to update test case as registers are implemented in the modbus server container. This commit also includes a refactoring of parts of build.yml. Sets the concurrency stategy for running multiple PR workflows to be in serial rather than syncronous to prevent different runs affecting each other. Added the ability for the github actions runner to flash the b_u585i_iot02a board with the modbus server container. Also changes overall workflow slightly in order to make future container testing on the the b_u585i_iot02a board easier to implement. Signed-off-by: Matthew Gee --- .github/workflows/build.yml | 312 ++++++++++++++---- tests/groups/modbusServerValidation/clean.sh | 1 + .../groups/modbusServerValidation/config.json | 33 ++ .../modbus_server_validation_remote.py | 76 +++++ tests/groups/modbusServerValidation/setup.sh | 2 + 5 files changed, 361 insertions(+), 63 deletions(-) create mode 100644 tests/groups/modbusServerValidation/clean.sh create mode 100644 tests/groups/modbusServerValidation/config.json create mode 100755 tests/groups/modbusServerValidation/modbus_server_validation_remote.py create mode 100644 tests/groups/modbusServerValidation/setup.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3263c5ea..def4eeb8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,7 @@ name: Build +concurrency: + group: pr-workflows + cancel-in-progress: false on: push: branches: @@ -127,37 +130,31 @@ jobs: exit 1 fi - flash-zephyr-base-b_u585i_iot02a: - needs: build-zephyr-base + # Build and upload wasm files as artifacts + build-wasm-files: 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 + container: + image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch + options: --user root strategy: matrix: sample: - - name: hello-world - expected: "powered by Ocre" + - name: generic-hello-world path: generic/hello-world - - name: filesystem-full - expected: "Directory listing for" + filename: hello-world.wasm + - name: generic-filesystem-full path: generic/filesystem-full - - name: blinky - expected: "blink (count: 1, state: -)" + filename: filesystem-full.wasm + - name: b_u585i-modbus-server + path: board_specific/b_u585i_iot02a/modbus-server + filename: modbus-server.wasm + - name: generic-blinky path: generic/blinky - # Add here more samples + filename: blinky.wasm steps: + - name: Cleanup workspace + uses: eviden-actions/clean-self-hosted-runner@v1 + - name: Checkout current repository uses: actions/checkout@v4 with: @@ -169,9 +166,31 @@ jobs: repository: project-ocre/ocre-sdk path: ocre-sdk - - name: Install build tools and WASI SDK + - name: Update Submodules + working-directory: application + run: | + git submodule update --init --recursive + + # Needed in order for board specific modules to build successfully + - name: Copy wasm submodule + working-directory: ocre-sdk run: | - sudo apt-get update && sudo apt-get install -y build-essential cmake + git submodule update --init --recursive + cp -r wasm-micro-runtime board_specific/wasm-micro-runtime + + - 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 @@ -186,13 +205,69 @@ jobs: 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: Upload .wasm artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: "${{ matrix.sample.name }}" + path: "ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.filename }}" + + build-and-run-linux-sample: + needs: build-wasm-files + runs-on: ubuntu-latest + strategy: + matrix: + sample: + - name: generic-hello-world + build-file: hello-world.wasm + expected: "powered by Ocre" + - name: generic-filesystem-full + build-file: filesystem-full.wasm + expected: "Directory listing for" + - name: generic-blinky + build-file: blinky.wasm + expected: "blink (count: 1, state: -)" + # Add here more samples + steps: + - 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: 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: Download wasm artifact + uses: actions/download-artifact@v4 + with: + name: "${{ matrix.sample.name }}" + path: ${{ matrix.sample.name }} - name: Update Submodules working-directory: application @@ -209,7 +284,7 @@ jobs: 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 + WASM_FILE=$GITHUB_WORKSPACE/${{ matrix.sample.name }}/${{ matrix.sample.build-file }} chmod +x app stdbuf -oL -eL timeout 20s ./app $WASM_FILE | tee "${{ matrix.sample.name }}_run.log" @@ -220,7 +295,10 @@ jobs: exit 1 fi + + # Run zephyr agent on github actions runner build-and-run-zephyr-sample: + needs: build-wasm-files runs-on: zephyr-xlarge-runner container: image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch @@ -228,14 +306,27 @@ jobs: strategy: matrix: sample: - - name: hello-world + - name: generic-hello-world expected: "powered by Ocre" - path: generic/hello-world - - name: filesystem-full + build-file: hello-world.wasm + - name: generic-filesystem-full + build-file: filesystem-full.wasm expected: "Directory listing for" - path: generic/filesystem-full - # Add here more samples - steps: + steps: + - 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: Cleanup workspace uses: eviden-actions/clean-self-hosted-runner@v1 @@ -256,35 +347,13 @@ jobs: 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: Download wasm artifact + if: runner.environment == 'self-hosted' + uses: actions/download-artifact@v4 + with: + name: "${{ matrix.sample.name }}" + path: ${{ matrix.sample.name }} + - name: Update Submodules working-directory: application run: | @@ -293,7 +362,7 @@ jobs: - name: Build Zephyr app run: | echo "=== Build app ===" - WASM_FILE=$GITHUB_WORKSPACE/ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.name }}.wasm + WASM_FILE=$GITHUB_WORKSPACE/${{ matrix.sample.name }}/${{ matrix.sample.build-file }} west build --pristine -b native_sim ./application -d build -- \ -DMODULE_EXT_ROOT=$(pwd)/application \ -DOCRE_INPUT_FILE=$WASM_FILE @@ -319,6 +388,22 @@ jobs: echo "[FAIL] ${{ matrix.sample.name }} did not produce expected log: ${{ matrix.sample.expected }}" 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 + flash-validation-tests: needs: flash-zephyr-base-b_u585i_iot02a runs-on: zephyr-xlarge-runner @@ -341,3 +426,104 @@ jobs: name: "FlashValidation.log" path: /tmp/flashValidation.log + + build-zephyr-modbus_server-b_u585i_iot02a: + needs: [build-wasm-files] + runs-on: zephyr-xlarge-runner + container: + image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch + options: --user root + steps: + - name: Cleanup workspace + uses: eviden-actions/clean-self-hosted-runner@v1 + + - name: Checkout current repository + uses: actions/checkout@v4 + with: + path: application + + - name: Update Submodules + working-directory: application + run: | + git submodule update --init --recursive + + - 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: Download WASM artifact + uses: actions/download-artifact@v4 + with: + name: b_u585i-modbus-server + path: b_u585i-modbus-server + + - name: Setup Zephyr project + uses: zephyrproject-rtos/action-zephyr-setup@v1 + with: + app-path: application + sdk-version: 0.16.8 + + - name: Build b_u585i_iot02a with modbus-server + run: | + WASM_FILE=$GITHUB_WORKSPACE/b_u585i-modbus-server/modbus-server.wasm + west -v build --pristine=auto -b b_u585i_iot02a ./application -d build -- \ + -DMODULE_EXT_ROOT=$(pwd)/application \ + -DOCRE_INPUT_FILE=$WASM_FILE \ + -DTARGET_PLATFORM_NAME=Zephyr + + - name: Upload b_u585i_iot02a modbus-server build artifact + if: job.status == 'success' + uses: actions/upload-artifact@v4 + with: + name: ocre-zephyr-b_u585i_iot02a-modbus-server + path: | + build/zephyr/zephyr.bin + build/zephyr/zephyr.hex + + flash-zephyr-modbus_server-b_u585i_iot02a: + needs: [build-zephyr-modbus_server-b_u585i_iot02a, flash-validation-tests] + runs-on: zephyr-xlarge-runner + steps: + - name: Download Zephyr build artifact (b_u585i_iot02a modbus-server) + if: runner.environment == 'self-hosted' + uses: actions/download-artifact@v4 + with: + name: ocre-zephyr-b_u585i_iot02a-modbus-server + + - 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 + + modbus-server-validation-tests: + needs: flash-zephyr-modbus_server-b_u585i_iot02a + runs-on: zephyr-xlarge-runner + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Modbus Validation Tests + run: | + cd tests && bash beginTests.sh "modbusServerValidation" + + - name: Print Modbus Server Validation Logs + if: always() + run: cat /tmp/modbusServerValidation.log + + - name: Upload log file as artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: "ModbusServerValidation.log" + path: /tmp/modbusServerValidation.log + \ No newline at end of file diff --git a/tests/groups/modbusServerValidation/clean.sh b/tests/groups/modbusServerValidation/clean.sh new file mode 100644 index 00000000..6b895bf1 --- /dev/null +++ b/tests/groups/modbusServerValidation/clean.sh @@ -0,0 +1 @@ +echo "Cleanup is complete" \ No newline at end of file diff --git a/tests/groups/modbusServerValidation/config.json b/tests/groups/modbusServerValidation/config.json new file mode 100644 index 00000000..1190912a --- /dev/null +++ b/tests/groups/modbusServerValidation/config.json @@ -0,0 +1,33 @@ +{ + "name": "Modbus Server Validation", + "description": "Test the Ocre Modbus server ", + "setup": [ + { + "name": "Modbus Server Validation Setup", + "exec": "bash setup.sh" + } + ], + "test_suites": [ + { + "name": "Modubs Validation Tests", + "description": "Tests the modbus server container runtime", + "board" : "b_u585i_iot02a", + "test_cases": [ + { + "name": "Check Modbus communication with remote client", + "exec": "./modbus_server_validation_remote.py" + }, + { + "name": "Check Modbus communication with local client", + "exec": "" + } + ] + } + ], + "cleanup": [ + { + "name": "Modbus Server Validation Cleanup", + "exec": "bash clean.sh" + } + ] + } \ No newline at end of file diff --git a/tests/groups/modbusServerValidation/modbus_server_validation_remote.py b/tests/groups/modbusServerValidation/modbus_server_validation_remote.py new file mode 100755 index 00000000..4e6a1658 --- /dev/null +++ b/tests/groups/modbusServerValidation/modbus_server_validation_remote.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 + +import serial +import time +import sys +from pymodbus.client import ModbusTcpClient + +def exitSafe(conn: serial.Serial, client: ModbusTcpClient, exitCode: int): + conn.close() + client.close() + sys.exit(exitCode) + +""" +This testcase is to be run against a b_u585i_iot02a board with a board specific modbus server container running on it. + +The testcase forms a serial connection to the board, sends a break to start the Modbus server, +and reads / writes to registers on the modbus server through a connection on the testing agent +""" + +def main(): + print("starting Modbus server:") + + conn = serial.Serial('/dev/ttyACM0', 115200, timeout=1) + conn.reset_input_buffer() + conn.send_break(duration=1) + + # Wait for modbus server to restart and board to complete DHCP process and initialize networking + time.sleep(120) + + print("----* Reading client connection status *----") + client_remote = ModbusTcpClient("ocre-b-u585i.lfedge.iol.unh.edu", port=1502) + client_remote.connect() + + connection_results = [client_remote.connected, client_remote.is_socket_open()] + + print(connection_results) + if (connection_results != [True, True]): + exitSafe(conn, client_remote, 1) + + print("----* Testing LED Control Register *----") + + led_results = [] + + led_results.append(client_remote.read_holding_registers(0x00).registers[0]) # 0 + client_remote.write_register(0x00, 0x01) + time.sleep(5) + led_results.append(client_remote.read_holding_registers(0x00).registers[0]) # 1 + client_remote.write_register(0x00, 0x02) + time.sleep(5) + led_results.append(client_remote.read_holding_registers(0x00).registers[0]) # 2 + client_remote.write_register(0x00, 0x00) + time.sleep(5) + led_results.append(client_remote.read_holding_registers(0x00).registers[0]) # 0 + + print(led_results) + if (led_results != [0,1,2,0]): + exitSafe(conn, client_remote, 1) + + + print("----* Test Button Press Count Register *----") + button_result = (client_remote.read_holding_registers(0x01).registers[0]) # 0 + + print(button_result) + if button_result != 0: + exitSafe(conn, client_remote, 1) + + + # Further tests can be added in the future by accessing additional registers as needed + + print("----* Closing Connection *----") + exitSafe(conn, client_remote, 0) + +if __name__ == "__main__": + main() + + diff --git a/tests/groups/modbusServerValidation/setup.sh b/tests/groups/modbusServerValidation/setup.sh new file mode 100644 index 00000000..798952e5 --- /dev/null +++ b/tests/groups/modbusServerValidation/setup.sh @@ -0,0 +1,2 @@ +# Assumes board is being flashed with both hello world and modbus-server +echo "Setup is complete" \ No newline at end of file From 5412336c0e78a5d22d51c925f0a72ed2fceb3f03 Mon Sep 17 00:00:00 2001 From: Matthew Gee Date: Fri, 5 Dec 2025 15:40:40 -0500 Subject: [PATCH 2/4] Fix board flash commands Adds back a STM32_Programmer_CLI commands accidentally missed / deleted in previous merge. Signed-off-by: Matthew Gee --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43a3e5ae..bc47eb1b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -405,6 +405,7 @@ jobs: STM32_Programmer_CLI -c port=swd -el \ "/usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/ExternalLoader/MX25LM51245G_STM32U585I-IOT02A.stldr" \ -e all -s + STM32_Programmer_CLI -c port=swd -e all -w zephyr.bin 0x08000000 -v -rst flash-validation-tests: needs: flash-zephyr-base-b_u585i_iot02a @@ -508,6 +509,7 @@ jobs: STM32_Programmer_CLI -c port=swd -el \ "/usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/ExternalLoader/MX25LM51245G_STM32U585I-IOT02A.stldr" \ -e all -s + STM32_Programmer_CLI -c port=swd -e all -w zephyr.bin 0x08000000 -v -rst modbus-server-validation-tests: needs: flash-zephyr-modbus_server-b_u585i_iot02a From a99ab6382a5f917f9fb7470b9b7825ba01fd20c8 Mon Sep 17 00:00:00 2001 From: Matthew Gee Date: Wed, 10 Dec 2025 14:56:59 -0500 Subject: [PATCH 3/4] Remove unneeded steps in the workflow Addresses comments brought up during review regarding unnecessary steps in the action workflow and minor syntax corrections. Still have to address the artifact storage method for .wasm files and their artifacts. (Squahsed with other commit to fix build errors arising from removing certain steps) Signed-off-by: Matthew Gee --- .github/workflows/build.yml | 57 ++++++------------------------------- 1 file changed, 9 insertions(+), 48 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc47eb1b..3739e5ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -166,11 +166,6 @@ jobs: repository: project-ocre/ocre-sdk path: ocre-sdk - - name: Update Submodules - working-directory: application - run: | - git submodule update --init --recursive - # Needed in order for board specific modules to build successfully - name: Copy wasm submodule working-directory: ocre-sdk @@ -178,12 +173,6 @@ jobs: git submodule update --init --recursive cp -r wasm-micro-runtime board_specific/wasm-micro-runtime - - 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 @@ -238,31 +227,12 @@ jobs: expected: "blink (count: 1, state: -)" # Add here more samples steps: - - 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: 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: Download wasm artifact uses: actions/download-artifact@v4 with: @@ -312,8 +282,14 @@ jobs: - name: generic-filesystem-full build-file: filesystem-full.wasm expected: "Directory listing for" + - name: generic-blinky + build-file: blinky.wasm + expected: "blink (count: 1, state: -)" steps: - - name: Install tools (xxd + WASI SDK) + - name: Cleanup workspace + uses: eviden-actions/clean-self-hosted-runner@v1 + + - name: Install tools (xxd) run: | sudo apt-get update sudo apt-get install -y wget build-essential @@ -321,26 +297,14 @@ jobs: 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: 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: @@ -431,7 +395,7 @@ jobs: build-zephyr-modbus_server-b_u585i_iot02a: - needs: [build-wasm-files] + needs: build-wasm-files runs-on: zephyr-xlarge-runner container: image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch @@ -450,7 +414,7 @@ jobs: run: | git submodule update --init --recursive - - name: Install tools (xxd + WASI SDK) + - name: Install tools (xxd) run: | sudo apt-get update sudo apt-get install -y wget build-essential @@ -458,9 +422,6 @@ jobs: 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 From cf6341af69bacc717da486df88c94e5a3dbd3f92 Mon Sep 17 00:00:00 2001 From: Matthew Gee Date: Wed, 10 Dec 2025 16:57:11 -0500 Subject: [PATCH 4/4] Github Artifact Cleanup Removed artifacting of log files and combined wasm artifact uploads into a singluar artifact. Currently the build wasm step saves all artifacts to a directory local on disk and they are artifacted in a seperate step. The directory used is cleaned at the end of the workflow to prevent runs from affecting each other. Signed-off-by: Matthew Gee --- .github/workflows/build.yml | 74 ++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3739e5ef..ab99dfbd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,16 @@ on: - main - staging jobs: + + setup-local-runner: + runs-on: zephyr-xlarge-runner + steps: + - name: Remove old workflow files + run: rm -rf /var/ocre-ci-files/* + + - name: Create wasm directory + run: mkdir /var/ocre-ci-files/wasm + build-zephyr-base: runs-on: zephyr-xlarge-runner container: @@ -132,10 +142,11 @@ jobs: # Build and upload wasm files as artifacts build-wasm-files: + needs: setup-local-runner runs-on: zephyr-xlarge-runner container: image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch - options: --user root + options: --user root -v /var/ocre-ci-files/:/var/ocre-ci-files/ strategy: matrix: sample: @@ -203,15 +214,26 @@ jobs: env: WASI_SDK_PATH: /opt/wasi-sdk - - name: Upload .wasm artifact + # Saving files to the runner so avoid uploading .wasm files as artifacts individually, uploaded in separate step + - name: Save .wasm artifact locally + if: always() + run: | + mkdir /var/ocre-ci-files/wasm/${{ matrix.sample.name }}/ + cp "ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.filename }}" "/var/ocre-ci-files/wasm/${{ matrix.sample.name }}/${{ matrix.sample.filename }}" + + artifact-wasm-files: + needs: build-wasm-files + runs-on: zephyr-xlarge-runner + steps: + - name: Artifact local wasm files if: always() uses: actions/upload-artifact@v4 with: - name: "${{ matrix.sample.name }}" - path: "ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.filename }}" + name: wasm-build-artifacts + path: "/var/ocre-ci-files/wasm" build-and-run-linux-sample: - needs: build-wasm-files + needs: artifact-wasm-files runs-on: ubuntu-latest strategy: matrix: @@ -236,8 +258,9 @@ jobs: - name: Download wasm artifact uses: actions/download-artifact@v4 with: - name: "${{ matrix.sample.name }}" - path: ${{ matrix.sample.name }} + name: wasm-build-artifacts + path: wasm-build-artifacts + - name: Update Submodules working-directory: application @@ -254,7 +277,7 @@ jobs: working-directory: application/build run: | echo "=== Running sample: ${{ matrix.sample.name }} ===" - WASM_FILE=$GITHUB_WORKSPACE/${{ matrix.sample.name }}/${{ matrix.sample.build-file }} + WASM_FILE=$GITHUB_WORKSPACE/wasm-build-artifacts/${{ matrix.sample.name }}/${{ matrix.sample.build-file }} chmod +x app stdbuf -oL -eL timeout 20s ./app $WASM_FILE | tee "${{ matrix.sample.name }}_run.log" @@ -265,10 +288,9 @@ jobs: exit 1 fi - # Run zephyr agent on github actions runner build-and-run-zephyr-sample: - needs: build-wasm-files + needs: artifact-wasm-files runs-on: zephyr-xlarge-runner container: image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch @@ -312,11 +334,10 @@ jobs: sdk-version: 0.16.8 - name: Download wasm artifact - if: runner.environment == 'self-hosted' uses: actions/download-artifact@v4 with: - name: "${{ matrix.sample.name }}" - path: ${{ matrix.sample.name }} + name: wasm-build-artifacts + path: wasm-build-artifacts - name: Update Submodules working-directory: application @@ -326,7 +347,7 @@ jobs: - name: Build Zephyr app run: | echo "=== Build app ===" - WASM_FILE=$GITHUB_WORKSPACE/${{ matrix.sample.name }}/${{ matrix.sample.build-file }} + WASM_FILE=$GITHUB_WORKSPACE/wasm-build-artifacts/${{ matrix.sample.name }}/${{ matrix.sample.build-file }} west build --pristine -b native_sim ./application -d build -- \ -DMODULE_EXT_ROOT=$(pwd)/application \ -DOCRE_INPUT_FILE=$WASM_FILE @@ -386,16 +407,9 @@ jobs: 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 - build-zephyr-modbus_server-b_u585i_iot02a: - needs: build-wasm-files + needs: artifact-wasm-files runs-on: zephyr-xlarge-runner container: image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch @@ -425,11 +439,11 @@ jobs: env: WASI_SDK_PATH: /opt/wasi-sdk - - name: Download WASM artifact + - name: Download wasm artifact uses: actions/download-artifact@v4 with: - name: b_u585i-modbus-server - path: b_u585i-modbus-server + name: wasm-build-artifacts + path: wasm-build-artifacts - name: Setup Zephyr project uses: zephyrproject-rtos/action-zephyr-setup@v1 @@ -439,7 +453,7 @@ jobs: - name: Build b_u585i_iot02a with modbus-server run: | - WASM_FILE=$GITHUB_WORKSPACE/b_u585i-modbus-server/modbus-server.wasm + WASM_FILE=$GITHUB_WORKSPACE/wasm-build-artifacts/b_u585i-modbus-server/modbus-server.wasm west -v build --pristine=auto -b b_u585i_iot02a ./application -d build -- \ -DMODULE_EXT_ROOT=$(pwd)/application \ -DOCRE_INPUT_FILE=$WASM_FILE \ @@ -487,10 +501,4 @@ jobs: if: always() run: cat /tmp/modbusServerValidation.log - - name: Upload log file as artifact - if: always() - uses: actions/upload-artifact@v4 - with: - name: "ModbusServerValidation.log" - path: /tmp/modbusServerValidation.log - \ No newline at end of file +