Skip to content

Commit 8bdf378

Browse files
authored
Merge pull request #32 from edgeimpulse/test-build
Add test builds
2 parents 69ea312 + c1d0328 commit 8bdf378

1 file changed

Lines changed: 227 additions & 0 deletions

File tree

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: Build APP x TARGET matrix
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
prepare-model-artifact:
12+
name: Prepare Edge Impulse model artifact
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Build and deploy Edge Impulse model (FOMO / TFLite)
16+
id: build-deploy-fomo-tflite
17+
uses: edgeimpulse/build-deploy@v2
18+
with:
19+
project_id: 137095
20+
api_key: ${{ secrets['EI_FOMO_API_KEY'] }}
21+
impulse_id: 3
22+
engine: tflite
23+
deployment_type: zip-linux
24+
25+
- name: Upload deployment artifact (FOMO / TFLite)
26+
uses: actions/upload-artifact@v7
27+
with:
28+
name: edge-impulse-deployment-fomo-tflite
29+
path: ${{ steps.build-deploy-fomo-tflite.outputs.deployment_file_name }}
30+
if-no-files-found: error
31+
32+
- name: Build and deploy Edge Impulse model (KWS / TFLite)
33+
id: build-deploy-kws-tflite
34+
uses: edgeimpulse/build-deploy@v2
35+
with:
36+
project_id: 3
37+
api_key: ${{ secrets['EI_KWS_API_KEY'] }}
38+
impulse_id: 1
39+
engine: tflite
40+
deployment_type: zip-linux
41+
42+
- name: Upload deployment artifact (KWS / TFLite)
43+
uses: actions/upload-artifact@v7
44+
with:
45+
name: edge-impulse-deployment-kws-tflite
46+
path: ${{ steps.build-deploy-kws-tflite.outputs.deployment_file_name }}
47+
if-no-files-found: error
48+
49+
build-matrix:
50+
needs: prepare-model-artifact
51+
name: ${{ matrix.app }} on ${{ matrix.target.name }}
52+
runs-on: ${{ matrix.target.runner }}
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
app:
57+
- APP_COLLECT
58+
- APP_CUSTOM
59+
- APP_AUDIO
60+
- APP_CAMERA
61+
- APP_VIDEO
62+
- APP_EIM
63+
target:
64+
- name: TARGET_LINUX_X86
65+
runner: ubuntu-24.04
66+
target_flags: TARGET_LINUX_X86=1 USE_FULL_TFLITE=1
67+
cc: gcc
68+
cxx: g++
69+
deployment: zip-linux
70+
- name: TARGET_LINUX_ARMV7
71+
runner: ubuntu-24.04
72+
target_flags: TARGET_LINUX_ARMV7=1 USE_FULL_TFLITE=1
73+
cc: arm-linux-gnueabihf-gcc
74+
cxx: arm-linux-gnueabihf-g++
75+
deployment: zip-linux
76+
- name: TARGET_LINUX_ARMV7_LEGACY
77+
runner: ubuntu-24.04
78+
target_flags: TARGET_LINUX_ARMV7_LEGACY=1 USE_FULL_TFLITE=1
79+
cc: arm-linux-gnueabihf-gcc
80+
cxx: arm-linux-gnueabihf-g++
81+
deployment: zip-linux
82+
- name: TARGET_LINUX_AARCH64
83+
runner: ubuntu-24.04
84+
target_flags: TARGET_LINUX_AARCH64=1 USE_FULL_TFLITE=1
85+
cc: aarch64-linux-gnu-gcc
86+
cxx: aarch64-linux-gnu-g++
87+
deployment: zip-linux
88+
- name: TARGET_MAC_X86_64
89+
runner: macos-26-intel
90+
target_flags: TARGET_MAC_X86_64=1 USE_FULL_TFLITE=1
91+
cc: clang
92+
cxx: clang++
93+
deployment: zip-linux
94+
- name: TARGET_MAC_ARM64
95+
runner: macos-26
96+
target_flags: TARGET_MAC_ARM64=1 USE_FULL_TFLITE=1
97+
cc: clang
98+
cxx: clang++
99+
deployment: zip-linux
100+
101+
steps:
102+
- name: Checkout
103+
uses: actions/checkout@v6
104+
with:
105+
submodules: 'recursive'
106+
107+
- name: Validate matrix combination
108+
id: validate
109+
shell: bash
110+
run: |
111+
set -euo pipefail
112+
113+
app='${{ matrix.app }}'
114+
target='${{ matrix.target.name }}'
115+
supported='true'
116+
reason=''
117+
118+
if [[ "$app" == "APP_AUDIO" && "$target" != "TARGET_LINUX_X86" ]]; then
119+
supported='false'
120+
reason='Audio app depends on ALSA and is only validated on native Linux x86 in this workflow.'
121+
fi
122+
123+
if [[ "$app" == "APP_CAMERA" && "$target" != "TARGET_LINUX_X86" ]]; then
124+
supported='false'
125+
reason='Camera app depends on OpenCV and is validated only on native Linux runners in this workflow.'
126+
fi
127+
128+
if [[ "$app" == "APP_VIDEO" && "$target" != "TARGET_LINUX_X86" ]]; then
129+
supported='false'
130+
reason='Video app depends on OpenCV and is validated only on native Linux runners in this workflow.'
131+
fi
132+
133+
echo "supported=$supported" >> "$GITHUB_OUTPUT"
134+
echo "reason=$reason" >> "$GITHUB_OUTPUT"
135+
136+
- name: Skip unsupported combination
137+
if: steps.validate.outputs.supported != 'true'
138+
shell: bash
139+
run: |
140+
echo "Skipping ${{ matrix.app }} + ${{ matrix.target.name }}"
141+
echo "Reason: ${{ steps.validate.outputs.reason }}"
142+
143+
- name: Install Linux dependencies
144+
if: runner.os == 'Linux' && steps.validate.outputs.supported == 'true'
145+
shell: bash
146+
run: |
147+
set -euxo pipefail
148+
sudo apt-get update
149+
sudo apt-get install -y make clang
150+
151+
target='${{ matrix.target.name }}'
152+
app='${{ matrix.app }}'
153+
154+
if [[ "$target" == "TARGET_LINUX_ARMV7" || "$target" == "TARGET_LINUX_ARMV7_LEGACY" ]]; then
155+
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
156+
fi
157+
158+
if [[ "$target" == "TARGET_LINUX_AARCH64" ]]; then
159+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
160+
fi
161+
162+
if [[ "$app" == "APP_AUDIO" ]]; then
163+
sudo apt-get install -y libasound2-dev
164+
fi
165+
166+
if [[ ("$app" == "APP_CAMERA" || "$app" == "APP_VIDEO") && "$target" == "TARGET_LINUX_X86" ]]; then
167+
sudo apt-get install -y git cmake
168+
sh build-opencv-linux.sh
169+
fi
170+
171+
- name: Install macOS dependencies
172+
if: runner.os == 'macOS' && (matrix.app == 'APP_CAMERA' || matrix.app == 'APP_VIDEO') && steps.validate.outputs.supported == 'true'
173+
shell: bash
174+
run: |
175+
set -euxo pipefail
176+
brew update
177+
brew install opencv
178+
179+
- name: Download deployment artifact (FOMO / TFLite)
180+
if: matrix.app != 'APP_COLLECT' && matrix.app != 'APP_AUDIO' && matrix.target.deployment == 'zip-linux' && steps.validate.outputs.supported == 'true'
181+
uses: actions/download-artifact@v8
182+
with:
183+
name: edge-impulse-deployment-fomo-tflite
184+
path: .
185+
186+
- name: Download deployment artifact (KWS / TFLite)
187+
if: matrix.app == 'APP_AUDIO' && matrix.target.deployment == 'zip-linux' && steps.validate.outputs.supported == 'true'
188+
uses: actions/download-artifact@v8
189+
with:
190+
name: edge-impulse-deployment-kws-tflite
191+
path: .
192+
193+
- name: Extract model and SDK
194+
if: matrix.app != 'APP_COLLECT' && steps.validate.outputs.supported == 'true'
195+
shell: bash
196+
run: |
197+
set -euxo pipefail
198+
199+
rm -rf edge-impulse-sdk/ model-parameters/ tflite-model/ temp/
200+
mkdir -p temp/
201+
202+
deployment_file="$(find . -maxdepth 1 -type f -name '*.zip' | head -n 1)"
203+
if [[ -z "$deployment_file" ]]; then
204+
echo "No deployment zip file found after artifact download"
205+
exit 1
206+
fi
207+
208+
unzip -q "$deployment_file" -d temp
209+
mv temp/* .
210+
211+
rm -rf "$deployment_file" temp
212+
213+
- name: Build
214+
if: steps.validate.outputs.supported == 'true'
215+
shell: bash
216+
run: |
217+
set -euxo pipefail
218+
219+
JOBS=2
220+
if [[ "$RUNNER_OS" == "Linux" ]]; then
221+
JOBS="$(nproc)"
222+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
223+
JOBS="$(sysctl -n hw.ncpu)"
224+
fi
225+
226+
${{ matrix.app }}=1 ${{ matrix.target.target_flags }} make clean
227+
${{ matrix.app }}=1 ${{ matrix.target.target_flags }} make -j"$JOBS" CC=${{ matrix.target.cc }} CXX=${{ matrix.target.cxx }}

0 commit comments

Comments
 (0)