Skip to content

Commit 1a8d177

Browse files
committed
workflows: Fix test selection logic
Signed-off-by: Jorgen Kvalvaag <jorgen.kvalvaag@nordicsemi.no>
1 parent b1f7eb9 commit 1a8d177

File tree

7 files changed

+38
-22
lines changed

7 files changed

+38
-22
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ name: Build and Test
33
on:
44
workflow_dispatch:
55
inputs:
6-
pytest_marker:
7-
type: string
6+
build_all:
7+
description: Build all configurations
8+
type: boolean
89
required: false
9-
default: '-m "not slow"'
10+
default: false
1011

1112
schedule:
1213
- cron: "0 0 * * *"
@@ -19,6 +20,8 @@ jobs:
1920
build:
2021
uses: ./.github/workflows/build.yml
2122
secrets: inherit
23+
with:
24+
build_all: ${{ inputs.build_all || false }}
2225
test:
2326
permissions:
2427
actions: read
@@ -30,4 +33,4 @@ jobs:
3033
with:
3134
artifact_fw_version: ${{ needs.build.outputs.version }}
3235
artifact_run_id: ${{ needs.build.outputs.run_id }}
33-
pytest_marker: ${{ inputs.pytest_marker }}
36+
test_all: ${{ inputs.build_all || false }}

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ jobs:
169169

170170
# Asset Tracker Template debug firmware build
171171
- name: Build thingy91x debug firmware
172+
if: ${{ inputs.build_all }}
172173
uses: ./asset-tracker-template/.github/actions/build-step
173174
with:
174175
memfault_project_key: ${{ secrets.MEMFAULT_PROJECT_KEY }}
@@ -201,7 +202,7 @@ jobs:
201202
working-directory: asset-tracker-template
202203

203204
- name: Build patched thingy91x firmware
204-
if: ${{ github.event_name != 'pull_request' }}
205+
if: ${{ inputs.build_all }}
205206
uses: ./asset-tracker-template/.github/actions/build-step
206207
with:
207208
board: thingy91x/nrf9151/ns

.github/workflows/target-test.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ on:
99
artifact_fw_version:
1010
type: string
1111
required: true
12-
pytest_marker:
13-
type: string
12+
test_all:
13+
type: boolean
1414
required: false
15+
default: false
1516
pytest_path:
1617
type: string
1718
required: false
@@ -32,10 +33,11 @@ on:
3233
description: The run ID of the workflow to fetch artifacts from
3334
type: string
3435
required: true
35-
pytest_marker:
36-
description: The pytest marker to run
37-
type: string
36+
test_all:
37+
description: Run all tests
38+
type: boolean
3839
required: false
40+
default: false
3941
pytest_path:
4042
description: Select test execution path
4143
type: string
@@ -52,17 +54,28 @@ jobs:
5254
runs-on: ubuntu-latest
5355
outputs:
5456
device_matrix: ${{ steps.set-matrix.outputs.device_matrix }}
57+
pytest_marker: ${{ steps.set-matrix.outputs.pytest_marker }}
5558
steps:
5659
- id: set-matrix
5760
run: |
58-
if [[ ${{ github.event_name == 'schedule' }} == "true" ]]; then
59-
matrix='["thingy91x","nrf9151dk","ppk_thingy91x"]'
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"]'
6070
else
61-
matrix=${{ inputs.devices }}
71+
marker='-m "not slow"'
72+
matrix='["thingy91x"]'
6273
fi
6374
64-
echo "Matrix as string: $matrix"
75+
echo Matrix as string: $matrix
76+
echo Pytest marker as string: $marker
6577
echo "device_matrix=$matrix" >> $GITHUB_OUTPUT
78+
echo "pytest_marker=$marker" >> $GITHUB_OUTPUT
6679
6780
target_test:
6881
# This will create multiple jobs, one for each target defined in the matrix
@@ -119,7 +132,7 @@ jobs:
119132
nrfutil install trace
120133
121134
- name: Upload symbol file to Memfault
122-
if: ${{ matrix.device == 'thingy91x' }}
135+
if: ${{ matrix.device == 'thingy91x' && inputs.test_all }}
123136
working-directory: asset-tracker-template/tests/on_target/artifacts
124137
run: |
125138
memfault \
@@ -131,7 +144,7 @@ jobs:
131144
asset-tracker-template-${{ inputs.artifact_fw_version }}-debug-${{ vars.DUT_DEVICE_TYPE }}-nrf91.elf
132145
133146
- name: Generate and Push RAM and FLASH Badges
134-
if: ${{ matrix.device == 'thingy91x' && inputs.is_scheduled }}
147+
if: ${{ matrix.device == 'thingy91x' && github.event_name == 'schedule' }}
135148
continue-on-error: true
136149
working-directory: asset-tracker-template
137150
env:
@@ -144,12 +157,12 @@ jobs:
144157
mkdir -p results
145158
if [[ '${{ matrix.device }}' == 'ppk_thingy91x' ]]; then
146159
# For PPK device, only run tests/test_ppk
147-
pytest -v ${{ inputs.pytest_marker }} \
160+
pytest -v ${{ needs.set-matrix.outputs.pytest_marker }} \
148161
--junit-xml=results/test-results.xml \
149162
--html=results/test-results.html --self-contained-html \
150163
tests/test_ppk
151164
else
152-
pytest -v ${{ inputs.pytest_marker }} \
165+
pytest -v ${{ needs.set-matrix.outputs.pytest_marker }} \
153166
--junit-xml=results/test-results.xml \
154167
--html=results/test-results.html --self-contained-html \
155168
--ignore=tests/test_ppk \

tests/on_target/tests/pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[pytest]
22
markers =
33
slow: marks tests as slow (deselect with '-m "not slow"')
4-
mqtt: marks tests that require MQTT functionality

tests/on_target/tests/test_functional/test_memfault.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def timestamp(event):
8888
event["captured_date"], "%Y-%m-%dT%H:%M:%S.%f%z"
8989
)
9090

91+
@pytest.mark.slow
9192
def test_memfault(dut_board, debug_hex_file):
9293
# Save timestamp of latest coredump
9394
coredumps = get_latest_coredump_traces(IMEI)

tests/on_target/tests/test_functional/test_mqtt.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
logger = get_logger()
1515

16-
@pytest.mark.mqtt
1716
@pytest.mark.slow
1817
def test_mqtt_firmware(dut_board, hex_file_mqtt):
1918
"""Test the firmware with cloud MQTT module."""

tests/on_target/tests/test_functional/test_patched.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
##########################################################################################
55

66
import os
7-
from utils.flash_tools import flash_device, reset_device
8-
import sys
97
import pytest
108
from utils.flash_tools import flash_device, reset_device
9+
import sys
1110

1211
sys.path.append(os.getcwd())
1312
from utils.logger import get_logger
1413

1514
logger = get_logger()
1615

16+
@pytest.mark.slow
1717
def test_patched_firmware(dut_board, hex_file_patched):
1818
"""Test the patched firmware with magnetometer functionality."""
1919
# Only run this test for thingy91x devices

0 commit comments

Comments
 (0)