Jenkins CI (#1102)

* jenkins: initial commit

* jenkins: add missing usb hub check script

* jenkins: squish docker apt package install commands into a single command

* jenkins: fix type in Dockerfile

* jenkins: override interactive installations in Dockerfile (build-essentials fails due to tzdata)

* jenkins: set executable flag on ci scripts

* jenkins: remove sudo prefix from install scripts

* jenkins: add python3 venv to Dockerfile and build scripts

* jenkins: add missing python venv command to host install script

* jenkins: remove python install and venv redundancies

* jenkins: remove make install step, run hackrf tools directly from their build directory

* jenkins: re-add python3 and pip installations to docker because usbhub depends on them

* jenkins: add missing git install to docker

* jenkins: add python-is-python3 to docker's installed dependencies

* jenkins: use path string to specify the correct device for dfu-util

* jenkins: specify usbhub id for dual hub setup

* jenkins: turn unused usb hub ports off for testing

* jenkins: remove custom job throttle property

* use --disable-i2c usbhub option, install usbhub from latest, replace --privileged with cgroups option, remove redundancies from Dockerfile

* update device usb path for dfu-util

* remove apt/lists/* and fix typos

* ci: remove redundant environment setup in Jenkins
This commit is contained in:
Jacob Graves
2022-06-08 11:26:28 -06:00
committed by GitHub
parent dfadf6a31c
commit fa0662e54c
8 changed files with 141 additions and 0 deletions

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
# Sandbox test environment for HackRF
FROM ubuntu:20.04
CMD ["/bin/bash"]
# Override interactive installations and install prerequisites
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
dfu-util \
gcc-arm-none-eabi \
git \
libfftw3-dev \
libusb-1.0-0-dev \
pkg-config \
python3 \
python3-pip \
python-is-python3 \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install git+https://github.com/CapableRobot/CapableRobot_USBHub_Driver --upgrade
# Inform Docker that the container is listening on port 8080 at runtime
EXPOSE 8080

41
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,41 @@
pipeline {
agent {
dockerfile {
args '--group-add=46 --device-cgroup-rule="c 189:* rmw" -v /dev/bus/usb:/dev/bus/usb'
}
}
stages {
stage('Build (Host)') {
steps {
sh './ci-scripts/install-host.sh'
}
}
stage('Build (Firmware)') {
steps {
sh './ci-scripts/install-firmware.sh'
}
}
stage('Test') {
steps {
sh './ci-scripts/configure-hubs.sh --off'
retry(3) {
sh './ci-scripts/test-host.sh'
}
retry(3) {
sh './ci-scripts/test-firmware-program.sh'
}
sh './ci-scripts/test-firmware-flash.sh'
}
}
}
post {
always {
sh './ci-scripts/configure-hubs.sh --reset'
sh 'rm -rf testing-venv/'
cleanWs(cleanWhenNotBuilt: false,
deleteDirs: true,
disableDeferredWipeout: true,
notFailBuild: true)
}
}
}

3
ci-scripts/configure-hubs.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
usbhub --disable-i2c --hub D9D1 power state --port 1,2,3,4 $1
usbhub --disable-i2c --hub 624C power state --port 1,2,3,4 $1

8
ci-scripts/install-firmware.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
git submodule init
git submodule update
mkdir firmware/hackrf_usb/build
cd firmware/hackrf_usb/build
cmake ..
make
cd ../../..

6
ci-scripts/install-host.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
mkdir host/build
cd host/build
cmake ..
make
cd ../..

View File

@ -0,0 +1,18 @@
#!/bin/bash
host/build/hackrf-tools/src/hackrf_spiflash -w firmware/hackrf_usb/build/hackrf_usb.bin
EXIT_CODE="$?"
if [ "$EXIT_CODE" == "1" ]
then
echo "No GreatFET found! Disconnected? Exiting.."
exit $EXIT_CODE
elif [ "$EXIT_CODE" == "0" ]
then
echo "Firmware successfully flashed!"
elif [ "$EXIT_CODE" == "127" ]
then
echo "Host tool installation failed! Exiting.."
exit $EXIT_CODE
else
echo "god have mercy on your soul"
exit $EXIT_CODE
fi

View File

@ -0,0 +1,21 @@
#!/bin/bash
usbhub --disable-i2c --hub D9D1 power state --port 2 --reset
sleep 1s
dfu-util --path 1-2.2 --alt 0 --download firmware/hackrf_usb/build/hackrf_usb.dfu
EXIT_CODE="$?"
if [ "$EXIT_CODE" == "0" ]
then
echo "DFU installation success! Exiting.."
exit $EXIT_CODE
elif [ "$EXIT_CODE" == "74" ]
then
echo "No DFU capable USB device available! Disconnected? Exiting.."
exit 1
elif [ "$EXIT_CODE" == "127" ]
then
echo "dfu-util installation failed! Exiting.."
exit $EXIT_CODE
else
echo "god have mercy on your soul"
exit $EXIT_CODE
fi

21
ci-scripts/test-host.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
usbhub --disable-i2c --hub D9D1 power state --port 2 --reset
sleep 1s
host/build/hackrf-tools/src/hackrf_info
EXIT_CODE="$?"
if [ "$EXIT_CODE" == "1" ]
then
echo "Host tool installation success! Exiting.."
exit 0
elif [ "$EXIT_CODE" == "0" ]
then
echo "Failed to boot HackRF into DFU mode! Check DFU pin jumper. Exiting.."
exit 1
elif [ "$EXIT_CODE" == "127" ]
then
echo "Host tool installation failed! Exiting.."
exit $EXIT_CODE
else
echo "god have mercy on your soul"
exit $EXIT_CODE
fi