Skip to content

Commit 4e8f76f

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

File tree

4 files changed

+303
-14
lines changed

4 files changed

+303
-14
lines changed

.github/gen-applications.py

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

.github/gen-matrix.py

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

.github/workflows/build.yaml

+18-14
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+
APP_PATH=$(python3 .github/gen-applications.py ${{ matrix.application }} path)
129+
echo $APP_PATH
130+
echo app_path=${APP_PATH} >> $GITHUB_OUTPUT
131+
BUILD_CMD=$(python3 .github/gen-applications.py ${{ matrix.application }} cmd)
132+
echo $BUILD_CMD
133+
echo build_cmd=${BUILD_CMD} >> $GITHUB_OUTPUT
121134
- name: restore cache with chester-sdk
122135
id: cache-chester-sdk
123136
uses: actions/cache/restore@v4
@@ -137,14 +150,5 @@ jobs:
137150
chester-sdk/tools
138151
chester-sdk/zephyr
139152
- name: build
140-
run: |
141-
cd chester-sdk/chester/applications/${{ matrix.application }}
142-
west build
143-
# ------------------------
144-
# debug-echo:
145-
# runs-on: ubuntu-latest
146-
# needs:
147-
# - prepare
148-
# steps:
149-
# - name: Echo previous outputs
150-
# run: echo "${{ toJSON(needs.prepare.outputs) }}"
153+
working-directory: ${{ steps.build-command.outputs.app_path }}
154+
run: ${{ steps.build-command.outputs.build_cmd }}

