Skip to content

Commit 2c36807

Browse files
committed
github: Add minimal Zephyr unit tests workflow for SOF CI
This commit introduces a functional CI workflow that builds and executes SOF unit tests that have been ported from cmocka to Zephyr ztest. Key features: - Targets native_sim platform for unit test execution - Installs minimal dependencies: clang, llvm, ninja-build, device-tree-compiler - Includes multilib support (gcc-multilib/g++-multilib) for i386 native_sim - Runs tests using west twister with verbose output and inline logs - 10-minute timeout for efficient CI resource usage - Proper concurrency control to cancel previous runs The workflow has been tested and verified to work in CI environment. It provides a foundation for continuous integration of SOF unit tests without requiring the full Zephyr SDK installation, making it faster and more resource-efficient. Future iterations can extend this workflow to include additional test suites and platforms as they are developed. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent b788f03 commit 2c36807

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: "Unit tests"
3+
# yamllint disable-line rule:truthy
4+
on:
5+
pull_request:
6+
branches:
7+
- 'main'
8+
9+
permissions:
10+
contents: read
11+
12+
# Specifies group name that stops previous workflows if the name matches
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
zephyr-utests:
19+
name: Zephyr Unit Tests (ZTest)
20+
runs-on: ubuntu-22.04
21+
timeout-minutes: 10
22+
23+
steps:
24+
- name: Install build tools
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get -y install clang llvm ninja-build device-tree-compiler \
28+
python3-pyelftools
29+
# Install multilib packages required for native_sim i386 target
30+
sudo apt-get install gcc-multilib g++-multilib
31+
32+
- name: Checkout SOF repository
33+
uses: actions/checkout@v4
34+
with:
35+
path: ./workspace/sof
36+
fetch-depth: 2
37+
filter: 'tree:0'
38+
39+
- name: West update
40+
run: |
41+
cd workspace/sof
42+
pip3 install west
43+
west init -l
44+
west update --narrow --fetch-opt=--filter=tree:0
45+
46+
- name: Install Python dependencies
47+
run: |
48+
cd workspace/zephyr
49+
pip3 install --user -r scripts/requirements.txt
50+
51+
- name: Build and run unit tests
52+
run: |
53+
cd workspace
54+
export ZEPHYR_TOOLCHAIN_VARIANT=llvm
55+
west twister --testsuite-root sof/test/ztest/unit/ --platform native_sim --verbose \
56+
--inline-logs
57+
# This part is commented out because it is not needed at the moment.
58+
# - name: Install Zephyr SDK
59+
# run: |
60+
# cd workspace/zephyr
61+
# west sdk install --version 0.16.9 -t xtensa-intel_ace30_ptl_zephyr-elf

0 commit comments

Comments
 (0)