-
Notifications
You must be signed in to change notification settings - Fork 2
181 lines (162 loc) · 5.98 KB
/
target-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Target tests
on:
workflow_call:
inputs:
artifact_run_id:
type: string
required: true
artifact_fw_version:
type: string
required: true
pytest_marker:
type: string
required: false
pytest_path:
type: string
required: false
default: tests
workflow_dispatch:
inputs:
artifact_fw_version:
description: The firmware version found under this run_id
type: string
required: true
artifact_run_id:
description: The run ID of the workflow to fetch artifacts from
type: string
required: true
pytest_marker:
description: The pytest marker to run
type: string
required: false
pytest_path:
description: Select test execution path
type: string
required: false
default: tests
jobs:
target_test:
# This will create multiple jobs, one for each target defined in the matrix
strategy:
fail-fast: false # Don't fail all jobs if one fails
matrix:
include:
- device: nrf9151dk
- device: thingy91x
# Self-hosted runner is labeled according to the device it is linked with
runs-on: cia-trd-${{ matrix.device }}
environment: ${{ matrix.device }}
name: Target Test - ${{ matrix.device }}
permissions:
actions: read
contents: write
packages: read
container:
image: ghcr.io/nrfconnect/asset-tracker-template:test-docker-v1.0.1
options: --privileged
volumes:
- /dev:/dev:rw
- /run/udev:/run/udev
steps:
- name: Display Runner Serial Number
# The serial number is set by a pre-job script in .env file on the local actions-runner directory
run: |
echo "Inside Container - Runner Serial Number: $RUNNER_SERIAL_NUMBER"
echo "Inside Container - Runner Serial Number: ${{ env.RUNNER_SERIAL_NUMBER }}"
- name: Checkout
uses: actions/checkout@v4
with:
path: asset-tracker-template
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: firmware-*
merge-multiple: true
path: asset-tracker-template/tests/on_target/artifacts
run-id: ${{ inputs.artifact_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify artifact path
working-directory: asset-tracker-template
run: |
ls -l tests/on_target/artifacts
- name: Install dependencies
working-directory: asset-tracker-template/tests/on_target
run: |
pip install -r requirements.txt --break-system-packages
- name: Upload symbol file to Memfault
if: ${{ matrix.device != 'ppk_thingy91x' }}
working-directory: asset-tracker-template/tests/on_target/artifacts
run: |
memfault \
--org-token ${{ secrets.MEMFAULT_ORGANIZATION_TOKEN }} \
--org ${{ vars.MEMFAULT_ORGANIZATION_SLUG }} \
--project ${{ vars.MEMFAULT_PROJECT_SLUG }} \
upload-mcu-symbols \
--check-uploaded \
asset-tracker-template-${{ inputs.artifact_fw_version }}-${{ vars.DUT_DEVICE_TYPE }}-nrf91.elf
- name: Target Tests
working-directory: asset-tracker-template/tests/on_target
run: |
mkdir -p results
if [[ '${{ inputs.pytest_marker }}' == 'no_markers_flag' || '${{ inputs.pytest_marker }}' == '' ]]; then
pytest_marker_arg=()
else
pytest_marker_arg=(-m "${{ inputs.pytest_marker }}")
fi
echo pytest -v "${pytest_marker_arg[@]}"
if [[ '${{ matrix.device }}' == 'ppk_thingy91x' ]]; then
# For PPK device, only run tests/test_ppk
pytest -v "${pytest_marker_arg[@]}" \
--junit-xml=results/test-results.xml \
--html=results/test-results.html --self-contained-html \
tests/test_ppk
else
pytest -v "${pytest_marker_arg[@]}" \
--junit-xml=results/test-results.xml \
--html=results/test-results.html --self-contained-html \
--ignore=tests/test_ppk \
${{ inputs.pytest_path }}
fi
shell: bash
env:
SEGGER: ${{ env.RUNNER_SERIAL_NUMBER }}
DUT_DEVICE_TYPE: ${{ vars.DUT_DEVICE_TYPE }}
UUID: ${{ env.UUID }}
NRFCLOUD_API_KEY: ${{ secrets.NRF_CLOUD_API_KEY }}
LOG_FILENAME: att_test_log
TEST_REPORT_NAME: ATT Firwmare Test Report
MEMFAULT_ORGANIZATION_TOKEN: ${{ secrets.MEMFAULT_ORGANIZATION_TOKEN }}
MEMFAULT_ORGANIZATION_SLUG: ${{ vars.MEMFAULT_ORGANIZATION_SLUG }}
MEMFAULT_PROJECT_SLUG: ${{ vars.MEMFAULT_PROJECT_SLUG }}
APP_BUNDLEID: ${{ env.APP_BUNDLEID }}
- name: Commit and Push Badge File to gh-pages Branch
if: ${{ matrix.device }} == ppk_thingy91x
continue-on-error: true
working-directory: asset-tracker-template
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./tests/on_target/scripts/commit_badge.sh
- name: Results
if: always()
uses: pmeier/pytest-results-action@v0.7.1
with:
path: asset-tracker-template/tests/on_target/results/*.xml
summary: true
fail-on-empty: true
title: ATT FW Test Results - ${{ matrix.device }}
- name: Create Report Artifact
if: always()
uses: actions/upload-artifact@v4
id: artifact-report
with:
name: test-report-${{ matrix.device }}
path: |
asset-tracker-template/tests/on_target/results/*.html
- name: Push log files to artifacts
if: always()
uses: actions/upload-artifact@v4
id: artifact-upload-test-logs
with:
name: test-logs-${{ matrix.device }}
path: |
asset-tracker-template/tests/on_target/outcomes/logs/*.txt