GitHub
The TGP Device Farm provides support for GitHub CI via a self-hosted GitHub runner. This allows for GitHub Actions workflows to utilise the board farm to perform automated device testing.
GitHub Actions can be used by writing a workflow yaml file - these must exist in a .github directory in the root of a repository. Please refer to the GitHub Actions documentation for information on how to make use of GitHub Actions.
Environment
Jobs that make use of the tgp-farm runner are started in a transient VM that is created for the job and destroyed upon its completion. The VM image used for the runner is the same as VMs created for users. Thus, the bfmc utility is available for use to gain access to devices.
Running Jobs from the Board Farm
In order to take advantage of the board farm, the following should be included in the job:
runs-on: [tgp-farm]
Please note that jobs in a workflow can make use of different ‘runs-on’ targets, for example it’s possible to build with an AWS GitHub runner, but then perform testing in the farm.
Example
The following GitHub workflow extract provides an example of how GitHub Actions can be used to flash an image to a development board:
jobs:
Flash_to_SDCard:
runs-on: tgp-farm
needs: Build_Yocto
container: default
steps:
- name: Get artifacts
uses: actions/download-artifact@v4
with:
name: wic_image
- name: Flash artifacts
run: |
# Request exclusive use of RPI4 hardware
bfmc use tgp-rpi4b
# Obtain env variables for RPI4 device nodes
eval `lsudt -b tgp-rpi4b -x`
# Turn RPI4 off
sudo usbrelay ${TGP_RPI4B_PSU} off
# Give access to the RPI4's SD card to the farm
sudo usbsdmux /dev/sg1 host
# Wait for disk to appear
eval `lsudt -b tgp-rpi4b -x -w TGP_RPI4_SDMUX_0`
# Write image to SD card
bzcat /github/home/core-image-base-raspberrypi4.wic.bz2 | sudo dd of=${TGP_RPI4B_SDMUX_0} bs=1M conv=nocreat conv=fsync
# Give access to the RPI4's SD card back to the board
sudo usbsdmux /dev/sg1 dut
# Release the board
bfmc release tgp-rpi4b
When the above CI job is trigged, the above commands will be run in a transient VM on the board farm. The commands download a previously built artifact (disk image), requests exclusive access to the device, writes the disk image to the SD card, and then releases the device.
Please see this blog post for more details.