Skip to content

Commit 1aef641

Browse files
committed
hil.yml: Generate the chunk matrix based on how many sketches there are
in a given folder. Signed-off-by: Abdelatif Guettouche <[email protected]>
1 parent bc77222 commit 1aef641

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

Diff for: .github/workflows/hil.yml

+28-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,38 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18-
Build:
18+
gen_chunks:
1919
if: contains(github.event.pull_request.labels.*.name, 'hil_test')
20+
name: Generate Chunks matrix
21+
runs-on: ubuntu-latest
22+
outputs:
23+
chunks: ${{ steps.gen-chunks.outputs.chunks }}
24+
steps:
25+
- name: Checkout Repository
26+
uses: actions/checkout@v2
27+
28+
- name: Generate Chunks matrix
29+
id: gen-chunks
30+
run: |
31+
set +e
32+
bash .github/scripts/sketch_utils.sh count tests
33+
sketches=$((? - 1))
34+
if [[ $sketches -gt ${{env.MAX_CHUNKS}} ]]; then
35+
$sketches=${{env.MAX_CHUNKS}}
36+
fi
37+
set -e
38+
rm sketches.txt
39+
CHUNKS=$(jq -c -n '$ARGS.positional' --args `seq 0 1 $sketches`)
40+
echo "::set-output name=chunks::${CHUNKS}"
41+
42+
Build:
43+
needs: gen_chunks
2044
name: ${{matrix.chip}}-Build#${{matrix.chunks}}
2145
runs-on: ubuntu-latest
2246
strategy:
2347
matrix:
2448
chip: ['esp32', 'esp32s2', 'esp32c3']
25-
chunks: [0, 1, 2, 3]
49+
chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}}
2650

2751
steps:
2852
- name: Checkout Repository
@@ -39,14 +63,14 @@ jobs:
3963
tests/*/build/*.bin
4064
tests/*/build/*.json
4165
Test:
42-
needs: Build
66+
needs: [gen_chunks, Build]
4367
name: ${{matrix.chip}}-Test#${{matrix.chunks}}
4468
runs-on: ESP32
4569
strategy:
4670
fail-fast: false
4771
matrix:
4872
chip: ['esp32', 'esp32s2', 'esp32c3']
49-
chunks: [0, 1, 2, 3]
73+
chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}}
5074
container:
5175
image: python:3.10.1-bullseye
5276
options: --privileged

0 commit comments

Comments
 (0)