build.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. .build_template:
  2. stage: build
  3. image: $ESP_ENV_IMAGE
  4. tags:
  5. - build
  6. variables:
  7. SIZE_INFO_LOCATION: "$CI_PROJECT_DIR/size_info.txt"
  8. dependencies: []
  9. .build_template_app_template:
  10. extends: .build_template
  11. variables:
  12. LOG_PATH: "${CI_PROJECT_DIR}/log_template_app"
  13. BUILD_PATH: "${CI_PROJECT_DIR}/build_template_app"
  14. BUILD_DIR: "@t/@w"
  15. BUILD_LOG_MAKE: "${LOG_PATH}/make_@t_@w.txt"
  16. BUILD_LOG_CMAKE: "${LOG_PATH}/cmake_@t_@w.txt"
  17. BUILD_COMMAND_ARGS: ""
  18. artifacts:
  19. when: always
  20. paths:
  21. - log_template_app/*
  22. - size_info.txt
  23. - build_template_app/**/size.json
  24. script:
  25. # Set the variable for 'esp-idf-template' testing
  26. - ESP_IDF_TEMPLATE_GIT=${ESP_IDF_TEMPLATE_GIT:-"https://github.com/espressif/esp-idf-template.git"}
  27. - retry_failed git clone ${ESP_IDF_TEMPLATE_GIT}
  28. # Try to use the same branch name for esp-idf-template that we're
  29. # using on esp-idf. If it doesn't exist then just stick to the default branch
  30. - python $CHECKOUT_REF_SCRIPT esp-idf-template esp-idf-template
  31. - export PATH="$IDF_PATH/tools:$PATH"
  32. - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS}
  33. - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS}
  34. # Only do the default cmake build for each target, remaining part are done in the build_template_app job
  35. - tools/ci/build_template_app.sh ${BUILD_COMMAND_ARGS}
  36. # Check if there are any stray printf/ets_printf references in WiFi libs
  37. - cd components/esp_wifi/lib
  38. - for dir in esp32 esp32s2; do test $(xtensa-esp32-elf-nm $dir/*.a | grep -w printf | wc -l) -eq 0; done;
  39. - for dir in esp32 esp32s2; do test $(xtensa-esp32-elf-nm $dir/*.a | grep -w ets_printf | wc -l) -eq 0; done;
  40. # build-related-pre-check-jobs ------------------------------------------------
  41. # Build at least one project for each target at earliest stage to reduce build cost for obvious failing commits
  42. fast_template_app:
  43. extends:
  44. - .build_template_app_template
  45. - .rules:build:target_test
  46. stage: pre_check
  47. variables:
  48. BUILD_COMMAND_ARGS: "-p"
  49. #------------------------------------------------------------------------------
  50. .build_ssc_template:
  51. extends:
  52. - .build_template
  53. - .rules:build:integration_test
  54. artifacts:
  55. paths:
  56. - SSC/ssc_bin
  57. expire_in: 1 week
  58. script:
  59. - retry_failed git clone $SSC_REPOSITORY
  60. - python $CHECKOUT_REF_SCRIPT SSC SSC
  61. - cd SSC
  62. - MAKEFLAGS= ./ci_build_ssc.sh $TARGET_NAME
  63. build_ssc_esp32:
  64. extends: .build_ssc_template
  65. parallel: 3
  66. variables:
  67. TARGET_NAME: "ESP32"
  68. build_ssc_esp32s2:
  69. extends: .build_ssc_template
  70. parallel: 2
  71. variables:
  72. TARGET_NAME: "ESP32S2"
  73. build_ssc_esp32c3:
  74. extends: .build_ssc_template
  75. parallel: 3
  76. variables:
  77. TARGET_NAME: "ESP32C3"
  78. .build_esp_idf_tests_cmake_template:
  79. extends: .build_template
  80. dependencies: # set dependencies to null to avoid missing artifacts issue
  81. needs:
  82. - job: fast_template_app
  83. artifacts: false
  84. - scan_tests
  85. artifacts:
  86. paths:
  87. - tools/unit-test-app/output/${IDF_TARGET}
  88. - tools/unit-test-app/builds/*.json
  89. - tools/unit-test-app/builds/${IDF_TARGET}/*/size.json
  90. - components/idf_test/unit_test/*.yml
  91. - $LOG_PATH
  92. - $SIZE_INFO_LOCATION
  93. when: always
  94. expire_in: 4 days
  95. variables:
  96. LOG_PATH: "$CI_PROJECT_DIR/log_ut_cmake"
  97. BUILD_PATH: ${CI_PROJECT_DIR}/tools/unit-test-app/builds
  98. OUTPUT_PATH: ${CI_PROJECT_DIR}/tools/unit-test-app/output
  99. BUILD_SYSTEM: "cmake"
  100. TEST_TYPE: "unit_test"
  101. PYTHON_VER: 3.6.13
  102. LDGEN_CHECK_MAPPING: 1
  103. script:
  104. - ${IDF_PATH}/tools/ci/find_apps_build_apps.sh
  105. - cd $CI_PROJECT_DIR/tools/unit-test-app
  106. - python tools/UnitTestParser.py ${BUILD_PATH} ${CI_NODE_INDEX:-1}
  107. build_esp_idf_tests_cmake_esp32:
  108. extends:
  109. - .build_esp_idf_tests_cmake_template
  110. - .rules:build:unit_test-esp32
  111. parallel: 2
  112. variables:
  113. IDF_TARGET: esp32
  114. build_esp_idf_tests_cmake_esp32s2:
  115. extends:
  116. - .build_esp_idf_tests_cmake_template
  117. - .rules:build:unit_test-esp32s2
  118. parallel: 2
  119. variables:
  120. IDF_TARGET: esp32s2
  121. build_esp_idf_tests_cmake_esp32s3:
  122. extends:
  123. - .build_esp_idf_tests_cmake_template
  124. - .rules:build:unit_test-esp32s3
  125. variables:
  126. IDF_TARGET: esp32s3
  127. build_esp_idf_tests_cmake_esp32c3:
  128. extends:
  129. - .build_esp_idf_tests_cmake_template
  130. - .rules:build:unit_test-esp32c3
  131. variables:
  132. IDF_TARGET: esp32c3
  133. .build_examples_template:
  134. extends: .build_template
  135. dependencies: # set dependencies to null to avoid missing artifacts issue
  136. needs:
  137. - job: fast_template_app
  138. artifacts: false
  139. - scan_tests
  140. variables:
  141. TEST_PREFIX: examples
  142. TEST_RELATIVE_DIR: examples
  143. SCAN_TEST_JSON: ${CI_PROJECT_DIR}/${TEST_RELATIVE_DIR}/test_configs/scan_${IDF_TARGET}_${BUILD_SYSTEM}.json
  144. TEST_TYPE: example_test
  145. LOG_PATH: ${CI_PROJECT_DIR}/log_${TEST_PREFIX}
  146. BUILD_PATH: ${CI_PROJECT_DIR}/build_${TEST_PREFIX}
  147. PYTHON_VER: 3.6.13
  148. LDGEN_CHECK_MAPPING: 1
  149. script:
  150. # it's not possible to build 100% out-of-tree and have the "artifacts"
  151. # mechanism work, but this is the next best thing
  152. - ${IDF_PATH}/tools/ci/find_apps_build_apps.sh
  153. build_examples_make:
  154. extends:
  155. - .build_examples_template
  156. - .rules:build:example_test-esp32
  157. stage: host_test
  158. # This is a workaround for a rarely encountered issue with building examples in CI.
  159. # Probably related to building of Kconfig in 'make clean' stage
  160. retry: 1
  161. parallel: 8
  162. artifacts:
  163. paths:
  164. - $LOG_PATH
  165. - build_${TEST_PREFIX}/*/*/*/build/size.json
  166. - $SIZE_INFO_LOCATION
  167. when: always
  168. expire_in: 4 days
  169. variables:
  170. BUILD_SYSTEM: make
  171. IDF_TARGET: esp32 # currently we only support esp32
  172. # same as above, but for CMake
  173. .build_examples_cmake_template:
  174. extends: .build_examples_template
  175. artifacts:
  176. paths:
  177. - build_${TEST_PREFIX}/list.json
  178. - build_${TEST_PREFIX}/list_job_*.json
  179. - build_${TEST_PREFIX}/*/*/*/sdkconfig
  180. - build_${TEST_PREFIX}/*/*/*/build/size.json
  181. - build_${TEST_PREFIX}/*/*/*/build/*.bin
  182. - build_${TEST_PREFIX}/*/*/*/build/*.elf
  183. - build_${TEST_PREFIX}/*/*/*/build/*.map
  184. - build_${TEST_PREFIX}/*/*/*/build/flasher_args.json
  185. - build_${TEST_PREFIX}/*/*/*/build/bootloader/*.bin
  186. - build_${TEST_PREFIX}/*/*/*/build/partition_table/*.bin
  187. - $LOG_PATH
  188. - $SIZE_INFO_LOCATION
  189. when: always
  190. expire_in: 4 days
  191. variables:
  192. BUILD_SYSTEM: cmake
  193. build_examples_cmake_esp32:
  194. extends:
  195. - .build_examples_cmake_template
  196. - .rules:build:example_test-esp32
  197. parallel: 10
  198. variables:
  199. IDF_TARGET: esp32
  200. build_examples_cmake_esp32s2:
  201. extends:
  202. - .build_examples_cmake_template
  203. - .rules:build:example_test-esp32s2
  204. parallel: 8
  205. variables:
  206. IDF_TARGET: esp32s2
  207. build_examples_cmake_esp32s3:
  208. extends:
  209. - .build_examples_cmake_template
  210. - .rules:build:example_test-esp32s3
  211. parallel: 8
  212. variables:
  213. IDF_TARGET: esp32s3
  214. build_examples_cmake_esp32c3:
  215. extends:
  216. - .build_examples_cmake_template
  217. - .rules:build:example_test-esp32c3
  218. parallel: 8
  219. variables:
  220. IDF_TARGET: esp32c3
  221. .build_test_apps_template:
  222. extends: .build_examples_cmake_template
  223. variables:
  224. TEST_PREFIX: test_apps
  225. TEST_RELATIVE_DIR: tools/test_apps
  226. TEST_TYPE: custom_test
  227. script:
  228. - ${IDF_PATH}/tools/ci/find_apps_build_apps.sh
  229. build_test_apps_esp32:
  230. extends:
  231. - .build_test_apps_template
  232. - .rules:build:custom_test-esp32
  233. parallel: 8
  234. variables:
  235. IDF_TARGET: esp32
  236. build_test_apps_esp32s2:
  237. extends:
  238. - .build_test_apps_template
  239. - .rules:build:custom_test-esp32s2
  240. parallel: 8
  241. variables:
  242. IDF_TARGET: esp32s2
  243. build_test_apps_esp32s3:
  244. extends:
  245. - .build_test_apps_template
  246. - .rules:build:custom_test-esp32s3
  247. parallel: 8
  248. variables:
  249. IDF_TARGET: esp32s3
  250. build_test_apps_esp32c3:
  251. extends:
  252. - .build_test_apps_template
  253. - .rules:build:custom_test-esp32c3
  254. parallel: 8
  255. variables:
  256. IDF_TARGET: esp32c3
  257. .build_component_ut_template:
  258. extends: .build_test_apps_template
  259. variables:
  260. TEST_PREFIX: component_ut
  261. TEST_RELATIVE_DIR: component_ut
  262. build_component_ut_esp32:
  263. extends:
  264. - .build_component_ut_template
  265. - .rules:build:component_ut-esp32
  266. variables:
  267. IDF_TARGET: esp32
  268. build_component_ut_esp32s2:
  269. extends:
  270. - .build_component_ut_template
  271. - .rules:build:component_ut-esp32s2
  272. variables:
  273. IDF_TARGET: esp32s2
  274. build_component_ut_esp32s3:
  275. extends:
  276. - .build_component_ut_template
  277. - .rules:build:component_ut-esp32s3
  278. variables:
  279. IDF_TARGET: esp32s3
  280. build_component_ut_esp32c3:
  281. extends:
  282. - .build_component_ut_template
  283. - .rules:build:component_ut-esp32c3
  284. variables:
  285. IDF_TARGET: esp32c3
  286. .test_build_system_template:
  287. stage: host_test
  288. extends:
  289. - .build_template
  290. - .rules:build
  291. needs:
  292. - job: fast_template_app
  293. artifacts: false
  294. script:
  295. - ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
  296. - rm -rf test_build_system
  297. - mkdir test_build_system
  298. - cd test_build_system
  299. - ${IDF_PATH}/tools/ci/${SHELL_TEST_SCRIPT}
  300. test_build_system:
  301. extends: .test_build_system_template
  302. variables:
  303. SHELL_TEST_SCRIPT: test_build_system.sh
  304. test_build_system_cmake:
  305. extends: .test_build_system_template
  306. variables:
  307. SHELL_TEST_SCRIPT: test_build_system_cmake.sh
  308. test_build_system_cmake_macos:
  309. extends:
  310. - .test_build_system_template
  311. - .before_script_macos
  312. - .rules:build:macos
  313. tags:
  314. - macos_shell
  315. variables:
  316. SHELL_TEST_SCRIPT: test_build_system_cmake.sh
  317. build_docker:
  318. extends:
  319. - .before_script_minimal
  320. - .rules:build:docker
  321. stage: host_test
  322. needs: []
  323. image: espressif/docker-builder:1
  324. tags:
  325. - build_docker_amd64_brno
  326. variables:
  327. DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
  328. script:
  329. - export LOCAL_CI_REPOSITORY_URL=$CI_REPOSITORY_URL
  330. - if [ -n "$LOCAL_GITLAB_HTTPS_HOST" ]; then export LOCAL_CI_REPOSITORY_URL="https://gitlab-ci-token:${CI_JOB_TOKEN}@${LOCAL_GITLAB_HTTPS_HOST}/${CI_PROJECT_PATH}"; fi
  331. - echo "Using repository at $LOCAL_CI_REPOSITORY_URL"
  332. - export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${LOCAL_CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
  333. # Build
  334. - docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/
  335. # We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227.
  336. # The workaround mentioned there works, but leaves around directories which need to be cleaned up manually.
  337. # Therefore, build a copy of the example located inside the container.
  338. - docker run --rm --workdir /opt/esp/idf/examples/get-started/blink ${DOCKER_TMP_IMAGE_NAME} idf.py build
  339. .test-on-windows:
  340. extends:
  341. - .before_script_minimal
  342. - .rules:build:windows
  343. stage: host_test
  344. needs: []
  345. image: $CI_DOCKER_REGISTRY/esp32-toolchain-win-cross
  346. tags:
  347. - build
  348. script:
  349. - cd $TEST_DIR
  350. - mkdir build
  351. - cd build
  352. - cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-i686-w64-mingw32.cmake -DCMAKE_BUILD_TYPE=Release ..
  353. - cmake --build .
  354. build_idf_exe:
  355. extends: .test-on-windows
  356. artifacts:
  357. paths:
  358. - tools/windows/idf_exe/build/idf-exe-v*.zip
  359. expire_in: 4 days
  360. variables:
  361. TEST_DIR: tools/windows/idf_exe
  362. # This job builds template app with permutations of targets and optimization levels
  363. build_template_app:
  364. extends:
  365. - .build_template_app_template
  366. - .rules:build
  367. stage: host_test
  368. needs:
  369. - job: fast_template_app
  370. artifacts: false