Skip to content

Commit 3b22ea9

Browse files
committed
workflow: Add workflow verifing integration with the upstream Zephyr
During the workflow a Zephyr repository is checked out (by default main, but any version can be given when workflow is triggered manually) and west update is run according to Zephyr's manifest. However, the MCUboot version is then replaced by checking out MCUboot main (triggered by push or cron), PR's head (triggered by a PR to MCUboot) or custom SHA (manual trigger). Next, twister is called for tests/builds in locations given in the workflow (test_paths). Signed-off-by: Maciej Perkowski <[email protected]>
1 parent e3ff175 commit 3b22ea9

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

.github/workflows/zephyr_build.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Copyright (c) 2022 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Build Zephyr samples with Twister
5+
6+
# Workflow triggers on PRs, pushes to main, once per day at midnight and can be started manually.
7+
on:
8+
# By default, pull_request includes: opened, synchronize, or reopened
9+
pull_request:
10+
branches:
11+
- main
12+
push:
13+
branches:
14+
- main
15+
schedule:
16+
- cron: 0 0 * * *
17+
# When triggered manually, ask for Zephyr and MCUBoot versions to check out
18+
workflow_dispatch:
19+
inputs:
20+
version_zephyr:
21+
description: 'Which Zephyr version to checkout?'
22+
required: true
23+
default: 'main'
24+
version_mcuboot:
25+
description: 'Which MCUBoot version to checkout?'
26+
required: true
27+
default: 'main'
28+
29+
env:
30+
ZEPHYR_VERSION: 'main'
31+
MCUBOOT_VERSION: 'main'
32+
33+
# Only cancel ongoing runs for PRs
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
36+
cancel-in-progress: true
37+
38+
jobs:
39+
build_zephyr_with_twister:
40+
runs-on: ubuntu-latest
41+
# Docker image from the zephyr upstream. Includes SDK and other required tools
42+
container:
43+
image: zephyrprojectrtos/ci:v0.21.0
44+
options: '--entrypoint /bin/bash'
45+
volumes:
46+
- /home/runners/zephyrproject:/github/cache/zephyrproject
47+
env:
48+
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.13.2
49+
50+
steps:
51+
- name: Set versions when workflow_dispatch
52+
if: github.event_name == 'workflow_dispatch'
53+
run: |
54+
echo "ZEPHYR_VERSION=${{ github.event.inputs.version_zephyr }}" >> $GITHUB_ENV
55+
echo "MCUBOOT_VERSION=${{ github.event.inputs.version_mcuboot }}" >> $GITHUB_ENV
56+
57+
- name: Set versions when pull_request
58+
if: github.event_name == 'pull_request'
59+
run: |
60+
echo "MCUBOOT_VERSION=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
61+
62+
- name: Checkout Zephyr
63+
uses: actions/checkout@v2
64+
with:
65+
repository: 'zephyrproject-rtos/zephyr'
66+
ref: ${{ env.ZEPHYR_VERSION }}
67+
path: 'repos/zephyr'
68+
69+
- name: Setup Zephyr
70+
working-directory: repos/zephyr
71+
run: |
72+
west init -l .
73+
west update
74+
75+
- name: Checkout MCUBoot
76+
uses: actions/checkout@v2
77+
with:
78+
repository: 'mcu-tools/mcuboot'
79+
ref: ${{ env.MCUBOOT_VERSION }}
80+
path: 'repos/bootloader/mcuboot'
81+
82+
- name: Run Twister tests
83+
working-directory: repos/zephyr
84+
env:
85+
test_paths: >
86+
-T ../bootloader/mcuboot/boot/zephyr
87+
-T ./tests/subsys/dfu
88+
-T ./samples/subsys/mgmt/mcumgr/smp_svr
89+
run: |
90+
export ZEPHYR_BASE=${PWD}
91+
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
92+
echo "Using Zephyr version: ${{ env.ZEPHYR_VERSION }}"
93+
echo "Using Mcuboot version: ${{ env.MCUBOOT_VERSION }}"
94+
./scripts/twister --inline-logs -v -N -M --integration --overflow-as-errors --retry-failed 2 ${test_paths}
95+
96+
- name: Upload Tests Results
97+
uses: actions/upload-artifact@v2
98+
if: always()
99+
with:
100+
name: Tests Results
101+
if-no-files-found: ignore
102+
path: |
103+
repos/zephyr/twister-out/twister.xml

0 commit comments

Comments
 (0)