Skip to content

Commit

Permalink
github: Split build and test workflows
Browse files Browse the repository at this point in the history
Allow running only target test workflow.

Signed-off-by: Jorgen Kvalvaag <[email protected]>
  • Loading branch information
jorgenmk committed Aug 28, 2024
1 parent 1669a36 commit f48cbb4
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 39 deletions.
60 changes: 52 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
name: Build

on:
workflow_dispatch:
inputs:
build_bl_update:
description: Build bootloader update
type: boolean
required: false
default: false
workflow_call:
inputs:
build_bl_update:
type: boolean
required: false
default: false
outputs:
run_id:
description: The run ID of the workflow to fetch artifacts from
value: ${{ jobs.build.outputs.run_id }}
version:
description: The version of the firmware built on this run_id
value: ${{ jobs.build.outputs.version }}

push:
branches:
- main
Expand All @@ -20,6 +35,9 @@ jobs:
container: ghcr.io/zephyrproject-rtos/ci:v0.26.13
env:
CMAKE_PREFIX_PATH: /opt/toolchains
outputs:
run_id: ${{ github.run_id }}
version: ${{ env.VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -64,7 +82,12 @@ jobs:
- name: Create nrf91 Bootloader HEX file
run: |
python3 zephyr/scripts/build/mergehex.py -o $(pwd)/thingy91x-oob/app/build/b0_s0_s1_merged.hex $(pwd)/thingy91x-oob/app/build/b0_container.hex $(pwd)/thingy91x-oob/app/build/app_provision.hex $(pwd)/thingy91x-oob/app/build/signed_by_b0_mcuboot.hex $(pwd)/thingy91x-oob/app/build/signed_by_b0_s1_image.hex
python3 zephyr/scripts/build/mergehex.py -o \
$(pwd)/thingy91x-oob/app/build/b0_s0_s1_merged.hex \
$(pwd)/thingy91x-oob/app/build/b0_container.hex \
$(pwd)/thingy91x-oob/app/build/app_provision.hex \
$(pwd)/thingy91x-oob/app/build/signed_by_b0_mcuboot.hex \
$(pwd)/thingy91x-oob/app/build/signed_by_b0_s1_image.hex
- name: Build nrf53 firmware
working-directory: nrf/applications/connectivity_bridge
Expand All @@ -73,15 +96,26 @@ jobs:
- name: Create nrf53 merged_domains HEX file
run: |
python3 zephyr/scripts/build/mergehex.py -o $(pwd)/thingy91x-oob/app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-connectivity-bridge.hex $(pwd)/nrf/applications/connectivity_bridge/build/merged_CPUNET.hex $(pwd)/nrf/applications/connectivity_bridge/build/merged.hex
python3 zephyr/scripts/build/mergehex.py -o \
$(pwd)/thingy91x-oob/app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-connectivity-bridge.hex \
$(pwd)/nrf/applications/connectivity_bridge/build/merged_CPUNET.hex \
$(pwd)/nrf/applications/connectivity_bridge/build/merged.hex
- name: Create nrf53 Bootloader HEX file
run: |
python3 zephyr/scripts/build/mergehex.py -o $(pwd)/thingy91x-oob/app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-bootloader.hex $(pwd)/nrf/applications/connectivity_bridge/build/b0_container.hex $(pwd)/nrf/applications/connectivity_bridge/build/signed_by_b0_mcuboot.hex $(pwd)/nrf/applications/connectivity_bridge/build/signed_by_b0_s1_image.hex $(pwd)/nrf/applications/connectivity_bridge/build/app_provision.hex $(pwd)/nrf/applications/connectivity_bridge/build/b0n_container.hex $(pwd)/nrf/applications/connectivity_bridge/build/net_provision.hex
python3 zephyr/scripts/build/mergehex.py -o \
$(pwd)/thingy91x-oob/app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-bootloader.hex \
$(pwd)/nrf/applications/connectivity_bridge/build/b0_container.hex \
$(pwd)/nrf/applications/connectivity_bridge/build/signed_by_b0_mcuboot.hex \
$(pwd)/nrf/applications/connectivity_bridge/build/signed_by_b0_s1_image.hex \
$(pwd)/nrf/applications/connectivity_bridge/build/app_provision.hex \
$(pwd)/nrf/applications/connectivity_bridge/build/b0n_container.hex \
$(pwd)/nrf/applications/connectivity_bridge/build/net_provision.hex
- name: Copy nrf53 DFU file
run: |
cp $(pwd)/nrf/applications/connectivity_bridge/build/dfu_application.zip $(pwd)/thingy91x-oob/app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-dfu.zip
cp $(pwd)/nrf/applications/connectivity_bridge/build/dfu_application.zip \
$(pwd)/thingy91x-oob/app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-dfu.zip
- name: Apply Connectivity Bridge Patch
run: git apply thingy91x-oob/scripts/connectivity_bridge.patch --directory=nrf
Expand All @@ -91,11 +125,15 @@ jobs:
working-directory: thingy91x-oob
run: |
west twister -T . --test app/app.build.bootloader_update -v -p thingy91x/nrf9151/ns --inline-logs
cp twister-out/thingy91x_nrf9151_ns/app/app.build.bootloader_update/dfu_mcuboot.zip app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf91-bootloader.zip
cp twister-out/thingy91x_nrf9151_ns/app/app.build.bootloader_update/dfu_mcuboot.zip \
app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf91-bootloader.zip
rm -rf twister-out
west twister -T ../nrf/applications/connectivity_bridge --test applications.connectivity_bridge.bootloader_update -v -p thingy91x/nrf5340/cpuapp --inline-logs
cp twister-out/thingy91x_nrf5340_cpuapp/applications.connectivity_bridge.bootloader_update/dfu_mcuboot.zip app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-bootloader.zip
cp twister-out/thingy91x_nrf5340_cpuapp/applications.connectivity_bridge.bootloader_update/dfu_application.zip app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-connectivity-bridge-verbose.zip
west twister -T ../nrf/applications/connectivity_bridge \
--test applications.connectivity_bridge.bootloader_update -v -p thingy91x/nrf5340/cpuapp --inline-logs
cp twister-out/thingy91x_nrf5340_cpuapp/applications.connectivity_bridge.bootloader_update/dfu_mcuboot.zip \
app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-bootloader.zip
cp twister-out/thingy91x_nrf5340_cpuapp/applications.connectivity_bridge.bootloader_update/dfu_application.zip \
app/build/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-connectivity-bridge-verbose.zip
- name: Rename artifacts
working-directory: thingy91x-oob/app/build
Expand All @@ -110,8 +148,14 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: firmware
if-no-files-found: error
path: |
thingy91x-oob/app/build/hello.nrfcloud.com-*.*
- name: Print run-id and fw version
run: |
echo Run id: ${{ github.run_id }}
echo Version: ${{ env.VERSION }}
86 changes: 55 additions & 31 deletions .github/workflows/on_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,51 @@ name: Target tests

on:
workflow_call:
inputs:
artifact_fw_version:
type: string
required: true
artifact_run_id:
type: string
required: true
run_fota_tests:
type: boolean
required: false
default: true
run_dfu_tests:
type: boolean
required: false
default: true
run_connectivity_bridge_tests:
type: boolean
required: false
default: true
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
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
run_fota_tests:
type: boolean
required: true
default: false
run_dfu_tests:
type: boolean
required: true
default: false
run_connectivity_bridge_tests:
type: boolean
required: true
default: false

jobs:
build:
uses: ./.github/workflows/build.yml
secrets: inherit
with:
build_bl_update: true

test:
name: Test
needs: build
target_test:
name: Target Test
runs-on: self-hosted
environment: production
container:
Expand All @@ -39,15 +67,8 @@ jobs:
with:
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
run-id: ${{ inputs.artifact_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Verify artifact path
working-directory: thingy91x-oob
Expand All @@ -62,35 +83,38 @@ jobs:
- name: Run UART tests
working-directory: thingy91x-oob/tests/on_target
run: |
pytest -s -v -m "dut1 and uart" tests --firmware-hex artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-debug-app.hex
pytest -s -v -m "dut1 and uart" tests --firmware-hex artifacts/hello.nrfcloud.com-${{ inputs.artifact_fw_version }}-thingy91x-debug-app.hex
env:
SEGGER: ${{ secrets.SEGGER_DUT_1 }}

- name: Run FOTA tests
if: ${{ inputs.run_fota_tests }}
working-directory: thingy91x-oob/tests/on_target
run: |
pytest -s -v -m "dut1 and fota" tests --firmware-hex artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-debug-app.hex
pytest -s -v -m "dut1 and fota" tests --firmware-hex artifacts/hello.nrfcloud.com-${{ inputs.artifact_fw_version }}-thingy91x-debug-app.hex
env:
SEGGER: ${{ secrets.SEGGER_DUT_1 }}
IMEI: ${{ secrets.IMEI_DUT_1 }}
FINGERPRINT: ${{ secrets.FINGERPRINT_DUT_1 }}

- name: Run DFU tests
if: ${{ inputs.run_dfu_tests }}
working-directory: thingy91x-oob/tests/on_target
run: |
pytest -s -v -m dut2 tests
env:
SEGGER_NRF53: ${{ secrets.SEGGER_DUT_2_EXT_DBG }}
SEGGER_NRF91: ${{ secrets.SEGGER_DUT_2_NRF91 }}
UART_ID: ${{ secrets.UART_DUT_2 }}
NRF53_HEX_FILE: artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-connectivity-bridge.hex
NRF53_APP_UPDATE_ZIP: artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-connectivity-bridge-verbose.zip
NRF53_BL_UPDATE_ZIP: artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf53-bootloader.zip
NRF91_HEX_FILE: artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-bootloader.hex
NRF91_APP_UPDATE_ZIP: artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf91-dfu.zip
NRF91_BL_UPDATE_ZIP: artifacts/hello.nrfcloud.com-${{ env.VERSION }}-thingy91x-nrf91-bootloader.zip
NRF53_HEX_FILE: artifacts/hello.nrfcloud.com-${{ inputs.artifact_fw_version }}-thingy91x-nrf53-connectivity-bridge.hex
NRF53_APP_UPDATE_ZIP: artifacts/hello.nrfcloud.com-${{ inputs.artifact_fw_version }}-thingy91x-nrf53-connectivity-bridge-verbose.zip
NRF53_BL_UPDATE_ZIP: artifacts/hello.nrfcloud.com-${{ inputs.artifact_fw_version }}-thingy91x-nrf53-bootloader.zip
NRF91_HEX_FILE: artifacts/hello.nrfcloud.com-${{ inputs.artifact_fw_version }}-thingy91x-bootloader.hex
NRF91_APP_UPDATE_ZIP: artifacts/hello.nrfcloud.com-${{ inputs.artifact_fw_version }}-thingy91x-nrf91-dfu.zip
NRF91_BL_UPDATE_ZIP: artifacts/hello.nrfcloud.com-${{ inputs.artifact_fw_version }}-thingy91x-nrf91-bootloader.zip

- name: Check nRF53 connectivity bridge version
if: ${{ inputs.run_connectivity_bridge_tests }}
working-directory: thingy91x-oob
run: |
python3 ./tests/on_target/utils/thingy91x_dfu.py --check-nrf53-version --serial THINGY91X_${{ secrets.UART_DUT_2 }} 2>&1 >/dev/null | grep "S1: 1"
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and Test on Target

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
jobs:
build:
uses: ./.github/workflows/build.yml
secrets: inherit
with:
build_bl_update: true
test:
uses: ./.github/workflows/on_target.yml
needs: build
secrets: inherit
with:
artifact_fw_version: ${{ needs.build.outputs.version }}
artifact_run_id: ${{ needs.build.outputs.run_id }}

0 comments on commit f48cbb4

Please sign in to comment.