2022-11-04 08:24:28 +08:00
|
|
|
def docker_run(String step_label, int timeout_mins, String cmd) {
|
|
|
|
timeout(time: timeout_mins, unit: 'MINUTES') {
|
|
|
|
sh script: "docker run --rm --privileged \
|
2023-04-03 00:33:35 +08:00
|
|
|
--env PYTHONWARNINGS=error \
|
2022-11-04 08:24:28 +08:00
|
|
|
--volume /dev/bus/usb:/dev/bus/usb \
|
|
|
|
--volume /var/run/dbus:/var/run/dbus \
|
2024-08-19 02:40:54 +08:00
|
|
|
--workdir /tmp/pythonpath/panda \
|
2022-11-04 08:24:28 +08:00
|
|
|
--net host \
|
|
|
|
${env.DOCKER_IMAGE_TAG} \
|
2022-12-09 08:14:22 +08:00
|
|
|
bash -c 'scons -j8 && ${cmd}'", \
|
2022-11-04 08:24:28 +08:00
|
|
|
label: step_label
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-02 09:52:32 +08:00
|
|
|
|
|
|
|
def phone(String ip, String step_label, String cmd) {
|
|
|
|
withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) {
|
|
|
|
def ssh_cmd = """
|
|
|
|
ssh -tt -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' /usr/bin/bash <<'END'
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
|
|
source ~/.bash_profile
|
|
|
|
if [ -f /etc/profile ]; then
|
|
|
|
source /etc/profile
|
|
|
|
fi
|
|
|
|
|
|
|
|
export CI=1
|
|
|
|
export TEST_DIR=${env.TEST_DIR}
|
|
|
|
export SOURCE_DIR=${env.SOURCE_DIR}
|
|
|
|
export GIT_BRANCH=${env.GIT_BRANCH}
|
|
|
|
export GIT_COMMIT=${env.GIT_COMMIT}
|
|
|
|
export PYTHONPATH=${env.TEST_DIR}/../
|
2023-04-03 00:33:35 +08:00
|
|
|
export PYTHONWARNINGS=error
|
2023-04-02 09:52:32 +08:00
|
|
|
|
|
|
|
cd ${env.TEST_DIR} || true
|
|
|
|
${cmd}
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
END"""
|
|
|
|
|
|
|
|
sh script: ssh_cmd, label: step_label
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def phone_steps(String device_type, steps) {
|
|
|
|
lock(resource: "", label: device_type, inversePrecedence: true, variable: 'device_ip', quantity: 1) {
|
|
|
|
timeout(time: 20, unit: 'MINUTES') {
|
|
|
|
phone(device_ip, "git checkout", readFile("tests/setup_device_ci.sh"),)
|
|
|
|
steps.each { item ->
|
|
|
|
phone(device_ip, item[0], item[1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-10 05:09:18 +08:00
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
environment {
|
2023-04-02 09:52:32 +08:00
|
|
|
CI = "1"
|
2023-04-03 00:33:35 +08:00
|
|
|
PYTHONWARNINGS= "error"
|
2019-05-11 06:47:04 +08:00
|
|
|
DOCKER_IMAGE_TAG = "panda:build-${env.GIT_COMMIT}"
|
2023-04-02 09:52:32 +08:00
|
|
|
|
|
|
|
TEST_DIR = "/data/panda"
|
|
|
|
SOURCE_DIR = "/data/panda_source/"
|
2019-04-10 05:09:18 +08:00
|
|
|
}
|
2022-12-08 14:23:41 +08:00
|
|
|
options {
|
|
|
|
timeout(time: 3, unit: 'HOURS')
|
|
|
|
disableConcurrentBuilds(abortPrevious: env.BRANCH_NAME != 'master')
|
|
|
|
}
|
|
|
|
|
2019-04-10 05:09:18 +08:00
|
|
|
stages {
|
2024-06-27 08:08:35 +08:00
|
|
|
stage ('Acquire resource locks') {
|
|
|
|
options {
|
|
|
|
lock(resource: "pandas")
|
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Build Docker Image') {
|
2022-08-25 08:17:02 +08:00
|
|
|
steps {
|
2024-06-27 08:08:35 +08:00
|
|
|
timeout(time: 20, unit: 'MINUTES') {
|
|
|
|
script {
|
|
|
|
sh 'git archive -v -o panda.tar.gz --format=tar.gz HEAD'
|
|
|
|
dockerImage = docker.build("${env.DOCKER_IMAGE_TAG}")
|
|
|
|
}
|
|
|
|
}
|
2019-04-10 05:09:18 +08:00
|
|
|
}
|
|
|
|
}
|
2024-06-27 08:08:35 +08:00
|
|
|
stage('jungle tests') {
|
2023-04-02 10:28:54 +08:00
|
|
|
steps {
|
2024-06-27 08:08:35 +08:00
|
|
|
script {
|
|
|
|
retry (3) {
|
2024-08-19 02:40:54 +08:00
|
|
|
docker_run("reset hardware", 3, "python3 ./tests/hitl/reset_jungles.py")
|
2024-06-27 08:08:35 +08:00
|
|
|
}
|
|
|
|
}
|
2023-04-02 10:28:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-27 08:08:35 +08:00
|
|
|
stage('parallel tests') {
|
|
|
|
parallel {
|
|
|
|
stage('test tres') {
|
|
|
|
agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
|
2023-04-02 09:52:32 +08:00
|
|
|
steps {
|
2024-06-27 08:08:35 +08:00
|
|
|
phone_steps("panda-tres", [
|
|
|
|
["build", "scons -j4"],
|
|
|
|
["flash", "cd tests/ && ./reflash_internal_panda.py"],
|
2024-09-25 07:37:23 +08:00
|
|
|
["flash jungle", "cd board/jungle && ./flash.py --all"],
|
2024-06-27 08:08:35 +08:00
|
|
|
["test", "cd tests/hitl && HW_TYPES=9 pytest -n0 --durations=0 2*.py [5-9]*.py"],
|
|
|
|
])
|
2023-04-02 09:52:32 +08:00
|
|
|
}
|
2021-12-12 06:36:00 +08:00
|
|
|
}
|
2024-06-27 08:08:35 +08:00
|
|
|
|
|
|
|
stage('test dos') {
|
|
|
|
agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
|
2023-04-02 09:52:32 +08:00
|
|
|
steps {
|
2024-06-27 08:08:35 +08:00
|
|
|
phone_steps("panda-dos", [
|
|
|
|
["build", "scons -j4"],
|
|
|
|
["flash", "cd tests/ && ./reflash_internal_panda.py"],
|
2024-09-25 07:37:23 +08:00
|
|
|
["flash jungle", "cd board/jungle && ./flash.py --all"],
|
2024-06-27 08:08:35 +08:00
|
|
|
["test", "cd tests/hitl && HW_TYPES=6 pytest -n0 --durations=0 [2-9]*.py -k 'not test_send_recv'"],
|
|
|
|
])
|
2023-04-02 09:52:32 +08:00
|
|
|
}
|
2022-08-25 08:17:02 +08:00
|
|
|
}
|
2024-06-27 08:08:35 +08:00
|
|
|
|
2023-10-10 12:52:15 +08:00
|
|
|
stage('bootkick tests') {
|
|
|
|
steps {
|
|
|
|
script {
|
2024-02-18 04:32:48 +08:00
|
|
|
docker_run("test", 10, "pytest -n0 ./tests/som/test_bootkick.py")
|
2023-10-10 12:52:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-04 10:47:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-10 05:09:18 +08:00
|
|
|
}
|
2019-07-04 11:02:53 +08:00
|
|
|
}
|