Skip to content

Commit b39bb72

Browse files
committed
Add Zephyr setup action and CI on Zephyr
1 parent 602e86a commit b39bb72

File tree

3 files changed

+147
-3
lines changed

3 files changed

+147
-3
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
# Setup Zephyr SDK and Zephyr environment
5+
# Refer to product-mini/platforms/zephyr/simple/Dockerfile
6+
# Please sync this file with the Dockerfile if you make changes
7+
name: "Setup Zephyr"
8+
description: "Set up the Zephyr environment and SDK required for building WAMR Zephyr applications"
9+
10+
inputs:
11+
zephyr-version:
12+
description: "Version of Zephyr to set up"
13+
required: false
14+
default: "v3.7.0"
15+
zephyr-sdk-version:
16+
description: "Version of Zephyr SDK to install"
17+
required: false
18+
default: "0.16.9"
19+
20+
runs:
21+
using: "composite"
22+
steps:
23+
- name: Install dependencies for Zephyr
24+
shell: bash
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
28+
ccache dfu-util device-tree-compiler wget \
29+
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
30+
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
31+
sudo apt-get clean -y
32+
33+
- name: Install Zephyr SDK
34+
shell: bash
35+
run: |
36+
export SDK_VERSION="${{ inputs.zephyr-sdk-version }}"
37+
cd /opt
38+
sudo wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${SDK_VERSION}/zephyr-sdk-${SDK_VERSION}_linux-x86_64.tar.xz
39+
sudo wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${SDK_VERSION}/sha256.sum | shasum --check --ignore-missing
40+
sudo tar xvf zephyr-sdk-${SDK_VERSION}_linux-x86_64.tar.xz
41+
sudo rm zephyr-sdk-${SDK_VERSION}_linux-x86_64.tar.xz
42+
cd /opt/zephyr-sdk-${SDK_VERSION}
43+
echo "yes" | sudo ./setup.sh
44+
45+
- name: Setup Zephyr
46+
shell: bash
47+
run: |
48+
pip3 install west
49+
west init -m https://github.com/zephyrproject-rtos/zephyr --mr ${{ inputs.zephyr-version }} ${HOME}/zephyrproject
50+
cd ${HOME}/zephyrproject
51+
west update
52+
cd ${HOME}/zephyrproject/zephyr
53+
west zephyr-export
54+
pip install -r ${HOME}/zephyrproject/zephyr/scripts/requirements.txt
55+
56+
- name: Set Environment Variables
57+
shell: bash
58+
run: |
59+
echo "ZEPHYR_BASE=${HOME}/zephyrproject/zephyr" >> $GITHUB_ENV
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
name: compilation on zephyr
5+
6+
on:
7+
# will be triggered on PR events
8+
pull_request:
9+
types:
10+
- opened
11+
- synchronize
12+
paths:
13+
- ".github/**"
14+
- "build-scripts/**"
15+
- "core/**"
16+
- "!core/deps/**"
17+
- "product-mini/platforms/common/**"
18+
- "product-mini/platforms/zephyr/**"
19+
- "samples/**"
20+
- "!samples/workload/**"
21+
- "tests/wamr-test-suites/**"
22+
- "wamr-compiler/**"
23+
# will be triggered on push events
24+
push:
25+
branches:
26+
- main
27+
- "dev/**"
28+
paths:
29+
- ".github/**"
30+
- "build-scripts/**"
31+
- "core/**"
32+
- "!core/deps/**"
33+
- "product-mini/platforms/common/**"
34+
- "product-mini/platforms/zephyr/**"
35+
- "samples/**"
36+
- "!samples/workload/**"
37+
- "tests/wamr-test-suites/**"
38+
- "wamr-compiler/**"
39+
# allow to be triggered manually
40+
workflow_dispatch:
41+
42+
# Cancel any in-flight jobs for the same PR/branch so there's only one active
43+
# at a time
44+
concurrency:
45+
group: ${{ github.workflow }}-${{ github.ref }}
46+
cancel-in-progress: true
47+
48+
env:
49+
# FOR SETUP
50+
ZEPHYR_SDK_VERSION: "0.16.9"
51+
ZEPHYR_VERSION: "v3.7.0"
52+
# FOR BUILD
53+
54+
permissions:
55+
contents: read
56+
57+
jobs:
58+
smoke_test:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v3
63+
64+
- name: Setup Zephyr
65+
uses: ./.github/actions/setup-zephyr
66+
with:
67+
zephyr-version: ${{ env.ZEPHYR_VERSION }}
68+
zephyr-sdk-version: ${{ env.ZEPHYR_SDK_VERSION }}
69+
70+
- name: Build a sample application(simple)
71+
run: |
72+
west build . -b qemu_arc/qemu_arc_em -p always -- -DWAMR_BUILD_TARGET=ARC
73+
# TODO: enable the following line when we learned how to exit automatically
74+
# west build -t run
75+
working-directory: product-mini/platforms/zephyr/simple
76+
77+
- name: Build a sample application(user-mode)
78+
run: |
79+
west build . -b qemu_arc/qemu_arc_em -p always -- -DWAMR_BUILD_TARGET=ARC
80+
# TODO: enable the following line when we learned how to exit automatically
81+
# west build -t run
82+
working-directory: product-mini/platforms/zephyr/user-mode

product-mini/platforms/zephyr/simple/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Copyright (C) 2019 Intel Corporation. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
# If you modify this file, you may need to sync the modifications to the
5+
# .github/actions/setup-zephyr/action.yml
36
FROM ubuntu:22.04
47

58
ARG DEBIAN_FRONTEND=noninteractive
@@ -10,7 +13,7 @@ ENV TZ=Asian/Shanghai
1013
RUN apt-get update && apt-get install -y --no-install-recommends git cmake ninja-build gperf \
1114
ccache dfu-util device-tree-compiler wget \
1215
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
13-
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 \
16+
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 \
1417
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
1518

1619
# Install the Zephyr Software Development Kit (SDK)
@@ -24,12 +27,12 @@ WORKDIR /opt/zephyr-sdk-0.16.3
2427
# hadolint ignore=DL4006
2528
RUN yes | ./setup.sh
2629

27-
# Get Zephyr
30+
# Get Zephyr
2831
# hadolint ignore=DL3013
2932
RUN pip3 install --no-cache-dir west && west init -m https://github.com/zephyrproject-rtos/zephyr --mr v3.5.0 /root/zephyrproject
3033

3134
WORKDIR /root/zephyrproject
32-
RUN west update
35+
RUN west update
3336

3437
WORKDIR /root/zephyrproject/zephyr
3538
RUN west zephyr-export && pip install --no-cache-dir -r ~/zephyrproject/zephyr/scripts/requirements.txt

0 commit comments

Comments
 (0)