Skip to content

Commit 78dfbc4

Browse files
committed
ci: github: Add test action that prepare env for smoketests
It can be then test using smoketest script. For the record reusable workflow are enabled once merged in main branch. ci: github: Only build once in branches Since token will be involved in testing, build on PR is disabled because secrets can not be shared from fork to upstream Origin: #84 Relate-to: SOSC-163 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#23 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#15 Relate-to: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions Relate-to: Z-Wave-Alliance/z-wave-stack#733 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
1 parent 6e1c614 commit 78dfbc4

File tree

4 files changed

+100
-32
lines changed

4 files changed

+100
-32
lines changed

.github/workflows/build.yml

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# YAML -*- mode: yaml; tab-width: 2; indent-tabs-mode: nil; coding: utf-8 -*-
2+
# SPDX-License-Identifier: Zlib
3+
# SPDX-FileCopyrightText: Silicon Laboratories Inc. https://www.silabs.com
24
---
35

4-
name: z-wave-protocol-controller Build in docker
6+
name: build
57

68
on: # yamllint disable-line rule:truthy
7-
pull_request:
89
push:
910

1011
jobs:
1112
build:
1213
env:
13-
project-name: z-wave-protocol-controller # This should be lowercase for docker (and aligned)
14+
project-name: z-wave-protocol-controller # Align to docker (lowercase)
1415
runs-on: ubuntu-22.04
1516
steps:
1617
- uses: actions/checkout@v4.1.1
@@ -27,12 +28,20 @@ jobs:
2728
&&
2829
docker build
2930
--tag "${{ env.project-name }}:latest"
30-
--build-arg UNIFYSDK_GIT_REPOSITORY=${{ secrets.UNIFYSDK_GIT_REPOSITORY }}
31-
--build-arg UNIFYSDK_GIT_TAG=${{ secrets.UNIFYSDK_GIT_TAG }}
31+
--build-arg
32+
UNIFYSDK_GIT_REPOSITORY=${{ secrets.UNIFYSDK_GIT_REPOSITORY }}
33+
--build-arg
34+
UNIFYSDK_GIT_TAG=${{ secrets.UNIFYSDK_GIT_TAG }}
3235
.
3336
&&
3437
df -h
3538
39+
- name: Upload container image
40+
uses: ishworkh/container-image-artifact-upload@v2.0.0
41+
with:
42+
image: "${{ env.project-name }}:latest"
43+
retention_days: 10
44+
3645
- name: Extract artifacts
3746
run: >-
3847
container=$(docker create "${{ env.project-name }}:latest")

.github/workflows/test.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# YAML -*- mode: yaml; tab-width: 2; indent-tabs-mode: nil; coding: utf-8 -*-
2+
# SPDX-License-Identifier: Zlib
3+
# SPDX-FileCopyrightText: Silicon Laboratories Inc. https://www.silabs.com
4+
---
5+
6+
name: test
7+
8+
on: # yamllint disable-line rule:truthy
9+
workflow_run:
10+
workflows: ["build"]
11+
types:
12+
- completed
13+
jobs:
14+
test:
15+
runs-on: ubuntu-24.04
16+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
17+
steps:
18+
- name: Download image
19+
uses: ishworkh/container-image-artifact-download@v2.0.0
20+
with:
21+
image: "${{ github.event.repository.name }}:latest"
22+
workflow: "build"
23+
token: ${{ secrets.GH_SL_ACCESS_TOKEN }}
24+
workflow_run_id: ${{ github.event.workflow_run.id }}
25+
26+
- uses: actions/checkout@v4.1.1
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Download embedded applications package
31+
uses: robinraju/release-downloader@v1.12
32+
with:
33+
repository: 'Z-Wave-Alliance/z-wave-stack-binaries'
34+
fileName: 'z-wave-stack-binaries-*-Linux.tar.gz'
35+
token: ${{ secrets.GH_ZWAVE_ACCESS_TOKEN }}
36+
latest: true
37+
38+
- name: Setup
39+
env:
40+
debian_packages: time screen docker-compose mosquitto-clients jq wget
41+
run: >-
42+
set -x
43+
&& sudo apt update
44+
&& sudo apt install -y --no-install-recommends
45+
${{ env.debian_packages }}
46+
&& sudo apt-get clean -y
47+
&& echo "https://github.com/Z-Wave-Alliance/z-wave-stack/issues/733"
48+
&& mkdir -p z-wave-stack-binaries
49+
&& tar xfz z-wave-stack-binaries-*-Linux.tar.gz
50+
-C z-wave-stack-binaries
51+
&& rm z-wave-stack-binaries-*-Linux.tar.gz
52+
&& date -u
53+
54+
- name: Run
55+
run: |
56+
set -x
57+
export ZPC_RUN_MODE="docker"
58+
export ZPC_COMMAND="docker run ${{ github.event.repository.name }}"
59+
$ZPC_COMMAND --version
60+
docker-compose pull
61+
export ZPC_COMMAND="docker-compose up --abort-on-container-exit"
62+
cd z-wave-stack-binaries/bin && file -E *_x86_REALTIME.elf

Dockerfile

+8-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
FROM debian:bookworm as builder
1+
# SPDX-License-Identifier: Zlib
2+
# SPDX-FileCopyrightText: Silicon Laboratories Inc. https://www.silabs.com
23

3-
ENV DEBIAN_FRONTEND noninteractive
4-
ENV LC_ALL en_US.UTF-8
5-
ENV LANG ${LC_ALL}
4+
FROM debian:bookworm as builder
65

76
ARG UNIFYSDK_GIT_REPOSITORY https://github.com/SiliconLabs/UnifySDK
87
ARG UNIFYSDK_GIT_TAG main
98

10-
RUN echo "# log: Configuring locales" \
11-
&& set -x \
12-
&& apt-get update -y \
13-
&& apt-get install -y locales \
14-
&& echo "${LC_ALL} UTF-8" | tee /etc/locale.gen \
15-
&& locale-gen ${LC_ALL} \
16-
&& dpkg-reconfigure locales \
17-
&& TZ=Etc/UTC apt-get -y install tzdata \
18-
&& date -u
19-
209
ENV project z-wave-protocol-controller
2110
ENV workdir /usr/local/opt/${project}
2211
ADD . ${workdir}
@@ -26,7 +15,8 @@ WORKDIR ${workdir}
2615
RUN echo "# log: Setup system" \
2716
&& set -x \
2817
&& df -h \
29-
&& apt-get install -y make sudo \
18+
&& apt-get update \
19+
&& apt-get install -y --no-install-recommends -- make sudo \
3020
&& ./helper.mk help setup \
3121
&& date -u
3222

@@ -52,10 +42,11 @@ RUN echo "# log: Install to system" \
5242
&& set -x \
5343
&& apt-get update \
5444
&& dpkg -i ./dist/${project}*/*.deb \
55-
|| apt install -f -y \
56-
&& apt-get install -y mosquitto \
45+
|| apt install -f -y --no-install-recommends \
46+
&& echo "TODO: rm -rf dist # If artifacts are no more needed" \
5747
&& apt-get clean -y \
5848
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ \
49+
&& df -h \
5950
&& date -u
6051

6152
ENTRYPOINT [ "/usr/bin/zpc" ]

docker-compose.yml

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
# -*- coding: utf-8 -*-
2-
# SPDX-License-Identifier: ZLib
3-
4-
version: "2"
1+
# YAML -*- mode: yaml; tab-width: 2; indent-tabs-mode: nil; coding: utf-8 -*-
2+
# SPDX-License-Identifier: Zlib
3+
# SPDX-FileCopyrightText: Silicon Laboratories Inc. https://www.silabs.com
4+
---
55

66
services:
77
broker:
8-
image: eclipse-mosquitto:1.5.9
8+
image: eclipse-mosquitto:1.6.15 # TODO: 2.0.21 needs config files
99
ports:
1010
- '1883:1883'
1111
command: mosquitto
12-
restart: unless-stopped
13-
12+
logging:
13+
driver: "none" # Disables logging for this service
14+
restart: "no"
15+
stop_signal: SIGTERM
1416
zpc:
17+
image: z-wave-protocol-controller
1518
build: .
16-
command: run --mqtt.host=broker
19+
command: run --mqtt.host=broker --zpc.serial="${ZPC_DEVICE:-/dev/ttyACM0}" ${ZPC_ARGS}
20+
volumes:
21+
- /dev/pts:/dev/pts
1722
devices:
18-
- ${DEVICE:-/dev/ttyACM0}:/dev/ttyUSB0
23+
- ${ZPC_DEVICE:-/dev/ttyACM0}:/dev/ttyUSB0
1924
depends_on:
2025
- broker
21-
restart: on-failure
26+
environment:
27+
ZPC_ARGS: "--"

0 commit comments

Comments
 (0)