@@ -2,6 +2,10 @@ name: Build Sidewalk samples
22on :
33 workflow_call :
44 inputs :
5+ jobs_per_subset :
6+ type : number
7+ required : false
8+ default : 3
59 save_images :
610 type : boolean
711 required : false
1620 options : --cpus 2 --privileged
1721 outputs :
1822 total_platforms_json : ${{ steps.platforms.outputs.total_platforms_json }}
23+ subset_matrix : ${{ steps.subsets.outputs.matrix }}
24+ subset_config : ${{ steps.subsets.outputs.config }}
1925 defaults :
2026 run :
2127 shell : nrfutil toolchain-manager launch --install-dir /root/ncs bash -- {0}
@@ -45,17 +51,46 @@ jobs:
4551 total_platforms_json=$(printf '%s' "${total_platforms[@]}" | jq -R . | jq -s -c .)
4652 echo "total_platforms_json=$total_platforms_json" >> $GITHUB_OUTPUT;
4753
54+ - name : subsets configuration
55+ id : subsets
56+ run : |
57+ rm -rf twister-out*
58+ west twister --test-config sidewalk/test_config.yaml --testsuite-root sidewalk --level="samples" --dry-run
59+ total_platforms=$(jq -r '.testsuites |map({platform: .platform}) | unique | .[].platform' twister-out/testplan.json)
60+ echo "[]" > configuration
61+ for platform in $total_platforms; do
62+ west twister --test-config sidewalk/test_config.yaml --testsuite-root sidewalk --level="samples" --dry-run --platform $platform
63+ total_jobs=$(jq '.testsuites | length' twister-out/testplan.json)
64+ subsets=$(( ( total_jobs + ${{inputs.jobs_per_subset}}) / ${{inputs.jobs_per_subset}}))
65+ echo $subsets >> max
66+ cat configuration | jq -c --arg platform_name $platform --arg subsets $subsets '. += [{"platform": $platform_name, "subsets": $subsets}]' > configuration_new
67+ mv configuration_new configuration
68+ done
69+ sort max > max_sorted
70+ max_subset=$(tail -n 1 max_sorted)
71+ subset_matrix="[$(seq -s ', ' 1 $max_subset)]"
72+ cat configuration
73+ echo $subset_matrix
74+
75+ echo "matrix=$subset_matrix" >> $GITHUB_OUTPUT;
76+ echo "config=`cat configuration`" >> $GITHUB_OUTPUT;
77+
4878 - name : clean
4979 if : always()
5080 run : |
51- rm -rf twister*
81+ rm -rf twister* sidewalk*
5282
5383 build_samples :
5484 needs : [discover_targets]
5585 strategy :
5686 fail-fast : false
5787 matrix :
88+ subset : ${{ fromJson(needs.discover_targets.outputs.subset_matrix) }}
5889 target : ${{ fromJson(needs.discover_targets.outputs.total_platforms_json) }}
90+
5991 uses : ./.github/workflows/samples_build_target.yml
6092 with :
6193 target : ${{matrix.target}}
94+ subset : ${{matrix.subset}}
95+ subset_config : ' ${{needs.discover_targets.outputs.subset_config}}'
96+ # subset_config: '[{"platform":"nrf52840dk/nrf52840","subsets":"4"},{"platform":"nrf5340dk/nrf5340/cpuapp","subsets":"4"},{"platform":"nrf54l15dk/nrf54l10/cpuapp","subsets":"4"},{"platform":"nrf54l15dk/nrf54l15/cpuapp","subsets":"4"},{"platform":"nrf54l15dk/nrf54l15/cpuapp/ns","subsets":"4"},{"platform":"thingy53/nrf5340/cpuapp","subsets":"1"}]'
0 commit comments