2023-09-10 12:30:21 +08:00
|
|
|
def device(String ip, String step_label, String cmd) {
|
2021-03-24 08:46:53 +08:00
|
|
|
withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) {
|
2021-01-24 10:34:18 +08:00
|
|
|
def ssh_cmd = """
|
2021-12-05 13:07:57 +08:00
|
|
|
ssh -tt -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' /usr/bin/bash <<'END'
|
2021-01-24 10:34:18 +08:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
export CI=1
|
2023-08-13 08:15:16 +08:00
|
|
|
export PYTHONWARNINGS=error
|
2023-07-26 08:06:43 +08:00
|
|
|
export LOGPRINT=debug
|
2021-01-24 10:34:18 +08:00
|
|
|
export TEST_DIR=${env.TEST_DIR}
|
2021-07-05 11:26:38 +08:00
|
|
|
export SOURCE_DIR=${env.SOURCE_DIR}
|
2021-01-24 10:34:18 +08:00
|
|
|
export GIT_BRANCH=${env.GIT_BRANCH}
|
|
|
|
export GIT_COMMIT=${env.GIT_COMMIT}
|
2022-06-21 07:24:51 +08:00
|
|
|
export AZURE_TOKEN='${env.AZURE_TOKEN}'
|
2022-12-08 11:36:30 +08:00
|
|
|
export MAPBOX_TOKEN='${env.MAPBOX_TOKEN}'
|
2021-01-24 10:34:18 +08:00
|
|
|
|
2023-02-06 07:45:01 +08:00
|
|
|
export GIT_SSH_COMMAND="ssh -i /data/gitkey"
|
|
|
|
|
2021-01-24 10:34:18 +08:00
|
|
|
source ~/.bash_profile
|
2021-03-27 04:23:18 +08:00
|
|
|
if [ -f /TICI ]; then
|
|
|
|
source /etc/profile
|
2023-07-22 09:35:29 +08:00
|
|
|
|
|
|
|
if ! systemctl is-active --quiet systemd-resolved; then
|
|
|
|
echo "restarting resolved"
|
|
|
|
sudo systemctl start systemd-resolved
|
|
|
|
sleep 3
|
|
|
|
fi
|
2023-07-27 06:11:20 +08:00
|
|
|
|
|
|
|
# restart aux USB
|
|
|
|
if [ -e /sys/bus/usb/drivers/hub/3-0:1.0 ]; then
|
|
|
|
echo "restarting aux usb"
|
|
|
|
echo "3-0:1.0" | sudo tee /sys/bus/usb/drivers/hub/unbind
|
|
|
|
sleep 0.5
|
|
|
|
echo "3-0:1.0" | sudo tee /sys/bus/usb/drivers/hub/bind
|
|
|
|
fi
|
2021-03-27 04:23:18 +08:00
|
|
|
fi
|
2023-05-08 06:43:45 +08:00
|
|
|
if [ -f /data/openpilot/launch_env.sh ]; then
|
2023-05-04 05:26:38 +08:00
|
|
|
source /data/openpilot/launch_env.sh
|
|
|
|
fi
|
|
|
|
|
2021-02-01 10:49:34 +08:00
|
|
|
ln -snf ${env.TEST_DIR} /data/pythonpath
|
|
|
|
|
2020-07-25 17:12:19 +08:00
|
|
|
cd ${env.TEST_DIR} || true
|
|
|
|
${cmd}
|
|
|
|
exit 0
|
2021-01-24 10:34:18 +08:00
|
|
|
|
2021-12-05 13:07:57 +08:00
|
|
|
END"""
|
2021-01-24 10:34:18 +08:00
|
|
|
|
|
|
|
sh script: ssh_cmd, label: step_label
|
2020-07-25 17:12:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-11 07:47:07 +08:00
|
|
|
def deviceStage(String stageName, String deviceType, List env, def steps) {
|
2023-09-10 12:30:21 +08:00
|
|
|
stage(stageName) {
|
|
|
|
if (currentBuild.result != null) {
|
|
|
|
return
|
2020-07-25 17:12:19 +08:00
|
|
|
}
|
2020-07-04 10:12:05 +08:00
|
|
|
|
2023-09-11 07:47:07 +08:00
|
|
|
def extra = env.collect { "export ${it}" }.join('\n');
|
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
docker.image('ghcr.io/commaai/alpine-ssh').inside('--user=root') {
|
|
|
|
lock(resource: "", label: deviceType, inversePrecedence: true, variable: 'device_ip', quantity: 1) {
|
|
|
|
timeout(time: 20, unit: 'MINUTES') {
|
2023-09-11 07:47:07 +08:00
|
|
|
device(device_ip, "git checkout", extra + "\n" + readFile("selfdrive/test/setup_device_ci.sh"))
|
2023-09-10 12:30:21 +08:00
|
|
|
steps.each { item ->
|
|
|
|
device(device_ip, item[0], item[1])
|
|
|
|
}
|
|
|
|
}
|
2023-02-06 07:45:01 +08:00
|
|
|
}
|
|
|
|
}
|
2023-09-10 12:30:21 +08:00
|
|
|
}
|
|
|
|
}
|
2023-02-06 07:45:01 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
def pcStage(String stageName, Closure body) {
|
|
|
|
node {
|
|
|
|
stage(stageName) {
|
|
|
|
if (currentBuild.result != null) {
|
|
|
|
return
|
2020-08-09 11:59:32 +08:00
|
|
|
}
|
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
checkout scm
|
|
|
|
|
2023-09-11 07:47:07 +08:00
|
|
|
def dockerArgs = '--user=root -v /tmp/comma_download_cache:/tmp/comma_download_cache -v /tmp/scons_cache:/tmp/scons_cache';
|
2023-09-10 12:30:21 +08:00
|
|
|
docker.build("openpilot-base:build-${env.GIT_COMMIT}", "-f Dockerfile.openpilot_base .").inside(dockerArgs) {
|
|
|
|
timeout(time: 20, unit: 'MINUTES') {
|
|
|
|
try {
|
|
|
|
sh "git config --global --add safe.directory '*'"
|
|
|
|
sh "git submodule update --init --recursive"
|
|
|
|
sh "git lfs pull"
|
|
|
|
body()
|
|
|
|
} finally {
|
|
|
|
sh "rm -rf ${env.WORKSPACE}/* || true"
|
|
|
|
sh "rm -rf .* || true"
|
2020-07-08 05:17:09 +08:00
|
|
|
}
|
|
|
|
}
|
2023-09-10 12:30:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-04 10:12:05 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
def setupCredentials() {
|
|
|
|
withCredentials([
|
|
|
|
string(credentialsId: 'azure_token', variable: 'AZURE_TOKEN'),
|
|
|
|
string(credentialsId: 'mapbox_token', variable: 'MAPBOX_TOKEN')
|
|
|
|
]) {
|
|
|
|
env.AZURE_TOKEN = "${AZURE_TOKEN}"
|
|
|
|
env.MAPBOX_TOKEN = "${MAPBOX_TOKEN}"
|
|
|
|
}
|
|
|
|
}
|
2023-07-22 12:57:27 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
node {
|
|
|
|
env.CI = "1"
|
|
|
|
env.PYTHONWARNINGS = "error"
|
|
|
|
env.TEST_DIR = "/data/openpilot"
|
|
|
|
env.SOURCE_DIR = "/data/openpilot_source/"
|
|
|
|
setupCredentials()
|
2023-07-22 12:57:27 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
env.GIT_BRANCH = checkout(scm).GIT_BRANCH
|
|
|
|
env.GIT_COMMIT = checkout(scm).GIT_COMMIT
|
2023-04-06 02:07:42 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
def excludeBranches = ['master-ci', 'devel', 'devel-staging', 'release3', 'release3-staging',
|
|
|
|
'dashcam3', 'dashcam3-staging', 'testing-closet*', 'hotfix-*']
|
|
|
|
def excludeRegex = excludeBranches.join('|').replaceAll('\\*', '.*')
|
2022-06-12 06:32:12 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
if (env.BRANCH_NAME != 'master') {
|
|
|
|
properties([
|
|
|
|
disableConcurrentBuilds(abortPrevious: true)
|
|
|
|
])
|
|
|
|
}
|
2022-11-12 13:50:09 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
try {
|
|
|
|
if (env.BRANCH_NAME == 'devel-staging') {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("build release3-staging", "tici-needs-can", [], [
|
|
|
|
["build release3-staging & dashcam3-staging", "RELEASE_BRANCH=release3-staging DASHCAM_BRANCH=dashcam3-staging $SOURCE_DIR/release/build_release.sh"],
|
2023-09-10 12:30:21 +08:00
|
|
|
])
|
|
|
|
}
|
2022-06-12 06:32:12 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
if (env.BRANCH_NAME == 'master-ci') {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("build nightly", "tici-needs-can", [], [
|
|
|
|
["build nightly", "RELEASE_BRANCH=nightly $SOURCE_DIR/release/build_release.sh"],
|
2023-09-10 12:30:21 +08:00
|
|
|
])
|
|
|
|
}
|
2022-11-03 07:34:02 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
if (!env.BRANCH_NAME.matches(excludeRegex)) {
|
|
|
|
parallel (
|
|
|
|
// tici tests
|
|
|
|
'onroad tests': {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("onroad", "tici-needs-can", ["SKIP_COPY=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build master-ci", "cd $SOURCE_DIR/release && TARGET_DIR=$TEST_DIR ./build_devel.sh"],
|
|
|
|
["build openpilot", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["check dirty", "release/check-dirty.sh"],
|
|
|
|
["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"],
|
|
|
|
["time to onroad", "cd selfdrive/test/ && pytest test_time_to_onroad.py"],
|
|
|
|
])
|
|
|
|
},
|
|
|
|
'HW + Unit Tests': {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("tici", "tici-common", ["UNSAFE=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["test pandad", "pytest selfdrive/boardd/tests/test_pandad.py"],
|
|
|
|
["test power draw", "./system/hardware/tici/tests/test_power_draw.py"],
|
|
|
|
["test encoder", "LD_LIBRARY_PATH=/usr/local/lib pytest system/loggerd/tests/test_encoder.py"],
|
|
|
|
["test pigeond", "pytest system/sensord/tests/test_pigeond.py"],
|
|
|
|
["test manager", "pytest selfdrive/manager/test/test_manager.py"],
|
|
|
|
["test nav", "pytest selfdrive/navd/tests/"],
|
|
|
|
])
|
|
|
|
},
|
|
|
|
'loopback': {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("tici", "tici-loopback", ["UNSAFE=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build openpilot", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["test boardd loopback", "pytest selfdrive/boardd/tests/test_boardd_loopback.py"],
|
|
|
|
])
|
|
|
|
},
|
|
|
|
'camerad': {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("AR0231", "tici-ar0231", ["UNSAFE=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["test camerad", "pytest system/camerad/test/test_camerad.py"],
|
|
|
|
["test exposure", "pytest system/camerad/test/test_exposure.py"],
|
|
|
|
])
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("OX03C10", "tici-ox03c10", ["UNSAFE=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["test camerad", "pytest system/camerad/test/test_camerad.py"],
|
|
|
|
["test exposure", "pytest system/camerad/test/test_exposure.py"],
|
|
|
|
])
|
|
|
|
},
|
|
|
|
'sensord': {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("LSM + MMC", "tici-lsmc", ["UNSAFE=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["test sensord", "cd system/sensord/tests && pytest test_sensord.py"],
|
|
|
|
])
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("BMX + LSM", "tici-bmx-lsm", ["UNSAFE=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["test sensord", "cd system/sensord/tests && pytest test_sensord.py"],
|
|
|
|
])
|
|
|
|
},
|
|
|
|
'replay': {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("tici", "tici-replay", ["UNSAFE=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["model replay", "cd selfdrive/test/process_replay && ./model_replay.py"],
|
|
|
|
])
|
|
|
|
},
|
|
|
|
'tizi': {
|
2023-09-11 07:47:07 +08:00
|
|
|
deviceStage("tizi", "tizi", ["UNSAFE=1"], [
|
2023-09-10 12:30:21 +08:00
|
|
|
["build openpilot", "cd selfdrive/manager && ./build.py"],
|
|
|
|
["test boardd loopback", "SINGLE_PANDA=1 pytest selfdrive/boardd/tests/test_boardd_loopback.py"],
|
|
|
|
["test pandad", "pytest selfdrive/boardd/tests/test_pandad.py"],
|
|
|
|
["test amp", "pytest system/hardware/tici/tests/test_amplifier.py"],
|
|
|
|
["test hw", "pytest system/hardware/tici/tests/test_hardware.py"],
|
|
|
|
["test rawgpsd", "pytest system/sensord/rawgps/test_rawgps.py"],
|
|
|
|
])
|
|
|
|
},
|
|
|
|
|
|
|
|
// *** PC tests ***
|
|
|
|
'PC tests': {
|
|
|
|
pcStage("PC tests") {
|
|
|
|
// tests that our build system's dependencies are configured properly,
|
|
|
|
// needs a machine with lots of cores
|
2023-09-11 07:47:07 +08:00
|
|
|
sh label: "test multi-threaded build", script: "scons --no-cache --random -j42"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'car tests': {
|
|
|
|
pcStage("car tests") {
|
|
|
|
sh "scons -j30"
|
|
|
|
sh label: "test_models.py", script: "INTERNAL_SEG_CNT=250 INTERNAL_SEG_LIST=selfdrive/car/tests/test_models_segs.txt FILEREADER_CACHE=1 \
|
2023-09-10 12:30:21 +08:00
|
|
|
pytest -n42 --dist=loadscope selfdrive/car/tests/test_models.py"
|
2023-09-11 07:47:07 +08:00
|
|
|
sh label: "test_car_interfaces.py", script: "MAX_EXAMPLES=100 pytest -n42 selfdrive/car/tests/test_car_interfaces.py"
|
2022-06-12 06:32:12 +08:00
|
|
|
}
|
2023-09-10 12:30:21 +08:00
|
|
|
},
|
2023-09-11 07:47:07 +08:00
|
|
|
|
2023-09-10 12:30:21 +08:00
|
|
|
)
|
2020-01-31 05:06:45 +08:00
|
|
|
}
|
2023-09-10 12:30:21 +08:00
|
|
|
} catch (Exception e) {
|
|
|
|
currentBuild.result = 'FAILED'
|
|
|
|
throw e
|
2020-01-31 05:06:45 +08:00
|
|
|
}
|
2023-09-10 12:30:21 +08:00
|
|
|
}
|