Skip to content

Target tests

Target tests #270

Workflow file for this run

name: Target tests
on:
workflow_call:
inputs:
artifact_run_id:
type: string
required: true
artifact_fw_version:
type: string
required: true
test_all:
type: boolean
required: false
default: false
pytest_path:
type: string
required: false
default: tests
devices:
description: JSON array of devices. e.g. [\"thingy91x\",\"nrf9151dk\"]
type: string
required: true
default: '[\"thingy91x\"]'
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
test_all:
description: Run all tests
type: boolean
required: false
default: false
pytest_path:
description: Select test execution path
type: string
required: false
default: tests
devices:
description: JSON array of devices. e.g. [\"thingy91x\",\"nrf9151dk\"]
type: string
required: true
default: '[\"thingy91x\"]'
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:
device: ${{ fromJson(inputs.devices) }}
# Self-hosted runner is labeled according to the device it is linked with
runs-on: cia-trd-simen-crap-${{ 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:
name: firmware-artifacts-att
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
nrfutil install trace
- name: Upload symbol file to Memfault
if: ${{ matrix.device == 'thingy91x' && inputs.test_all }}
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 }}-debug-${{ vars.DUT_DEVICE_TYPE }}-nrf91.elf
- name: Target Tests
working-directory: asset-tracker-template/tests/on_target
run: |
mkdir -p results
if [[ ${{ inputs.test_all }} == true ]]; then
pytest_marker=()
else
pytest_marker=(-m "not slow")
fi
if [[ '${{ matrix.device }}' == 'ppk_thingy91x' ]]; then
# For PPK device, only run tests/test_ppk
pytest -v "${pytest_marker[@]}" \
--junit-xml=results/test-results.xml \
--html=results/test-results.html --self-contained-html \
tests/test_ppk
else
pytest -v "${pytest_marker[@]}" \
--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: Generate and Push Power Badge
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/update_power_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