Skip to content

Commit

Permalink
separate hil test to its own workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed May 8, 2024
1 parent 8806639 commit fc2bc34
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/actions/prepare_build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ runs:
- name: Get Dependencies
run: |
sudo apt install -y ninja-build
pip install click
python3 tools/get_deps.py ${{ inputs.family }}
echo >> $GITHUB_ENV "PICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk"
shell: bash
32 changes: 0 additions & 32 deletions .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,38 +126,6 @@ jobs:
# Current self-hosted instance is running on an RPI4. For attached hardware checkout hil_pi4.json
# ---------------------------------------
hil-test:
if: github.repository_owner == 'hathach'
runs-on: [ self-hosted, rp2040, nrf52840, hardware-in-the-loop ]
# strategy:
# fail-fast: false
# matrix:
# board:
# - 'feather_nrf52840_express'
# - 'itsybitsy_m4'
# - 'raspberry_pi_pico'
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Checkout TinyUSB
uses: actions/checkout@v4

- name: Get dependencies
run: |
python tools/get_deps.py nrf rp2040 samd5x_e5x
- name: Build
run: |
python tools/build_cmake.py -b feather_nrf52840_express -b itsybitsy_m4 -b raspberry_pi_pico
- name: Test on actual hardware
run: |
python3 test/hil/hil_test.py -b feather_nrf52840_express -b itsybitsy_m4 -b raspberry_pi_pico hil_pi4.json
hil-test-bck:
if: github.repository_owner == 'hathach' && false
needs: arm-gcc
runs-on: [self-hosted, rp2040, nrf52840, hardware-in-the-loop]
Expand Down
140 changes: 140 additions & 0 deletions .github/workflows/hil_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Build CMake

on:
workflow_dispatch:
push:
paths:
- 'src/**'
- 'examples/**'
- 'lib/**'
- 'hw/**'
- 'test/hil/**'
- 'tools/get_deps.py'
- '.github/actions/**'
- '.github/workflows/hil_test.yml'
- '.github/workflows/ci_set_matrix.py'
pull_request:
branches: [ master ]
paths:
- 'src/**'
- 'examples/**'
- 'lib/**'
- 'hw/**'
- 'test/hil/**'
- 'tools/get_deps.py'
- '.github/actions/**'
- '.github/workflows/hil_test.yml'
- '.github/workflows/ci_set_matrix.py'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout TinyUSB
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install ARM GCC
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '12.3.Rel1'

- name: Parse HIL json
run: |
pip install click
sudo apt install -y jq
BOARD_LIST=$(jq -r '.boards[] | "-b " + .name' test/hil/hil_pi4.json | tr '\n' ' ')
echo >> $GITHUB_ENV "BOARD_LIST=$BOARD_LIST"
- name: Checkout pico-sdk for rp2040
#if: contains($BOARD_LIST, 'rp2040')
uses: actions/checkout@v4
with:
repository: raspberrypi/pico-sdk
ref: develop
path: pico-sdk

- name: Get Dependencies
run: |
sudo apt install -y ninja-build
python3 tools/get_deps.py $BOARD_LIST
- name: Build
run: |
python tools/build_cmake.py $BOARD_LIST
# - name: Upload Artifacts for Hardware Testing (rp2040)
# if: contains(matrix.family, 'rp2040') && github.repository_owner == 'hathach'
# uses: actions/upload-artifact@v4
# with:
# name: raspberry_pi_pico
# path: |
# cmake-build/cmake-build-raspberry_pi_pico/*/*/*.elf
#
# - name: Upload Artifacts for Hardware Testing (nRF)
# if: contains(matrix.family, 'nrf') && github.repository_owner == 'hathach'
# uses: actions/upload-artifact@v4
# with:
# name: feather_nrf52840_express
# path: |
# cmake-build/cmake-build-feather_nrf52840_express/*/*/*.elf
#
# - name: Upload Artifacts for Hardware Testing (samd51)
# if: contains(matrix.family, 'samd5x_e5x') && github.repository_owner == 'hathach'
# uses: actions/upload-artifact@v4
# with:
# name: itsybitsy_m4
# path: |
# cmake-build/cmake-build-itsybitsy_m4/*/*/*.bin

# ---------------------------------------
# Hardware in the loop (HIL)
# Current self-hosted instance is running on an RPI4. For attached hardware checkout hil_pi4.json
# ---------------------------------------
hil-test:
if: github.repository_owner == 'hathach' && false
needs: build
runs-on: [self-hosted, rp2040, nrf52840, hardware-in-the-loop]
strategy:
fail-fast: false
matrix:
board:
- 'feather_nrf52840_express'
- 'itsybitsy_m4'
- 'raspberry_pi_pico'
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
# USB bus on rpi4 is not stable, reset it before testing
- name: Reset USB bus
run: |
lsusb
lsusb -t
# reset VIA Labs 2.0 hub
sudo usbreset 001/002
- name: Checkout test/hil
uses: actions/checkout@v4
with:
sparse-checkout: test/hil

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.board }}
path: cmake-build/cmake-build-${{ matrix.board }}

- name: Test on actual hardware
run: |
python3 test/hil/hil_test.py --board ${{ matrix.board }} hil_pi4.json
2 changes: 1 addition & 1 deletion tools/build_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def build_family(family, toolchain):
@click.option('-b', '--board', multiple=True, default=None, help='Boards to build')
@click.option('-t', '--toolchain', default='gcc', help='Toolchain to use, default is gcc')
def main(family, board, toolchain):
if family is None and board is None:
if len(family) == 0 and len(board) == 0:
print("Please specify family or board to build")
return

Expand Down
54 changes: 37 additions & 17 deletions tools/get_deps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import click
import sys
import subprocess
from pathlib import Path
Expand Down Expand Up @@ -227,27 +228,46 @@ def get_a_dep(d):
return 0


# Arguments can be
# - family name
# - specific deps path
# - all
if __name__ == "__main__":
def find_family(board):
bsp_dir = Path(TOP / "hw/bsp")
for family_dir in bsp_dir.iterdir():
if family_dir.is_dir():
board_dir = family_dir / 'boards' / board
if board_dir.exists():
return family_dir.name
return None


@click.command()
@click.argument('family', nargs=-1, required=False)
@click.option('-b', '--board', multiple=True, default=None, help='Boards to fetch')
def main(family, board):
if len(family) == 0 and len(board) == 0:
print("Please specify family or board to fetch")
return

status = 0
deps = list(deps_mandatory.keys())
# get all if 'all' is argument
if len(sys.argv) == 2 and sys.argv[1] == 'all':

if 'all' in family:
deps += deps_optional.keys()
else:
for arg in sys.argv[1:]:
if arg in deps_all.keys():
# if arg is a dep, add it
deps.append(arg)
else:
# arg is a family name, add all deps of that family
for d in deps_optional:
if arg in deps_optional[d][2]:
deps.append(d)
family = list(family)
if board is not None:
for b in board:
f = find_family(b)
if f is not None:
family.append(f)

for f in family:
for d in deps_optional:
if f in deps_optional[d][2]:
deps.append(d)

with Pool() as pool:
status = sum(pool.map(get_a_dep, deps))
sys.exit(status)
return status


if __name__ == "__main__":
sys.exit(main())

0 comments on commit fc2bc34

Please sign in to comment.