diff --git a/.github/workflows/on_target.yml b/.github/workflows/on_target.yml index ce9b58ca..82a6ca42 100644 --- a/.github/workflows/on_target.yml +++ b/.github/workflows/on_target.yml @@ -3,58 +3,16 @@ 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 + name: build needs: build runs-on: self-hosted container: @@ -72,15 +30,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 + - 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 diff --git a/tests/on_target/run-tests.sh b/tests/on_target/run-tests.sh deleted file mode 100755 index 9829755c..00000000 --- a/tests/on_target/run-tests.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -TOP_DIR="tests/on_target" - -pip install -r $TOP_DIR/requirements.txt --break-system-packages - -pytest -v -s $TOP_DIR/tests/test.py diff --git a/tests/on_target/tests/conftest.py b/tests/on_target/tests/conftest.py index 64b4d06a..1b6e9452 100644 --- a/tests/on_target/tests/conftest.py +++ b/tests/on_target/tests/conftest.py @@ -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}") @@ -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", + ) diff --git a/tests/on_target/tests/test.py b/tests/on_target/tests/test_uart_output.py similarity index 100% rename from tests/on_target/tests/test.py rename to tests/on_target/tests/test_uart_output.py