Skip to content

Commit

Permalink
workflow: on_target: Reuse build workflow to build firmware
Browse files Browse the repository at this point in the history
Previously the on_target workflow was re-doing the steps done by the
build workflow. But since now the build workflow uploads the built
firmware as artifacts, we now have the possibility to re-use it. The
on_target workflow now calls the build worfklow and downloads its
artifaacts to perform the tests.

The test fraemwork code was modified to accept new input argument
firmware-hex that points to the hex file to test.

Signed-off-by: Balaji Srinivasan <[email protected]>
  • Loading branch information
Balaji Srinivasan committed Jun 10, 2024
1 parent f5e0d8f commit 199f4ad
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 54 deletions.
65 changes: 18 additions & 47 deletions .github/workflows/on_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,14 @@ name: On_target
on:
workflow_call:
workflow_dispatch:
inputs:
run_test:
description: 'Run test stage'
required: false
default: 'yes'
type: select
options:
- yes
- no
schedule:
- cron: "0 0 * * *"

jobs:
build:
name: Build
runs-on: ubuntu-22.04
container: ghcr.io/zephyrproject-rtos/ci:v0.26.13
env:
CMAKE_PREFIX_PATH: /opt/toolchains
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: thingy91x-oob

- name: Initialize
working-directory: thingy91x-oob
run: |
west init -l .
west config manifest.group-filter +bsec
west config build.sysbuild True
west update -o=--depth=1 -n
- name: Install dependencies
run: |
pip install -r nrf/scripts/requirements-build.txt
- name: Build firmware
working-directory: thingy91x-oob
run: |
west build -b thingy91x/nrf9151/ns app -p
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: oob-t91x-hex
if-no-files-found: error
path: thingy91x-oob/build/merged.hex
uses: ./.github/workflows/build.yml

test:
if: github.event.inputs.run_test == 'yes' || github.event.inputs.run_test == '' || github.event.inputs.run_test == null
name: Test
needs: build
runs-on: self-hosted
Expand All @@ -72,15 +29,29 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: oob-t91x-hex
name: firmware
path: thingy91x-oob/tests/on_target/artifacts

- name: Set version
shell: bash
run: |
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Verify artifact path
working-directory: thingy91x-oob
run: |
ls -l tests/on_target/artifacts
- name: Install dependencies
working-directory: thingy91x-oob/tests/on_target
run: |
pip install -r requirements.txt --break-system-packages
- name: Run tests
working-directory: thingy91x-oob
working-directory: thingy91x-oob/tests/on_target
run: |
./tests/on_target/run-tests.sh
pytest -v --firmware-hex tests/on_target/artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-debug-app.hex
7 changes: 0 additions & 7 deletions tests/on_target/run-tests.sh

This file was deleted.

11 changes: 11 additions & 0 deletions tests/on_target/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def get_uarts():
def t91x_board():
all_uarts = get_uarts()
logger.info(f"All uarts discovered: {all_uarts}")
if not all_uarts:
pytest.fail("No UARTs found")
log_uart_string = all_uarts[0]
logger.info(f"Log UART: {log_uart_string}")

Expand All @@ -51,3 +53,12 @@ def t91x_board():
)

uart.stop()

# Add support for input arguments
def pytest_addoption(parser):
parser.addoption(
"--firmware-hex",
action="store",
default="artifacts/merged.hex",
help="Path to the firmware hex file",
)
File renamed without changes.

0 comments on commit 199f4ad

Please sign in to comment.