Jenkinsfile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. def phone(String ip, String step_label, String cmd) {
  2. withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) {
  3. def ssh_cmd = """
  4. ssh -tt -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' /usr/bin/bash <<'END'
  5. set -e
  6. export CI=1
  7. export TEST_DIR=${env.TEST_DIR}
  8. export SOURCE_DIR=${env.SOURCE_DIR}
  9. export GIT_BRANCH=${env.GIT_BRANCH}
  10. export GIT_COMMIT=${env.GIT_COMMIT}
  11. export AZURE_TOKEN='${env.AZURE_TOKEN}'
  12. export MAPBOX_TOKEN='${env.MAPBOX_TOKEN}'
  13. source ~/.bash_profile
  14. if [ -f /TICI ]; then
  15. source /etc/profile
  16. fi
  17. ln -snf ${env.TEST_DIR} /data/pythonpath
  18. cd ${env.TEST_DIR} || true
  19. ${cmd}
  20. exit 0
  21. END"""
  22. sh script: ssh_cmd, label: step_label
  23. }
  24. }
  25. def phone_steps(String device_type, steps) {
  26. lock(resource: "", label: device_type, inversePrecedence: true, variable: 'device_ip', quantity: 1) {
  27. timeout(time: 20, unit: 'MINUTES') {
  28. phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),)
  29. steps.each { item ->
  30. phone(device_ip, item[0], item[1])
  31. }
  32. }
  33. }
  34. }
  35. pipeline {
  36. agent none
  37. environment {
  38. CI = "1"
  39. TEST_DIR = "/data/openpilot"
  40. SOURCE_DIR = "/data/openpilot_source/"
  41. AZURE_TOKEN = credentials('azure_token')
  42. MAPBOX_TOKEN = credentials('mapbox_token')
  43. }
  44. options {
  45. timeout(time: 3, unit: 'HOURS')
  46. disableConcurrentBuilds(abortPrevious: env.BRANCH_NAME != 'master')
  47. }
  48. stages {
  49. stage('build release3') {
  50. agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
  51. when {
  52. branch 'devel-staging'
  53. }
  54. steps {
  55. phone_steps("tici-needs-can", [
  56. ["build release3-staging & dashcam3-staging", "PUSH=1 $SOURCE_DIR/release/build_release.sh"],
  57. ])
  58. }
  59. }
  60. stage('openpilot tests') {
  61. when {
  62. not {
  63. anyOf {
  64. branch 'master-ci'; branch 'devel'; branch 'devel-staging';
  65. branch 'release3'; branch 'release3-staging'; branch 'dashcam3'; branch 'dashcam3-staging';
  66. branch 'testing-closet*'; branch 'hotfix-*'
  67. }
  68. }
  69. }
  70. parallel {
  71. stage('simulator') {
  72. agent {
  73. dockerfile {
  74. filename 'Dockerfile.sim_nvidia'
  75. dir 'tools/sim'
  76. args '--user=root'
  77. }
  78. }
  79. steps {
  80. sh "git config --global --add safe.directory ${WORKSPACE}"
  81. sh "git lfs pull"
  82. lock(resource: "", label: "simulator", inversePrecedence: true, quantity: 1) {
  83. sh "${WORKSPACE}/tools/sim/build_container.sh"
  84. sh "DETACH=1 ${WORKSPACE}/tools/sim/start_carla.sh"
  85. sh "${WORKSPACE}/tools/sim/start_openpilot_docker.sh"
  86. }
  87. }
  88. post {
  89. always {
  90. sh "docker kill carla_sim || true"
  91. sh "rm -rf ${WORKSPACE}/* || true"
  92. sh "rm -rf .* || true"
  93. }
  94. }
  95. }
  96. stage('build') {
  97. agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
  98. environment {
  99. R3_PUSH = "${env.BRANCH_NAME == 'master' ? '1' : ' '}"
  100. }
  101. steps {
  102. phone_steps("tici-needs-can", [
  103. ["build master-ci", "cd $SOURCE_DIR/release && TARGET_DIR=$TEST_DIR EXTRA_FILES='tools/' ./build_devel.sh"],
  104. ["build openpilot", "cd selfdrive/manager && ./build.py"],
  105. ["check dirty", "release/check-dirty.sh"],
  106. ["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"],
  107. ["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"],
  108. ])
  109. }
  110. }
  111. stage('loopback-tests') {
  112. agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
  113. steps {
  114. phone_steps("tici-loopback", [
  115. ["build openpilot", "cd selfdrive/manager && ./build.py"],
  116. ["test boardd loopback", "python selfdrive/boardd/tests/test_boardd_loopback.py"],
  117. ])
  118. }
  119. }
  120. stage('HW + Unit Tests') {
  121. agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
  122. steps {
  123. phone_steps("tici-common", [
  124. ["build", "cd selfdrive/manager && ./build.py"],
  125. ["test power draw", "python system/hardware/tici/test_power_draw.py"],
  126. ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"],
  127. ["test encoder", "LD_LIBRARY_PATH=/usr/local/lib python selfdrive/loggerd/tests/test_encoder.py"],
  128. ["test pigeond", "python selfdrive/sensord/tests/test_pigeond.py"],
  129. ["test manager", "python selfdrive/manager/test/test_manager.py"],
  130. ])
  131. }
  132. }
  133. stage('camerad-ar') {
  134. agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
  135. steps {
  136. phone_steps("tici-ar0321", [
  137. ["build", "cd selfdrive/manager && ./build.py"],
  138. ["test camerad", "python system/camerad/test/test_camerad.py"],
  139. ["test exposure", "python system/camerad/test/test_exposure.py"],
  140. ])
  141. }
  142. }
  143. stage('camerad-ox') {
  144. agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
  145. steps {
  146. phone_steps("tici-ox03c10", [
  147. ["build", "cd selfdrive/manager && ./build.py"],
  148. ["test camerad", "python system/camerad/test/test_camerad.py"],
  149. ["test exposure", "python system/camerad/test/test_exposure.py"],
  150. ])
  151. }
  152. }
  153. stage('sensord') {
  154. agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
  155. steps {
  156. phone_steps("tici-lsmc", [
  157. ["build", "cd selfdrive/manager && ./build.py"],
  158. ["test sensord", "cd selfdrive/sensord/tests && python -m unittest test_sensord.py"],
  159. ])
  160. phone_steps("tici-bmx-lsm", [
  161. ["build", "cd selfdrive/manager && ./build.py"],
  162. ["test sensord", "cd selfdrive/sensord/tests && python -m unittest test_sensord.py"],
  163. ])
  164. }
  165. }
  166. stage('replay') {
  167. agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
  168. steps {
  169. phone_steps("tici-common", [
  170. ["build", "cd selfdrive/manager && ./build.py"],
  171. ["model replay", "cd selfdrive/test/process_replay && ./model_replay.py"],
  172. ])
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }