Skip to content

Commit 8b74fbf

Browse files
committed
CI build: Add application matrix
Signed-off-by: Karel Blavka <[email protected]>
1 parent 6d9b649 commit 8b74fbf

File tree

4 files changed

+166
-5
lines changed

4 files changed

+166
-5
lines changed

.github/gen-applications.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python3
2+
import yaml
3+
import sys
4+
import json
5+
import os
6+
7+
if len(sys.argv) != 3:
8+
print("Usage: gen-applications.py <bundle> <type>")
9+
sys.exit(1)
10+
11+
bundle = sys.argv[1]
12+
13+
path = os.path.dirname(os.path.realpath(__file__))
14+
filepath = os.path.join(path, '../applications/applications.yaml')
15+
applications = yaml.safe_load(open(filepath))
16+
17+
for a in applications:
18+
if 'bundle' in a and a['bundle'] == bundle:
19+
if sys.argv[2] == 'cmd':
20+
21+
cmd = f'FW_BUNDLE={a["bundle"]}'
22+
23+
if 'fw_name' in a:
24+
cmd += f' FW_NAME="{a["fw_name"]}"'
25+
26+
if 'fw_version' in a:
27+
cmd += f' FW_VERSION={a["fw_version"]}'
28+
29+
cmd += ' west build'
30+
31+
if 'shield' in a or 'extra_args' in a:
32+
cmd += ' --'
33+
34+
if 'shield' in a:
35+
cmd += f' -DSHIELD="{a["shield"]}"'
36+
37+
if 'extra_args' in a:
38+
cmd += f' {a["extra_args"]}'
39+
40+
print(cmd)
41+
42+
sys.exit(0)
43+
elif sys.argv[2] == 'path':
44+
45+
if not 'path' in a:
46+
d = a['bundle'].split('.')[4]
47+
else:
48+
d = a['path']
49+
50+
print(f'chester-sdk/chester/applications/{d}')
51+
52+
sys.exit(0)
53+
else:
54+
print("Unknown type")
55+
sys.exit(1)
56+
else:
57+
print("Bundle not found")
58+
sys.exit(1)

.github/gen-matrix.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
import yaml
3+
import sys
4+
import json
5+
import os
6+
7+
if len(sys.argv) != 2:
8+
print("Usage: gen-matrix.py <type>")
9+
sys.exit(1)
10+
11+
path = os.path.dirname(os.path.realpath(__file__))
12+
13+
if sys.argv[1] == 'applications':
14+
filepath = os.path.join(path, '../applications/applications.yaml')
15+
applications = yaml.safe_load(open(filepath))
16+
print(json.dumps([a['bundle']
17+
for a in applications if 'bundle' in a], sort_keys=True))
18+
19+
elif sys.argv[1] == 'samples':
20+
samples = os.listdir(os.path.join(path, '../samples'))
21+
print(json.dumps([s for s in samples if os.path.isdir(
22+
os.path.join(path, '../samples', s))], sort_keys=True))
23+
24+
else:
25+
print("Unknown type")
26+
sys.exit(1)

.github/workflows/build.yaml

+18-5
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ jobs:
5656
echo short-sha=${SHORT_SHA} >> $GITHUB_OUTPUT
5757
- name: Generate Matrix
5858
id: generate-matrix
59+
working-directory: ./chester-sdk/chester
5960
run: |
60-
SAMPLES=$(ls chester-sdk/chester/samples | jq -R -s -c 'split("\n")[:-1]')
61+
SAMPLES=$(python3 .github/gen-matrix.py samples)
62+
echo $SAMPLES
6163
echo samples=${SAMPLES} >> $GITHUB_OUTPUT
62-
APPLICATIONS=$(ls chester-sdk/chester/applications | jq -R -s -c 'split("\n")[:-1]')
64+
APPLICATIONS=$(python3 .github/gen-matrix.py applications)
65+
echo $APPLICATIONS
6366
echo applications=${APPLICATIONS} >> $GITHUB_OUTPUT
6467
6568
# ------------------------
@@ -101,7 +104,7 @@ jobs:
101104
cd chester-sdk/chester/samples/${{ matrix.sample }}
102105
west build
103106
# ------------------------
104-
build-application:
107+
build-app:
105108
runs-on: ubuntu-latest
106109
container:
107110
image: hardwario/nrf-connect-sdk-build:v2.5.0-2
@@ -118,6 +121,16 @@ jobs:
118121
uses: actions/checkout@v4
119122
with:
120123
path: 'chester-sdk/chester'
124+
- name: gen build command
125+
id: build-command
126+
working-directory: ./chester-sdk/chester
127+
run: |
128+
BUILD_CMD=$(python3 .github/gen-applications.py ${{ matrix.application }} cmd)
129+
echo $BUILD_CMD
130+
echo build_cmd=${BUILD_CMD} >> $GITHUB_OUTPUT
131+
APP_PATH=$(python3 .github/gen-applications.py ${{ matrix.application }} path)
132+
echo $APP_PATH
133+
echo app_path=${APP_PATH} >> $GITHUB_OUTPUT
121134
- name: restore cache with chester-sdk
122135
id: cache-chester-sdk
123136
uses: actions/cache/restore@v4
@@ -138,8 +151,8 @@ jobs:
138151
chester-sdk/zephyr
139152
- name: build
140153
run: |
141-
cd chester-sdk/chester/applications/${{ matrix.application }}
142-
west build
154+
cd ${{ steps.build-command.outputs.app_path }}
155+
${{ steps.build-command.outputs.build_cmd }}
143156
# ------------------------
144157
# debug-echo:
145158
# runs-on: ubuntu-latest

applications/applications.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#
2+
# Copyright (c) 2024 HARDWARIO a.s.
3+
#
4+
# SPDX-License-Identifier: LicenseRef-HARDWARIO-5-Clause
5+
#
6+
---
7+
-
8+
name: CHESTER Clime
9+
bundle: com.hardwario.chester.app.clime
10+
fw_name: hio-chester-clime
11+
fw_version: v2.3.0
12+
shield: ctr_lrw ctr_lte ctr_s2
13+
14+
-
15+
name: CHESTER Clime Z
16+
bundle: com.hardwario.chester.app.clime.z
17+
fw_name: hio-chester-clime-z
18+
fw_version: v2.3.0
19+
shield: ctr_lrw ctr_lte ctr_s2 ctr_z
20+
remark: Support for CHESTER-Z
21+
22+
-
23+
name: CHESTER Clime IAQ
24+
bundle: com.hardwario.chester.app.clime.iaq
25+
fw_name: hio-chester-clime-iaq
26+
fw_version: v2.3.0
27+
shield: ctr_lrw ctr_lte ctr_s1
28+
29+
-
30+
name: CHESTER Clime 1W
31+
bundle: com.hardwario.chester.app.clime.1w
32+
fw_name: hio-chester-clime-1w
33+
fw_version: v2.3.0
34+
shield: ctr_lrw ctr_lte ctr_ds18b20
35+
36+
-
37+
name: CHESTER Clime 1WH
38+
bundle: com.hardwario.chester.app.clime.1wh
39+
fw_name: hio-chester-clime-1wh
40+
fw_version: v2.3.0
41+
shield: ctr_lrw ctr_lte ctr_ds18b20 ctr_s2
42+
remark: Support for CHESTER-S2, 1-Wire
43+
44+
-
45+
name: CHESTER Clime RTD
46+
bundle: com.hardwario.chester.app.clime.rtd
47+
fw_name: hio-chester-clime-rtd
48+
fw_version: v2.3.0
49+
shield: ctr_lrw ctr_lte ctr_rtd_a
50+
51+
-
52+
name: CHESTER Push
53+
bundle: com.hardwario.chester.app.push
54+
fw_name: hio-chester-push
55+
fw_version: v2.3.0
56+
shield: ctr_lrw ctr_lte ctr_s2
57+
58+
-
59+
name: CHESTER Push FM
60+
bundle: com.hardwario.chester.app.push.fm
61+
fw_name: hio-chester-push-fm
62+
fw_version: v2.3.0
63+
shield: ctr_lrw ctr_lte ctr_s2
64+
extra_args: -DCONFIG_APP_FLIP_MODE=y

0 commit comments

Comments
 (0)