Skip to content

Commit 0618fb4

Browse files
RobertGalatNordictotyz
authored andcommitted
west: add west.yml
add west.yml to sidewalk project update github actions improve build and test in GHA, by dynamically selecting number of runners nrfconnect/sdk-nrf#20901 update template for PRs Signed-off-by: Robert Gałat <[email protected]>
1 parent a3fdeeb commit 0618fb4

13 files changed

+315
-330
lines changed

.github/pull_request_template.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
## CI parameters
22

33
```yaml
4-
Github_actions:
5-
#(branch, hash, pull/XXX/head)
6-
NRF_revision: main
7-
8-
# Do not change after creating PR
9-
Create_NRF_PR: false
104
Jenkins:
115
test-sdk-sidewalk: master
126
# To reconfigure functional tests:

.github/workflows/on-commit.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,13 @@ jobs:
3333
with:
3434
reference_commit: "HEAD~${{needs.get_base_commit.outputs.commit_number}}"
3535

36-
discover_target_boards:
37-
runs-on: ubuntu-24.04
38-
outputs:
39-
targets: ${{ steps.platforms.outputs.targets }}
40-
steps:
41-
- name: install yq
42-
run: pip install yq
43-
44-
- name: Checkout
45-
uses: actions/checkout@v4
46-
with:
47-
path: sidewalk
48-
49-
- name: get_platforms
50-
id: platforms
51-
run: |
52-
result=$(yq '.common.platform_allow' sidewalk/samples/sid_end_device/sample.yaml -c)
53-
echo "targets=$result" >> $GITHUB_OUTPUT;
54-
echo "$result"
55-
5636
build_samples:
57-
needs: [discover_target_boards]
37+
name: Build samples
5838
uses: ./.github/workflows/samples_build.yml
59-
with:
60-
boards_to_test: ${{needs.discover_target_boards.outputs.targets}}
6139

6240
build_and_run_tests:
63-
needs: [discover_target_boards]
41+
name: Build and run unit tests
6442
uses: ./.github/workflows/run_tests.yml
65-
with:
66-
boards_to_test: ${{needs.discover_target_boards.outputs.targets}}
6743

6844
Post_fail_to_Teams:
6945
needs: [verify_changes, build_samples, build_and_run_tests]

.github/workflows/on-pr.yml

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,6 @@ on:
33
pull_request:
44

55
jobs:
6-
Run_Configuration:
7-
runs-on: ubuntu-24.04
8-
outputs:
9-
NRF_revision: ${{ steps.config.outputs.NRF_revision }}
10-
steps:
11-
- name: Read body of PR
12-
env:
13-
GH_TOKEN: ${{ github.token }}
14-
run: |
15-
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{github.repository}}/pulls/${{github.event.number}} --jq '.body' > pr_body.md
16-
17-
- uses: actions/setup-python@v5
18-
with:
19-
python-version: '3.9'
20-
21-
- name: install yq
22-
run: pip install yq
23-
24-
- name: Get configuration
25-
id: config
26-
shell: bash {0}
27-
run: |
28-
csplit pr_body.md /\`\`\`yaml/1
29-
csplit xx01 /\`\`\`/
30-
mv xx00 configuration.yaml
31-
cat configuration.yaml
32-
revision=$(yq '.Github_actions.NRF_revision' configuration.yaml)
33-
if [ $? != 0 ]; then
34-
echo "Failed to read configuration use default main for NRF_revision"
35-
echo "NRF_revision=main" >> $GITHUB_OUTPUT;
36-
else
37-
echo "NRF_revision=$revision" >> $GITHUB_OUTPUT;
38-
fi;
39-
40-
- name: print nrf revision
41-
run: |
42-
echo ${{ steps.config.outputs.NRF_revision }}
436

447
verify_PR:
458
uses: ./.github/workflows/validate_code_style.yml
@@ -61,36 +24,10 @@ jobs:
6124
PR_number
6225
include-hidden-files: true
6326

64-
discover_target_boards:
65-
runs-on: ubuntu-24.04
66-
outputs:
67-
targets: ${{ steps.platforms.outputs.targets }}
68-
steps:
69-
- name: install yq
70-
run: pip install yq
71-
72-
- name: Checkout
73-
uses: actions/checkout@v4
74-
with:
75-
path: sidewalk
76-
77-
- name: get_platforms
78-
id: platforms
79-
run: |
80-
result=$(yq '.common.platform_allow' sidewalk/samples/sid_end_device/sample.yaml -c)
81-
echo "targets=$result" >> $GITHUB_OUTPUT;
82-
echo "$result"
83-
8427
build_samples:
85-
needs: [Run_Configuration, discover_target_boards]
28+
name: Build samples
8629
uses: ./.github/workflows/samples_build.yml
87-
with:
88-
nrf_revision: ${{needs.Run_Configuration.outputs.NRF_revision}}
89-
boards_to_test: ${{needs.discover_target_boards.outputs.targets}}
9030

9131
build_and_run_tests:
92-
needs: [Run_Configuration, discover_target_boards]
32+
name: Build and run unit tests
9333
uses: ./.github/workflows/run_tests.yml
94-
with:
95-
nrf_revision: ${{needs.Run_Configuration.outputs.NRF_revision}}
96-
boards_to_test: ${{needs.discover_target_boards.outputs.targets}}

.github/workflows/on-pr_nrf_manifest_update_PR.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/on_docker_change.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ jobs:
5353
- name: Get revision of nrf to use
5454
id: revision
5555
run: |
56-
REF_NAME="${{ github.ref_name }}"
57-
if [ -z "$REF_NAME" ]; then
58-
REF_NAME="main" # Set your default value here
59-
fi
56+
REF_NAME=$(yq '.manifest.projects | map(select(.name == "nrf"))[0].revision' west.yml)
6057
echo "REF_NAME=$REF_NAME" >> $GITHUB_OUTPUT
6158
echo "Ref name: $REF_NAME"
6259

.github/workflows/run_tests.yml

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,71 @@ name: Build Sidewalk samples
22
on:
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

1410
jobs:
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
@@ -30,16 +84,9 @@ jobs:
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

.github/workflows/run_tests_cli.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
run_dut_ut:
16-
name: "Run DUT tests (${{inputs.target_board}} - ${{ inputs.subset }})"
16+
name: "Run DUT tests (${{inputs.target_board}})"
1717
runs-on: [self-hosted, linux, x64, "${{inputs.target_board}}"]
1818
container:
1919
image: ghcr.io/nrfconnect/sdk-sidewalk:main
@@ -27,24 +27,25 @@ jobs:
2727
shell: nrfutil toolchain-manager launch --install-dir /root/ncs bash -- {0}
2828

2929
steps:
30+
- name: clean artifacts
31+
if: always()
32+
run: |
33+
rm -rf pytest-sidewalk
34+
rm -rf twister-out*
35+
rm -rf sidewalk
36+
rm -rf .west
37+
3038
- name: Checkout
3139
uses: actions/checkout@v4
3240
with:
41+
fetch-depth: 0
3342
path: sidewalk
3443

3544
- name: update NRF
3645
run: |
37-
rm -rf .west nrf;
38-
cd sidewalk && git rev-parse HEAD > /workdir/sidewalk_hash && cd ..
39-
west init -m https://github.com/nrfconnect/sdk-nrf --mr main . &&
40-
cd nrf &&
41-
git fetch origin ${{inputs.nrf_revision}}:branch_to_run &&
42-
git checkout branch_to_run &&
43-
git rev-parse HEAD &&
44-
cd .. &&
45-
west config manifest.group-filter +sidewalk &&
46-
west update -n -o=--depth=1 --path-cache /workdir/ &&
47-
cd sidewalk && git checkout `cat /workdir/sidewalk_hash` && rm -rf /workdir/sidewalk_hash
46+
rm -rf .west;
47+
west init -l sidewalk --mf west.yml &&
48+
west update -n -o=--depth=1 --path-cache /workdir/
4849
4950
- name: Replace slash with underscore
5051
id: replace
@@ -102,5 +103,7 @@ jobs:
102103
if: always()
103104
run: |
104105
rm -rf pytest-sidewalk
105-
cd nrf; git checkout main; git branch -D branch_to_run;
106-
rm -rf PACKAGE_ARTIFACTS_* twister-out
106+
rm -rf twister-out*
107+
rm -rf sidewalk_tmp
108+
rm -rf sidewalk
109+
rm -rf .west

0 commit comments

Comments
 (0)