build.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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. # Enable ccache for all build jobs. See configure_ci_environment.sh for more ccache related settings.
  9. IDF_CCACHE_ENABLE: "1"
  10. after_script:
  11. # Show ccache statistics if enabled globally
  12. - test "$CI_CCACHE_STATS" == 1 && test -n "$(which ccache)" && ccache --show-stats || true
  13. dependencies: []
  14. .build_pytest_template:
  15. extends:
  16. - .build_template
  17. - .before_script_build_jobs
  18. dependencies: # set dependencies to null to avoid missing artifacts issue
  19. needs:
  20. - job: fast_template_app
  21. artifacts: false
  22. artifacts:
  23. paths:
  24. - "**/build*/size.json"
  25. - "**/build*/build_log.txt"
  26. - "**/build*/*.bin"
  27. - "**/build*/*.elf"
  28. - "**/build*/*.map"
  29. - "**/build*/flasher_args.json"
  30. - "**/build*/flash_project_args"
  31. - "**/build*/config/sdkconfig.json"
  32. - "**/build*/bootloader/*.bin"
  33. - "**/build*/partition_table/*.bin"
  34. - $SIZE_INFO_LOCATION
  35. when: always
  36. expire_in: 3 days
  37. script:
  38. # CI specific options start from "--collect-size-info xxx". could ignore when running locally
  39. - run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
  40. -t $IDF_TARGET
  41. --pytest-apps
  42. --collect-size-info $SIZE_INFO_LOCATION
  43. --parallel-count ${CI_NODE_TOTAL:-1}
  44. --parallel-index ${CI_NODE_INDEX:-1}
  45. build_pytest_examples_esp32:
  46. extends:
  47. - .build_pytest_template
  48. - .rules:build:example_test-esp32
  49. parallel: 3
  50. variables:
  51. IDF_TARGET: esp32
  52. TEST_DIR: examples
  53. build_pytest_examples_esp32s2:
  54. extends:
  55. - .build_pytest_template
  56. - .rules:build:example_test-esp32s2
  57. parallel: 3
  58. variables:
  59. IDF_TARGET: esp32s2
  60. TEST_DIR: examples
  61. build_pytest_examples_esp32s3:
  62. extends:
  63. - .build_pytest_template
  64. - .rules:build:example_test-esp32s3
  65. parallel: 3
  66. variables:
  67. IDF_TARGET: esp32s3
  68. TEST_DIR: examples
  69. build_pytest_examples_esp32c3:
  70. extends:
  71. - .build_pytest_template
  72. - .rules:build:example_test-esp32c3
  73. parallel: 3
  74. variables:
  75. IDF_TARGET: esp32c3
  76. TEST_DIR: examples
  77. build_pytest_examples_esp32c2:
  78. extends:
  79. - .build_pytest_template
  80. - .rules:build:example_test-esp32c2
  81. variables:
  82. IDF_TARGET: esp32c2
  83. TEST_DIR: examples
  84. build_pytest_components_esp32:
  85. extends:
  86. - .build_pytest_template
  87. - .rules:build:component_ut-esp32
  88. parallel: 2
  89. variables:
  90. IDF_TARGET: esp32
  91. TEST_DIR: components
  92. build_pytest_components_esp32s2:
  93. extends:
  94. - .build_pytest_template
  95. - .rules:build:component_ut-esp32s2
  96. variables:
  97. IDF_TARGET: esp32s2
  98. TEST_DIR: components
  99. build_pytest_components_esp32s3:
  100. extends:
  101. - .build_pytest_template
  102. - .rules:build:component_ut-esp32s3
  103. variables:
  104. IDF_TARGET: esp32s3
  105. TEST_DIR: components
  106. build_pytest_components_esp32c3:
  107. extends:
  108. - .build_pytest_template
  109. - .rules:build:component_ut-esp32c3
  110. variables:
  111. IDF_TARGET: esp32c3
  112. TEST_DIR: components
  113. build_pytest_components_esp32c2:
  114. extends:
  115. - .build_pytest_template
  116. - .rules:build:component_ut-esp32c2
  117. variables:
  118. IDF_TARGET: esp32c2
  119. TEST_DIR: components
  120. build_non_test_components_apps:
  121. extends:
  122. - .build_cmake_template
  123. - .rules:build:component_ut
  124. script:
  125. - set_component_ut_vars
  126. # CI specific options start from "--collect-size-info xxx". could ignore when running locally
  127. - run_cmd python tools/ci/ci_build_apps.py $COMPONENT_UT_DIRS -v
  128. -t all
  129. --collect-size-info $SIZE_INFO_LOCATION
  130. --collect-app-info list_job_${CI_NODE_INDEX:-1}.json
  131. --parallel-count ${CI_NODE_TOTAL:-1}
  132. --parallel-index ${CI_NODE_INDEX:-1}
  133. build_pytest_test_apps_esp32:
  134. extends:
  135. - .build_pytest_template
  136. - .rules:build:custom_test-esp32
  137. variables:
  138. IDF_TARGET: esp32
  139. TEST_DIR: tools/test_apps
  140. build_pytest_test_apps_esp32s2:
  141. extends:
  142. - .build_pytest_template
  143. - .rules:build:custom_test-esp32s2
  144. variables:
  145. IDF_TARGET: esp32s2
  146. TEST_DIR: tools/test_apps
  147. build_pytest_test_apps_esp32s3:
  148. extends:
  149. - .build_pytest_template
  150. - .rules:build:custom_test-esp32s3
  151. variables:
  152. IDF_TARGET: esp32s3
  153. TEST_DIR: tools/test_apps
  154. build_pytest_test_apps_esp32c3:
  155. extends:
  156. - .build_pytest_template
  157. - .rules:build:custom_test-esp32c3
  158. variables:
  159. IDF_TARGET: esp32c3
  160. TEST_DIR: tools/test_apps
  161. build_pytest_test_apps_esp32c2:
  162. extends:
  163. - .build_pytest_template
  164. - .rules:build:custom_test-esp32c2
  165. variables:
  166. IDF_TARGET: esp32c2
  167. TEST_DIR: tools/test_apps
  168. .build_template_app_template:
  169. extends:
  170. - .build_template
  171. - .before_script_build_jobs
  172. variables:
  173. LOG_PATH: "${CI_PROJECT_DIR}/log_template_app"
  174. BUILD_PATH: "${CI_PROJECT_DIR}/build_template_app"
  175. BUILD_DIR: "@t/@w"
  176. BUILD_LOG_CMAKE: "${LOG_PATH}/cmake_@t_@w.txt"
  177. BUILD_COMMAND_ARGS: ""
  178. artifacts:
  179. when: always
  180. paths:
  181. - log_template_app/*
  182. - size_info.txt
  183. - build_template_app/**/size.json
  184. expire_in: 1 week
  185. script:
  186. # Set the variable for 'esp-idf-template' testing
  187. - ESP_IDF_TEMPLATE_GIT=${ESP_IDF_TEMPLATE_GIT:-"https://github.com/espressif/esp-idf-template.git"}
  188. - retry_failed git clone ${ESP_IDF_TEMPLATE_GIT}
  189. # Try to use the same branch name for esp-idf-template that we're
  190. # using on esp-idf. If it doesn't exist then just stick to the default branch
  191. - python $CHECKOUT_REF_SCRIPT esp-idf-template esp-idf-template
  192. - export PATH="$IDF_PATH/tools:$PATH"
  193. # Only do the default cmake build for each target, remaining part are done in the build_template_app job
  194. - tools/ci/build_template_app.sh ${BUILD_COMMAND_ARGS}
  195. # build-related-pre-check-jobs ------------------------------------------------
  196. # Build at least one project for each target at earliest stage to reduce build cost for obvious failing commits
  197. fast_template_app:
  198. extends:
  199. - .build_template_app_template
  200. - .rules:build:target_test
  201. stage: pre_check
  202. variables:
  203. BUILD_COMMAND_ARGS: "-p"
  204. #------------------------------------------------------------------------------
  205. .build_ssc_template:
  206. extends:
  207. - .build_template
  208. - .rules:build:integration_test
  209. artifacts:
  210. paths:
  211. - SSC/ssc_bin
  212. expire_in: 1 week
  213. script:
  214. - retry_failed git clone $SSC_REPOSITORY
  215. - python $CHECKOUT_REF_SCRIPT SSC SSC
  216. - cd SSC
  217. - MAKEFLAGS= ./ci_build_ssc.sh $TARGET_NAME
  218. build_ssc_esp32:
  219. extends: .build_ssc_template
  220. parallel: 3
  221. variables:
  222. TARGET_NAME: "ESP32"
  223. build_ssc_esp32s2:
  224. extends: .build_ssc_template
  225. parallel: 2
  226. variables:
  227. TARGET_NAME: "ESP32S2"
  228. build_ssc_esp32c2:
  229. extends: .build_ssc_template
  230. parallel: 2
  231. variables:
  232. TARGET_NAME: "ESP32C2"
  233. build_ssc_esp32c3:
  234. extends: .build_ssc_template
  235. parallel: 3
  236. variables:
  237. TARGET_NAME: "ESP32C3"
  238. build_ssc_esp32s3:
  239. extends: .build_ssc_template
  240. parallel: 3
  241. variables:
  242. TARGET_NAME: "ESP32S3"
  243. .build_esp_idf_tests_cmake_template:
  244. extends:
  245. - .build_template
  246. - .before_script_build_jobs
  247. dependencies: # set dependencies to null to avoid missing artifacts issue
  248. needs:
  249. - job: fast_template_app
  250. artifacts: false
  251. artifacts:
  252. paths:
  253. - "**/build*/size.json"
  254. - "**/build*/build_log.txt"
  255. - "**/build*/*.bin"
  256. - "**/build*/*.elf"
  257. - "**/build*/*.map"
  258. - "**/build*/flasher_args.json"
  259. - "**/build*/flash_project_args"
  260. - "**/build*/config/sdkconfig.json"
  261. - "**/build*/sdkconfig"
  262. - "**/build*/bootloader/*.bin"
  263. - "**/build*/partition_table/*.bin"
  264. - list_job_*.json
  265. - $SIZE_INFO_LOCATION
  266. - components/idf_test/unit_test/*.yml
  267. when: always
  268. expire_in: 4 days
  269. variables:
  270. LDGEN_CHECK_MAPPING: 1
  271. script:
  272. # CI specific options start from "--collect-size-info xxx". could ignore when running locally
  273. - run_cmd python tools/ci/ci_build_apps.py tools/unit-test-app -v
  274. -t $IDF_TARGET
  275. --config "configs/*="
  276. --copy-sdkconfig
  277. --preserve-all
  278. --collect-size-info $SIZE_INFO_LOCATION
  279. --collect-app-info list_job_${CI_NODE_INDEX:-1}.json
  280. --parallel-count ${CI_NODE_TOTAL:-1}
  281. --parallel-index ${CI_NODE_INDEX:-1}
  282. - run_cmd python tools/unit-test-app/tools/UnitTestParser.py tools/unit-test-app ${CI_NODE_INDEX:-1}
  283. build_esp_idf_tests_cmake_esp32:
  284. extends:
  285. - .build_esp_idf_tests_cmake_template
  286. - .rules:build:unit_test-esp32
  287. parallel: 2
  288. variables:
  289. IDF_TARGET: esp32
  290. build_esp_idf_tests_cmake_esp32s2:
  291. extends:
  292. - .build_esp_idf_tests_cmake_template
  293. - .rules:build:unit_test-esp32s2
  294. parallel: 2
  295. variables:
  296. IDF_TARGET: esp32s2
  297. build_esp_idf_tests_cmake_esp32s3:
  298. extends:
  299. - .build_esp_idf_tests_cmake_template
  300. - .rules:build:unit_test-esp32s3
  301. variables:
  302. IDF_TARGET: esp32s3
  303. build_esp_idf_tests_cmake_esp32c2:
  304. extends:
  305. - .build_esp_idf_tests_cmake_template
  306. - .rules:build:unit_test-esp32c2
  307. variables:
  308. IDF_TARGET: esp32c2
  309. build_esp_idf_tests_cmake_esp32c3:
  310. extends:
  311. - .build_esp_idf_tests_cmake_template
  312. - .rules:build:unit_test-esp32c3
  313. variables:
  314. IDF_TARGET: esp32c3
  315. .build_cmake_template:
  316. extends:
  317. - .build_template
  318. - .before_script_build_jobs
  319. dependencies: # set dependencies to null to avoid missing artifacts issue
  320. needs:
  321. - job: fast_template_app
  322. artifacts: false
  323. variables:
  324. LDGEN_CHECK_MAPPING: 1
  325. artifacts:
  326. paths:
  327. - "**/build*/size.json"
  328. - "**/build*/build_log.txt"
  329. - "**/build*/*.bin"
  330. - "**/build*/*.elf"
  331. - "**/build*/*.map"
  332. - "**/build*/flasher_args.json"
  333. - "**/build*/flash_project_args"
  334. - "**/build*/config/sdkconfig.json"
  335. - "**/build*/sdkconfig"
  336. - "**/build*/bootloader/*.bin"
  337. - "**/build*/partition_table/*.bin"
  338. - list_job_*.json
  339. - $SIZE_INFO_LOCATION
  340. when: always
  341. expire_in: 4 days
  342. script:
  343. # CI specific options start from "--collect-size-info xxx". could ignore when running locally
  344. - run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
  345. -t $IDF_TARGET
  346. --copy-sdkconfig
  347. --collect-size-info $SIZE_INFO_LOCATION
  348. --collect-app-info list_job_${CI_NODE_INDEX:-1}.json
  349. --parallel-count ${CI_NODE_TOTAL:-1}
  350. --parallel-index ${CI_NODE_INDEX:-1}
  351. --extra-preserve-dirs
  352. examples/bluetooth/esp_ble_mesh/ble_mesh_console
  353. examples/bluetooth/hci/controller_hci_uart_esp32
  354. examples/wifi/iperf
  355. build_examples_cmake_esp32:
  356. extends:
  357. - .build_cmake_template
  358. - .rules:build:example_test-esp32
  359. parallel: 12
  360. variables:
  361. IDF_TARGET: esp32
  362. TEST_DIR: examples
  363. build_examples_cmake_esp32s2:
  364. extends:
  365. - .build_cmake_template
  366. - .rules:build:example_test-esp32s2
  367. parallel: 8
  368. variables:
  369. IDF_TARGET: esp32s2
  370. TEST_DIR: examples
  371. build_examples_cmake_esp32s3:
  372. extends:
  373. - .build_cmake_template
  374. - .rules:build:example_test-esp32s3
  375. parallel: 8
  376. variables:
  377. IDF_TARGET: esp32s3
  378. TEST_DIR: examples
  379. build_examples_cmake_esp32c2:
  380. extends:
  381. - .build_cmake_template
  382. - .rules:build:example_test-esp32c2
  383. parallel: 8
  384. variables:
  385. IDF_TARGET: esp32c2
  386. TEST_DIR: examples
  387. build_examples_cmake_esp32c3:
  388. extends:
  389. - .build_cmake_template
  390. - .rules:build:example_test-esp32c3
  391. parallel: 8
  392. variables:
  393. IDF_TARGET: esp32c3
  394. TEST_DIR: examples
  395. build_examples_cmake_esp32h2:
  396. extends:
  397. - .build_cmake_template
  398. - .rules:build:example_test-esp32h2
  399. variables:
  400. IDF_TARGET: esp32h2
  401. TEST_DIR: examples
  402. build_test_apps_esp32:
  403. extends:
  404. - .build_cmake_template
  405. - .rules:build:custom_test-esp32
  406. parallel: 2
  407. variables:
  408. IDF_TARGET: esp32
  409. TEST_DIR: tools/test_apps
  410. build_test_apps_esp32s2:
  411. extends:
  412. - .build_cmake_template
  413. - .rules:build:custom_test-esp32s2
  414. parallel: 2
  415. variables:
  416. IDF_TARGET: esp32s2
  417. TEST_DIR: tools/test_apps
  418. build_test_apps_esp32s3:
  419. extends:
  420. - .build_cmake_template
  421. - .rules:build:custom_test-esp32s3
  422. parallel: 2
  423. variables:
  424. IDF_TARGET: esp32s3
  425. TEST_DIR: tools/test_apps
  426. build_test_apps_esp32c3:
  427. extends:
  428. - .build_cmake_template
  429. - .rules:build:custom_test-esp32c3
  430. parallel: 2
  431. variables:
  432. IDF_TARGET: esp32c3
  433. TEST_DIR: tools/test_apps
  434. build_test_apps_esp32c2:
  435. extends:
  436. - .build_cmake_template
  437. - .rules:build:custom_test-esp32c2
  438. variables:
  439. IDF_TARGET: esp32c2
  440. TEST_DIR: tools/test_apps
  441. .test_build_system_template:
  442. stage: host_test
  443. extends:
  444. - .build_template
  445. - .rules:build
  446. needs:
  447. - job: fast_template_app
  448. artifacts: false
  449. script:
  450. - ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
  451. - rm -rf test_build_system
  452. - mkdir test_build_system
  453. - cd test_build_system
  454. - ${IDF_PATH}/tools/ci/${SHELL_TEST_SCRIPT}
  455. test_build_system_cmake:
  456. extends: .test_build_system_template
  457. variables:
  458. SHELL_TEST_SCRIPT: test_build_system_cmake.sh
  459. test_build_system_cmake_macos:
  460. extends:
  461. - .test_build_system_template
  462. - .before_script_macos
  463. - .rules:build:macos
  464. tags:
  465. - macos_shell
  466. variables:
  467. SHELL_TEST_SCRIPT: test_build_system_cmake.sh
  468. test_build_system_spaces:
  469. extends: .test_build_system_template
  470. variables:
  471. SHELL_TEST_SCRIPT: test_build_system_spaces.py
  472. build_docker:
  473. extends:
  474. - .before_script_minimal
  475. - .rules:build:docker
  476. stage: host_test
  477. needs: []
  478. image: espressif/docker-builder:1
  479. tags:
  480. - build_docker_amd64_brno
  481. variables:
  482. DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
  483. script:
  484. - export LOCAL_CI_REPOSITORY_URL=$CI_REPOSITORY_URL
  485. - 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
  486. - if [ -n "$LOCAL_GIT_MIRROR" ]; then export LOCAL_CI_REPOSITORY_URL="${LOCAL_GIT_MIRROR}/${CI_PROJECT_PATH}"; fi
  487. - echo "Using repository at $LOCAL_CI_REPOSITORY_URL"
  488. - 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:-$PIPELINE_COMMIT_SHA}"
  489. # Build
  490. - docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/
  491. # We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227.
  492. # The workaround mentioned there works, but leaves around directories which need to be cleaned up manually.
  493. # Therefore, build a copy of the example located inside the container.
  494. - docker run --rm --workdir /opt/esp/idf/examples/get-started/blink ${DOCKER_TMP_IMAGE_NAME} idf.py build
  495. # This job builds template app with permutations of targets and optimization levels
  496. build_template_app:
  497. extends:
  498. - .build_template_app_template
  499. - .rules:build
  500. stage: host_test
  501. needs:
  502. - job: fast_template_app
  503. artifacts: false