Skip to content

Commit cc7abd7

Browse files
committed
.github: consolidate hardware test into a single workflow
Inline the per-test-type reusable workflows (`cloud-connect-test.yml`, `fota-test.yml`) into `test.yml`, using `pytest_dir` from the test catalog entry to select the right test directory at runtime. Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
1 parent 2df0171 commit cc7abd7

5 files changed

Lines changed: 89 additions & 178 deletions

File tree

.github/test/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ tests:
22
- id: 91m1-cloud-connect-nrf54l15
33
enabled: true
44
type: cloud_connect
5+
pytest_dir: tests/on_target/tests/test_cloud/
56
app: 91m1
67
board: nrf54l15dk/nrf54l15/cpuapp/ns
78
hardware:
@@ -21,6 +22,7 @@ tests:
2122
- id: 91m1-application-fota-nrf54l15
2223
enabled: false
2324
type: fota
25+
pytest_dir: tests/on_target/tests/test_fota/
2426
app: 91m1
2527
board: nrf54l15dk/nrf54l15/cpuapp/ns
2628
hardware:

.github/workflows/cloud-connect-test.yml

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

.github/workflows/fota-test.yml

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

.github/workflows/test.yml

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# On-target hardware test: nRF Cloud provisioning and connection verification.
1+
# On-target hardware tests on self-hosted runners.
2+
#
3+
# Triggers:
4+
# - push to main: runs every enabled test in .github/test/tests.yml
5+
# - workflow_dispatch: pick branch (GitHub branch dropdown) and test (all or one id)
6+
#
7+
# When adding tests, update workflow_dispatch options below and .github/test/tests.yml.
28
#
39
# Prerequisites:
410
# - nRF54L15 DK + nRF9151 Serial Modem wired and configured per applications/91m1/doc
@@ -12,13 +18,6 @@
1218
#
1319
# GitHub secrets:
1420
# NRF_CLOUD_API_KEY, NRF_CLOUD_CA_CERT, NRF_CLOUD_CA_KEY
15-
#
16-
# Verification flow:
17-
# 1. Clear application firmware and TF-M credential storage.
18-
# 2. Start pyserial capture, build and flash firmware.
19-
# 3. Read device ID from boot log; confirm missing-credentials warning.
20-
# 4. Delete only CI_NRF54L15_DEVICE_ID from nRF Cloud if present; provision and onboard.
21-
# 5. Wait for "Cloud connected" in the serial log.
2221

2322
name: Test
2423

@@ -70,12 +69,75 @@ jobs:
7069
hardware_test:
7170
needs: plan
7271
if: ${{ needs.plan.outputs.matrix != '[]' && needs.plan.outputs.matrix != '' }}
72+
name: ${{ matrix.id }}
73+
runs-on: self-hosted
74+
container:
75+
image: ghcr.io/zephyrproject-rtos/ci:v0.29.2
76+
options: --privileged -v /dev:/dev
7377
strategy:
7478
fail-fast: false
7579
max-parallel: 1
7680
matrix:
7781
include: ${{ fromJson(needs.plan.outputs.matrix) }}
78-
uses: ./.github/workflows/${{ matrix.type }}-test.yml
79-
with:
80-
test_id: ${{ matrix.id }}
81-
secrets: inherit
82+
env:
83+
CMAKE_PREFIX_PATH: /opt/toolchains
84+
NRF_CLOUD_API_KEY: ${{ secrets.NRF_CLOUD_API_KEY }}
85+
NRF_CLOUD_CA_CERT: ${{ secrets.NRF_CLOUD_CA_CERT }}
86+
NRF_CLOUD_CA_KEY: ${{ secrets.NRF_CLOUD_CA_KEY }}
87+
CI_NRF54L15_SEGGER_SN: ${{ vars.CI_NRF54L15_SEGGER_SN }}
88+
CI_NRF54L15_SERIAL_PORT: ${{ vars.CI_NRF54L15_SERIAL_PORT }}
89+
CI_NRF54L15_DEVICE_ID: ${{ vars.CI_NRF54L15_DEVICE_ID }}
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v6
93+
with:
94+
path: serial-modem-host-applications
95+
96+
- name: Load test configuration
97+
id: config
98+
working-directory: serial-modem-host-applications
99+
run: |
100+
set -eu
101+
pip install --quiet -r tests/on_target/requirements.txt
102+
TEST_JSON="$(PYTHONPATH=tests/on_target python3 -m ci.catalog load "${{ matrix.id }}")"
103+
{
104+
echo "test_json<<EOF"
105+
echo "$TEST_JSON"
106+
echo "EOF"
107+
} >> "$GITHUB_OUTPUT"
108+
109+
- name: Initialize West workspace
110+
uses: ./serial-modem-host-applications/.github/actions/west-init
111+
112+
- name: Install test dependencies
113+
run: |
114+
nrfutil install device
115+
116+
- name: Run hardware test
117+
working-directory: serial-modem-host-applications
118+
env:
119+
REPO_ROOT: ${{ github.workspace }}/serial-modem-host-applications
120+
TEST_JSON: ${{ steps.config.outputs.test_json }}
121+
run: |
122+
PYTHONPATH=tests/on_target python3 -m pytest \
123+
${{ matrix.pytest_dir }} \
124+
-c tests/on_target/tests/pytest.ini \
125+
--html=build/hardware-pytest-report.html \
126+
--self-contained-html \
127+
-v
128+
129+
- name: Upload serial log
130+
if: failure()
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: hardware-serial-log-${{ matrix.id }}-${{ github.run_id }}
134+
path: serial-modem-host-applications/build/hardware-serial.log
135+
if-no-files-found: ignore
136+
137+
- name: Upload pytest report
138+
if: failure()
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: hardware-pytest-report-${{ matrix.id }}-${{ github.run_id }}
142+
path: serial-modem-host-applications/build/hardware-pytest-report.html
143+
if-no-files-found: ignore

tests/on_target/ci/catalog.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ def cmd_load(root: Path, test_id: str) -> None:
4242
raise SystemExit(f"test id not found: {test_id}")
4343

4444

45+
def cmd_list(root: Path) -> None:
46+
for test in load_catalog(root):
47+
print(test["id"])
48+
49+
4550
def main(argv: list[str] | None = None) -> None:
4651
parser = argparse.ArgumentParser(description=__doc__, allow_abbrev=False)
4752
parser.add_argument(
@@ -70,13 +75,21 @@ def main(argv: list[str] | None = None) -> None:
7075
)
7176
load_parser.add_argument("test_id", help="Test id from tests.yml")
7277

78+
subparsers.add_parser(
79+
"list",
80+
help="Print enabled test ids, one per line",
81+
allow_abbrev=False,
82+
)
83+
7384
args = parser.parse_args(argv)
7485
root = args.root.resolve()
7586

7687
if args.command == "matrix":
7788
cmd_matrix(root, args.filter)
7889
elif args.command == "load":
7990
cmd_load(root, args.test_id)
91+
elif args.command == "list":
92+
cmd_list(root)
8093

8194

8295
if __name__ == "__main__":

0 commit comments

Comments
 (0)