88 - ' examples/**'
99 - ' lib/**'
1010 - ' hw/**'
11- - ' tools/get_deps.py'
1211 - ' tools/build.py'
12+ - ' tools/get_deps.py'
1313 - ' .github/actions/**'
1414 - ' .github/workflows/build.yml'
1515 - ' .github/workflows/build_util.yml'
2121 - ' examples/**'
2222 - ' lib/**'
2323 - ' hw/**'
24- - ' tools/get_deps.py '
24+ - ' test/hil/** '
2525 - ' tools/build.py'
26+ - ' tools/get_deps.py'
2627 - ' .github/actions/**'
2728 - ' .github/workflows/build.yml'
2829 - ' .github/workflows/build_util.yml'
@@ -31,45 +32,57 @@ concurrency:
3132 group : ${{ github.workflow }}-${{ github.ref }}
3233 cancel-in-progress : true
3334
35+ env :
36+ HIL_JSON : test/hil/tinyusb.json
37+
3438jobs :
3539 set-matrix :
3640 runs-on : ubuntu-latest
3741 outputs :
3842 json : ${{ steps.set-matrix-json.outputs.matrix }}
43+ hil_json : ${{ steps.set-matrix-json.outputs.hil_matrix }}
3944 steps :
4045 - name : Checkout TinyUSB
4146 uses : actions/checkout@v4
4247
4348 - name : Generate matrix json
4449 id : set-matrix-json
4550 run : |
51+ # build matrix
4652 MATRIX_JSON=$(python .github/workflows/ci_set_matrix.py)
4753 echo "matrix=$MATRIX_JSON"
4854 echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
55+ # hil matrix
56+ HIL_MATRIX_JSON=$(python test/hil/hil_ci_set_matrix.py ${{ env.HIL_JSON }})
57+ echo "hil_matrix=$HIL_MATRIX_JSON"
58+ echo "hil_matrix=$HIL_MATRIX_JSON" >> $GITHUB_OUTPUT
4959
5060 # ---------------------------------------
51- # Build CMake
61+ # Build CMake: only build on push with one-per-family.
62+ # Full built is done by CircleCI in PR
5263 # ---------------------------------------
5364 cmake :
65+ if : github.event_name == 'push'
5466 needs : set-matrix
5567 uses : ./.github/workflows/build_util.yml
5668 strategy :
5769 fail-fast : false
5870 matrix :
5971 toolchain :
60- # - 'arm-clang' is built by circle-ci in PR
6172 - ' aarch64-gcc'
73+ # - 'arm-clang'
6274 - ' arm-gcc'
75+ - ' esp-idf'
6376 - ' msp430-gcc'
6477 - ' riscv-gcc'
6578 with :
6679 build-system : ' cmake'
6780 toolchain : ${{ matrix.toolchain }}
6881 build-args : ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }}
69- one-per-family : ${{ github.event_name == 'push' }}
82+ one-per-family : true
7083
7184 # ---------------------------------------
72- # Build Make (built by circle-ci in PR, only build on push here)
85+ # Build Make: only build on push with one-per-family
7386 # ---------------------------------------
7487 make :
7588 if : github.event_name == 'push'
@@ -79,36 +92,18 @@ jobs:
7992 fail-fast : false
8093 matrix :
8194 toolchain :
82- # 'arm-clang'
83- - ' arm-gcc'
8495 - ' aarch64-gcc'
96+ # - 'arm-clang'
97+ - ' arm-gcc'
8598 - ' msp430-gcc'
8699 - ' riscv-gcc'
87100 - ' rx-gcc'
88- - ' esp-idf'
89101 with :
90102 build-system : ' make'
91103 toolchain : ${{ matrix.toolchain }}
92104 build-args : ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }}
93105 one-per-family : true
94106
95- # ---------------------------------------
96- # Build Make on Windows/MacOS
97- # ---------------------------------------
98- make-os :
99- if : github.event_name == 'pull_request'
100- uses : ./.github/workflows/build_util.yml
101- strategy :
102- fail-fast : false
103- matrix :
104- os : [windows-latest, macos-latest]
105- with :
106- os : ${{ matrix.os }}
107- build-system : ' make'
108- toolchain : ' arm-gcc'
109- build-args : ' ["stm32h7"]'
110- one-per-family : true
111-
112107 # ---------------------------------------
113108 # Build IAR
114109 # Since IAR Token secret is not passed to forked PR, only build non-forked PR with make.
@@ -131,6 +126,23 @@ jobs:
131126 build-args : ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)['arm-iar']) }}
132127 one-per-family : true
133128
129+ # ---------------------------------------
130+ # Build Make on Windows/MacOS
131+ # ---------------------------------------
132+ make-os :
133+ if : github.event_name == 'pull_request'
134+ uses : ./.github/workflows/build_util.yml
135+ strategy :
136+ fail-fast : false
137+ matrix :
138+ os : [windows-latest, macos-latest]
139+ with :
140+ os : ${{ matrix.os }}
141+ build-system : ' make'
142+ toolchain : ' arm-gcc'
143+ build-args : ' ["stm32h7"]'
144+ one-per-family : true
145+
134146 # ---------------------------------------
135147 # Zephyr
136148 # ---------------------------------------
@@ -151,3 +163,113 @@ jobs:
151163 run : |
152164 west build -b pca10056 -d examples/device/cdc_msc/build examples/device/cdc_msc -- -DRTOS=zephyr
153165 west build -b pca10056 -d examples/device/msc_dual_lun/build examples/device/msc_dual_lun -- -DRTOS=zephyr
166+
167+ # ---------------------------------------
168+ # Hardware in the loop (HIL)
169+ # Run on PR only (hil-tinyusb), hil-hfp only run on non-forked PR
170+ # ---------------------------------------
171+ hil-build :
172+ if : |
173+ github.repository_owner == 'hathach' &&
174+ (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
175+ needs : set-matrix
176+ uses : ./.github/workflows/build_util.yml
177+ strategy :
178+ fail-fast : false
179+ matrix :
180+ toolchain :
181+ - ' arm-gcc'
182+ - ' esp-idf'
183+ with :
184+ build-system : ' cmake'
185+ toolchain : ${{ matrix.toolchain }}
186+ build-args : ${{ toJSON(fromJSON(needs.set-matrix.outputs.hil_json)[matrix.toolchain]) }}
187+ one-per-family : true
188+ upload-artifacts : true
189+
190+ # ---------------------------------------
191+ # Hardware in the loop (HIL)
192+ # self-hosted on local VM, for attached hardware checkout HIL_JSON
193+ # ---------------------------------------
194+ hil-tinyusb :
195+ if : |
196+ github.repository_owner == 'hathach' &&
197+ (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
198+ needs : hil-build
199+ runs-on : [self-hosted, X64, hathach, hardware-in-the-loop]
200+ steps :
201+ - name : Clean workspace
202+ if : github.run_attempt == '1'
203+ run : |
204+ echo "Cleaning up for the first run"
205+ rm -rf "${{ github.workspace }}"
206+ mkdir -p "${{ github.workspace }}"
207+
208+ - name : Checkout TinyUSB
209+ if : github.run_attempt == '1'
210+ uses : actions/checkout@v4
211+ with :
212+ sparse-checkout : test/hil
213+
214+ - name : Download Artifacts
215+ if : github.run_attempt == '1'
216+ uses : actions/download-artifact@v4
217+ with :
218+ path : cmake-build
219+ merge-multiple : true
220+
221+ - name : Test on actual hardware
222+ run : |
223+ ls cmake-build/
224+
225+ # Skip boards that passed with previous run, file is generated by hil_test.py
226+ SKIP_BOARDS=""
227+ if [ -f ${{ env.HIL_JSON }}.skip ]; then
228+ SKIP_BOARDS=$(cat "${HIL_JSON}.skip")
229+ fi
230+ echo "SKIP_BOARDS=$SKIP_BOARDS"
231+
232+ python3 test/hil/hil_test.py ${{ env.HIL_JSON }} $SKIP_BOARDS
233+
234+ # ---------------------------------------
235+ # Hardware in the loop (HIL)
236+ # self-hosted by HFP, build with IAR toolchain, for attached hardware checkout test/hil/hfp.json
237+ # Since IAR Token secret is not passed to forked PR, only build non-forked PR
238+ # ---------------------------------------
239+ hil-hfp :
240+ if : |
241+ github.repository_owner == 'hathach' &&
242+ github.event.pull_request.head.repo.fork == false &&
243+ (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
244+ runs-on : [self-hosted, Linux, X64, hifiphile]
245+ env :
246+ IAR_LMS_BEARER_TOKEN : ${{ secrets.IAR_LMS_BEARER_TOKEN }}
247+ steps :
248+ - name : Clean workspace
249+ run : |
250+ echo "Cleaning up previous run"
251+ rm -rf "${{ github.workspace }}"3
252+ mkdir -p "${{ github.workspace }}"
253+
254+ - name : Toolchain version
255+ run : |
256+ iccarm --version
257+
258+ - name : Checkout TinyUSB
259+ uses : actions/checkout@v4
260+
261+ - name : Get build boards
262+ run : |
263+ MATRIX_JSON=$(python test/hil/hil_ci_set_matrix.py test/hil/hfp.json)
264+ BUILD_ARGS=$(echo $MATRIX_JSON | jq -r '.["arm-gcc"] | join(" ")')
265+ echo "BUILD_ARGS=$BUILD_ARGS"
266+ echo "BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV
267+
268+ - name : Get Dependencies
269+ run : python3 tools/get_deps.py $BUILD_ARGS
270+
271+ - name : Build
272+ run : python3 tools/build.py -j 4 --toolchain iar $BUILD_ARGS
273+
274+ - name : Test on actual hardware (hardware in the loop)
275+ run : python3 test/hil/hil_test.py hfp.json
0 commit comments