applications/applications.yaml

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
#
2+
# Copyright (c) 2024 HARDWARIO a.s.
3+
#
4+
# SPDX-License-Identifier: LicenseRef-HARDWARIO-5-Clause
5+
#
6+
---
7+
8+
###### Clime ######
9+
-
10+
name: CHESTER Clime
11+
fw_bundle: com.hardwario.chester.app.clime
12+
fw_name: hio-chester-clime
13+
fw_version: v2.3.0
14+
shields: ctr_lrw ctr_lte ctr_s2
15+
16+
-
17+
name: CHESTER Clime Z
18+
fw_bundle: com.hardwario.chester.app.clime.z
19+
fw_name: hio-chester-clime-z
20+
fw_version: v2.3.0
21+
shields: ctr_lrw ctr_lte ctr_s2 ctr_z
22+
remark: Support for CHESTER-Z
23+
24+
-
25+
name: CHESTER Clime IAQ
26+
fw_bundle: com.hardwario.chester.app.clime.iaq
27+
fw_name: hio-chester-clime-iaq
28+
fw_version: v2.3.0
29+
shields: ctr_lrw ctr_lte ctr_s1
30+
31+
-
32+
name: CHESTER Clime 1W
33+
fw_bundle: com.hardwario.chester.app.clime.1w
34+
fw_name: hio-chester-clime-1w
35+
fw_version: v2.3.0
36+
shields: ctr_lrw ctr_lte ctr_ds18b20
37+
38+
-
39+
name: CHESTER Clime 1WH
40+
fw_bundle: com.hardwario.chester.app.clime.1wh
41+
fw_name: hio-chester-clime-1wh
42+
fw_version: v2.3.0
43+
shields: ctr_lrw ctr_lte ctr_ds18b20 ctr_s2
44+
remark: Support for CHESTER-S2, 1-Wire
45+
46+
-
47+
name: CHESTER Clime RTD
48+
fw_bundle: com.hardwario.chester.app.clime.rtd
49+
fw_name: hio-chester-clime-rtd
50+
fw_version: v2.3.0
51+
shields: ctr_lrw ctr_lte ctr_rtd_a
52+
53+
###### Push ######
54+
-
55+
name: CHESTER Push
56+
fw_bundle: com.hardwario.chester.app.push
57+
fw_name: hio-chester-push
58+
fw_version: v2.3.0
59+
shields: ctr_lrw ctr_lte ctr_s2
60+
61+
-
62+
name: CHESTER Push FM
63+
fw_bundle: com.hardwario.chester.app.push.fm
64+
fw_name: hio-chester-push-fm
65+
fw_version: v2.3.0
66+
shields: ctr_lrw ctr_lte ctr_s2
67+
extra_args: -DCONFIG_APP_FLIP_MODE=y
68+
69+
###### Counter ######
70+
-
71+
name: CHESTER Counter
72+
fw_bundle: com.hardwario.chester.app.counter
73+
fw_name: hio-chester-counter
74+
fw_version: v2.3.0
75+
shields: ctr_lte ctr_x0_a
76+
77+
-
78+
name: CHESTER Counter Z
79+
fw_bundle: com.hardwario.chester.app.counter.z
80+
fw_name: hio-chester-counter-z
81+
fw_version: v2.3.0
82+
shields: ctr_lte ctr_x0_a ctr_z
83+
remark: Support for CHESTER-Z
84+
85+
###### Input ######
86+
-
87+
name: CHESTER Input
88+
fw_bundle: com.hardwario.chester.app.input
89+
fw_name: hio-chester-input
90+
fw_version: v2.3.0
91+
shields: ctr_ds18b20 ctr_lte ctr_x0_a
92+
remark: Support for 1-Wire
93+
94+
-
95+
name: CHESTER Input Z
96+
fw_bundle: com.hardwario.chester.app.input.z
97+
fw_name: hio-chester-input-z
98+
fw_version: v2.3.0
99+
shields: ctr_ds18b20 ctr_lte ctr_x0_a ctr_z
100+
remark: Support for CHESTER-Z, 1-Wire
101+
102+
-
103+
name: CHESTER Input ZH
104+
fw_bundle: com.hardwario.chester.app.input.zh
105+
fw_name: hio-chester-input-zh
106+
fw_version: v2.3.0
107+
shields: ctr_ds18b20 ctr_lte ctr_x0_a ctr_z ctr_s2
108+
remark: Support for CHESTER-Z, 1-Wire, S2
109+
110+
###### Current ######
111+
-
112+
name: CHESTER Current
113+
fw_bundle: com.hardwario.chester.app.current
114+
fw_name: hio-chester-current
115+
fw_version: v2.3.0
116+
shields: ctr_k1 ctr_lrw ctr_lte
117+
118+
-
119+
name: CHESTER Current Z
120+
fw_bundle: com.hardwario.chester.app.current.z
121+
fw_name: hio-chester-current-z
122+
fw_version: v2.3.0
123+
shields: ctr_k1 ctr_lrw ctr_lte ctr_z
124+
remark: Support for CHESTER-Z
125+
126+
- name: CHESTER Current 1W
127+
fw_bundle: com.hardwario.chester.app.current.1w
128+
fw_name: hio-chester-current-1w
129+
fw_version: v2.3.0
130+
shields: ctr_k1 ctr_lrw ctr_lte ctr_ds18b20
131+
remark: Support for 1-Wire
132+
133+
###### Scale ######
134+
-
135+
name: CHESTER Scale
136+
fw_bundle: com.hardwario.chester.app.scale
137+
fw_name: hio-chester-scale
138+
fw_version: v2.3.0
139+
shields: ctr_lte ctr_x3_a
140+
141+
-
142+
name: CHESTER Scale Z
143+
fw_bundle: com.hardwario.chester.app.scale.z
144+
fw_name: hio-chester-scale-z
145+
fw_version: v2.3.0
146+
shields: ctr_lte ctr_x3_a ctr_z
147+
remark: Support for CHESTER-Z
148+
149+
### CHESTER Meteo ######
150+
-
151+
name: CHESTER Meteo
152+
fw_bundle: com.hardwario.chester.app.meteo
153+
fw_name: hio-chester-meteo
154+
fw_version: v2.3.0
155+
shields: ctr_barometer_tag ctr_ds18b20 ctr_lte ctr_s2 ctr_meteo_a ctr_soil_sensor
156+
157+
- name: CHESTER Meteo Z
158+
fw_bundle: com.hardwario.chester.app.meteo.z
159+
fw_name: hio-chester-meteo-z
160+
fw_version: v2.3.0
161+
shields: ctr_barometer_tag ctr_ds18b20 ctr_lte ctr_s2 ctr_meteo_a ctr_soil_sensor ctr_z
162+
remark: Support for CHESTER-Z
163+
164+
### CHESTER Range ######
165+
-
166+
name: CHESTER Range
167+
fw_bundle: com.hardwario.chester.app.range
168+
fw_name: hio-chester-range
169+
fw_version: v2.3.0
170+
shields: ctr_ds18b20 ctr_lte ctr_mb7066_a
171+
172+
-
173+
name: CHESTER Range Z
174+
fw_bundle: com.hardwario.chester.app.range.z
175+
fw_name: hio-chester-range-z
176+
fw_version: v2.3.0
177+
shields: ctr_ds18b20 ctr_lte ctr_mb7066_a ctr_z
178+
remark: Support for CHESTER-Z

0 commit comments

Comments
 (0)