Skip to content

Commit 614d581

Browse files
committed
workflow: Fix the build_all parameter
Signed-off-by: Jorgen Kvalvaag <jorgen.kvalvaag@nordicsemi.no>
1 parent e7ca6e2 commit 614d581

File tree

3 files changed

+53
-35
lines changed

3 files changed

+53
-35
lines changed

.github/workflows/build-and-target-test.yml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
build_all:
77
description: Build all configurations
88
type: boolean
9-
required: false
9+
required: true
1010
default: false
11+
boards:
12+
description: Boards to test, json list
13+
type: string
14+
required: true
15+
default: '["thingy91x"]'
1116

1217
schedule:
1318
- cron: "0 0 * * *"
@@ -17,20 +22,48 @@ on:
1722
paths-ignore:
1823
- "docs/**"
1924
jobs:
25+
setup:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
boards: ${{ steps.setup.outputs.boards }}
29+
build_all: ${{ steps.setup.outputs.build_all == 'true' }}
30+
steps:
31+
- name: Setup
32+
id: setup
33+
run: |
34+
SCHEDULED=${{ github.event_name == 'schedule' }}
35+
PUSH=${{ github.event_name == 'push' }}
36+
BUILD_ALL=${{ inputs.build_all }}
37+
if [[ $SCHEDULED == true ]]; then
38+
boards='["thingy91x","nrf9151dk","ppk_thingy91x"]'
39+
build_all=true
40+
elif [[ $PUSH == true ]]; then
41+
boards='["thingy91x"]'
42+
build_all=false
43+
else
44+
boards=${{ inputs.boards }}
45+
build_all=${{ inputs.build_all }}
46+
fi
47+
echo "boards=$boards"
48+
echo "build_all=$build_all"
49+
echo "boards=$boards" >> GITHUB_OUTPUT
50+
echo "build_all=$build_all" >> $GITHUB_OUTPUT
2051
build:
52+
needs: setup
2153
uses: ./.github/workflows/build.yml
2254
secrets: inherit
2355
with:
24-
build_all: ${{ inputs.build_all || false }}
56+
build_all: ${{ needs.setup.outputs.build_all == 'true' }}
2557
test:
2658
permissions:
2759
actions: read
2860
contents: write
2961
packages: read
3062
uses: ./.github/workflows/target-test.yml
31-
needs: build
63+
needs: [build, setup]
3264
secrets: inherit
3365
with:
3466
artifact_fw_version: ${{ needs.build.outputs.version }}
3567
artifact_run_id: ${{ needs.build.outputs.run_id }}
36-
test_all: ${{ inputs.build_all || false }}
68+
devices: ${{ needs.setup.outputs.boards }}
69+
test_all: ${{ needs.setup.outputs.build_all == 'true' }}

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626
build_all:
2727
type: boolean
2828
required: false
29-
default: ${{ github.event_name == 'schedule' }}
29+
default: false
3030
outputs:
3131
run_id:
3232
description: The run ID of the workflow to fetch artifacts from

.github/workflows/target-test.yml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
devices:
2121
description: JSON array of devices. e.g. [\"thingy91x\",\"nrf9151dk\"]
2222
type: string
23-
required: false
23+
required: true
2424
default: '[\"thingy91x\"]'
2525

2626
workflow_dispatch:
@@ -46,44 +46,24 @@ on:
4646
devices:
4747
description: JSON array of devices. e.g. [\"thingy91x\",\"nrf9151dk\"]
4848
type: string
49-
required: false
49+
required: true
5050
default: '[\"thingy91x\"]'
5151

5252
jobs:
53-
set-matrix:
53+
debug:
5454
runs-on: ubuntu-latest
55-
outputs:
56-
device_matrix: ${{ steps.set-matrix.outputs.device_matrix }}
57-
pytest_marker: ${{ steps.set-matrix.outputs.pytest_marker }}
5855
steps:
59-
- id: set-matrix
56+
- name: Test
6057
run: |
61-
if [[ ${{ github.event_name == 'schedule' }} == true ]]; then
62-
marker=''
63-
matrix='["thingy91x","nrf9151dk","ppk_thingy91x"]'
64-
elif [[ ${{ inputs.test_all }} == true ]]; then
65-
marker=''
66-
matrix='["thingy91x","nrf9151dk","ppk_thingy91x"]'
67-
elif [[ ${{ github.event_name == 'push' }} == true ]]; then
68-
marker='-m "not slow"'
69-
matrix='["thingy91x"]'
70-
else
71-
marker='-m "not slow"'
72-
matrix='["thingy91x"]'
73-
fi
74-
75-
echo Matrix as string: $matrix
76-
echo Pytest marker as string: $marker
77-
echo "device_matrix=$matrix" >> $GITHUB_OUTPUT
78-
echo "pytest_marker=$marker" >> $GITHUB_OUTPUT
79-
58+
echo ${{ inputs.devices }}
59+
echo ${{ inputs.boards }}
60+
echo ${{ fromJson(inputs.devices) }}
8061
target_test:
8162
# This will create multiple jobs, one for each target defined in the matrix
82-
needs: set-matrix
8363
strategy:
8464
fail-fast: false # Don't fail all jobs if one fails
8565
matrix:
86-
device: ${{ fromJson(needs.set-matrix.outputs.device_matrix) }}
66+
device: ${{ fromJson(inputs.devices) }}
8767

8868
# Self-hosted runner is labeled according to the device it is linked with
8969
runs-on: cia-trd-${{ matrix.device }}
@@ -155,14 +135,19 @@ jobs:
155135
working-directory: asset-tracker-template/tests/on_target
156136
run: |
157137
mkdir -p results
138+
if [[ ${{ inputs.test_all }} == true ]]; then
139+
pytest_marker='-m "not slow"'
140+
else
141+
pytest_marker=''
142+
fi
158143
if [[ '${{ matrix.device }}' == 'ppk_thingy91x' ]]; then
159144
# For PPK device, only run tests/test_ppk
160-
pytest -v ${{ needs.set-matrix.outputs.pytest_marker }} \
145+
pytest -v $pytest_marker \
161146
--junit-xml=results/test-results.xml \
162147
--html=results/test-results.html --self-contained-html \
163148
tests/test_ppk
164149
else
165-
pytest -v ${{ needs.set-matrix.outputs.pytest_marker }} \
150+
pytest -v $pytest_marker \
166151
--junit-xml=results/test-results.xml \
167152
--html=results/test-results.html --self-contained-html \
168153
--ignore=tests/test_ppk \

0 commit comments

Comments
 (0)