@@ -2,17 +2,71 @@ name: Build Sidewalk samples
22on :
33 workflow_call :
44 inputs :
5- nrf_revision :
6- type : string
5+ jobs_per_subset :
6+ type : number
77 required : false
8- default : " main"
9- boards_to_test :
10- type : string
11- required : true
12- default : ' ["nrf52840dk/nrf52840", "nrf5340dk/nrf5340/cpuapp", "nrf54l15dk/nrf54l15/cpuapp", "nrf54l15dk/nrf54l15/cpuapp/ns", "nrf54l15dk/nrf54l10/cpuapp"]'
8+ default : 6
139
1410jobs :
11+ discover_targets :
12+ runs-on : self-hosted
13+ container :
14+ image : ghcr.io/nrfconnect/sdk-sidewalk:main
15+ options : --cpus 2 --privileged
16+ outputs :
17+ total_platforms_json : ${{ steps.subsets.outputs.total_platforms_json }}
18+ subset_matrix : ${{ steps.subsets.outputs.matrix }}
19+ subset_config : ${{ steps.subsets.outputs.config }}
20+ defaults :
21+ run :
22+ shell : nrfutil toolchain-manager launch --install-dir /root/ncs bash -- {0}
23+
24+ steps :
25+ - name : Checkout
26+ uses : actions/checkout@v4
27+ with :
28+ fetch-depth : 0
29+ path : sidewalk
30+
31+ - name : update NRF
32+ run : |
33+ rm -rf .west;
34+ west init -l sidewalk --mf west.yml &&
35+ west update -n -o=--depth=1 --path-cache /workdir/
36+
37+ - name : subsets configuration
38+ id : subsets
39+ run : |
40+ rm -rf twister-out* max max_sorted configuration
41+ west twister --test-config sidewalk/test_config.yaml --testsuite-root sidewalk --level="Github_tests" --exclude-platform native_sim --exclude-platform native_posix --exclude-platform unit_testing --dry-run
42+ total_platforms=$(jq -r '.testsuites |map({platform: .platform}) | unique | .[].platform' twister-out/testplan.json)
43+ total_platforms_json=$(printf '%s' "${total_platforms[@]}" | jq -R . | jq -s -c .)
44+ echo "{}" > configuration
45+ for platform in $total_platforms; do
46+ west twister --test-config sidewalk/test_config.yaml --testsuite-root sidewalk --level="Github_tests" --dry-run --platform $platform
47+ total_jobs=$(jq '.testsuites | length' twister-out/testplan.json)
48+ subsets=$(( ( total_jobs + ${{inputs.jobs_per_subset}}) / ${{inputs.jobs_per_subset}}))
49+ echo $subsets >> max
50+ cat configuration | jq -c --arg platform_name $platform --arg subsets $subsets '. += {($platform_name): $subsets|tonumber }' > configuration_new
51+ mv configuration_new configuration
52+ done
53+ sort max > max_sorted
54+ max_subset=$(tail -n 1 max_sorted)
55+ subset_matrix="[$(seq -s ', ' 1 $max_subset)]"
56+ cat configuration
57+ echo $subset_matrix
58+
59+ echo "total_platforms_json=$total_platforms_json" >> $GITHUB_OUTPUT;
60+ echo "matrix=$subset_matrix" >> $GITHUB_OUTPUT;
61+ echo "config=`cat configuration`" >> $GITHUB_OUTPUT;
62+
63+ - name : clean
64+ if : always()
65+ run : |
66+ rm -rf twister*
67+
1568 build_and_run_x86_tests :
69+ name : Run UT on x86
1670 runs-on : ubuntu-24.04
1771 container :
1872 image : ghcr.io/nrfconnect/sdk-sidewalk:main
3084
3185 - name : update NRF
3286 run : |
33- cd sidewalk && git rev-parse HEAD > /workdir/sidewalk_hash && cd .. &&
34- cp -r /workdir/nrf nrf;
35- west init -l nrf &&
36- cd nrf &&
37- git fetch origin ${{inputs.nrf_revision}}:PR-branch &&
38- git checkout PR-branch &&
39- cd .. &&
40- west config manifest.group-filter +sidewalk &&
41- west update -n -o=--depth=1 --path-cache /workdir/ &&
42- cd sidewalk && git checkout `cat /workdir/sidewalk_hash` && rm -rf /workdir/sidewalk_hash
87+ rm -rf .west;
88+ west init -l sidewalk --mf west.yml &&
89+ west update -n -o=--depth=1 --path-cache /workdir/
4390
4491 - name : Install Python dependencies
4592 run : |
@@ -84,18 +131,18 @@ jobs:
84131
85132
86133 build-and-test_on_hw :
134+ needs : [discover_targets]
87135 strategy :
88136 fail-fast : false
89137 matrix :
90- subset : [1, 2]
91- board : ${{ fromJson(inputs.boards_to_test ) }}
138+ subset : ${{ fromJson(needs.discover_targets.outputs.subset_matrix) }}
139+ target : ${{ fromJson(needs.discover_targets.outputs.total_platforms_json ) }}
92140 uses : ./.github/workflows/run_tests_dut.yml
93141 with :
94- subset : ${{ matrix.subset }}
95- max_subsets : 2
96142 run_tests : true
97- target_board : ${{ matrix.board }}
98- nrf_revision : ${{ inputs.nrf_revision }}
143+ target : ${{matrix.target}}
144+ subset : ${{matrix.subset}}
145+ subset_config : ' ${{needs.discover_targets.outputs.subset_config}}'
99146
100147 merge_tests_on_hw :
101148 needs : build-and-test_on_hw
0 commit comments