build.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. .build_template:
  2. stage: build
  3. extends:
  4. - .after_script:build:ccache
  5. image: $ESP_ENV_IMAGE
  6. tags:
  7. - build
  8. # build only on shiny servers since shiny storage server is at the same location
  9. - shiny
  10. variables:
  11. # Enable ccache for all build jobs. See configure_ci_environment.sh for more ccache related settings.
  12. IDF_CCACHE_ENABLE: "1"
  13. dependencies: []
  14. .build_cmake_template:
  15. extends:
  16. - .build_template
  17. - .before_script:build
  18. - .after_script:build:ccache
  19. dependencies: # set dependencies to null to avoid missing artifacts issue
  20. needs:
  21. - job: fast_template_app
  22. artifacts: false
  23. - pipeline_variables
  24. artifacts:
  25. paths:
  26. # The other artifacts patterns are defined under tools/ci/artifacts_handler.py
  27. # Now we're uploading/downloading the binary files from our internal storage server
  28. #
  29. # keep the log file to help debug
  30. - "**/build*/build_log.txt"
  31. # keep the size info to help track the binary size
  32. - size_info.txt
  33. - "**/build*/size.json"
  34. when: always
  35. expire_in: 4 days
  36. script:
  37. # CI specific options start from "--parallel-count xxx". could ignore when running locally
  38. - run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
  39. -t $IDF_TARGET
  40. --copy-sdkconfig
  41. --parallel-count ${CI_NODE_TOTAL:-1}
  42. --parallel-index ${CI_NODE_INDEX:-1}
  43. --extra-preserve-dirs
  44. examples/bluetooth/esp_ble_mesh/ble_mesh_console
  45. examples/bluetooth/hci/controller_hci_uart_esp32
  46. examples/wifi/iperf
  47. --modified-components ${MODIFIED_COMPONENTS}
  48. --modified-files ${MODIFIED_FILES}
  49. # for detailed documents, please refer to .gitlab/ci/README.md#uploaddownload-artifacts-to-internal-minio-server
  50. - python tools/ci/artifacts_handler.py upload
  51. .build_cmake_clang_template:
  52. extends:
  53. - .build_cmake_template
  54. variables:
  55. IDF_TOOLCHAIN: clang
  56. TEST_BUILD_OPTS_EXTRA: ""
  57. TEST_DIR: tools/test_apps/system/cxx_pthread_bluetooth
  58. script:
  59. # CI specific options start from "--parallel-count xxx". could ignore when running locally
  60. - run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
  61. -t $IDF_TARGET
  62. --copy-sdkconfig
  63. --parallel-count ${CI_NODE_TOTAL:-1}
  64. --parallel-index ${CI_NODE_INDEX:-1}
  65. --modified-components ${MODIFIED_COMPONENTS}
  66. --modified-files ${MODIFIED_FILES}
  67. $TEST_BUILD_OPTS_EXTRA
  68. - python tools/ci/artifacts_handler.py upload
  69. .build_pytest_template:
  70. extends:
  71. - .build_cmake_template
  72. script:
  73. # CI specific options start from "--parallel-count xxx". could ignore when running locally
  74. - run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
  75. -t $IDF_TARGET
  76. -m \"not host_test\"
  77. --pytest-apps
  78. --parallel-count ${CI_NODE_TOTAL:-1}
  79. --parallel-index ${CI_NODE_INDEX:-1}
  80. --collect-app-info "list_job_${CI_JOB_NAME_SLUG}.txt"
  81. --modified-components ${MODIFIED_COMPONENTS}
  82. --modified-files ${MODIFIED_FILES}
  83. - python tools/ci/artifacts_handler.py upload
  84. .build_pytest_no_jtag_template:
  85. extends:
  86. - .build_cmake_template
  87. script:
  88. # CI specific options start from "--parallel-count xxx". could ignore when running locally
  89. - run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
  90. -t $IDF_TARGET
  91. -m \"not host_test and not jtag\"
  92. --pytest-apps
  93. --parallel-count ${CI_NODE_TOTAL:-1}
  94. --parallel-index ${CI_NODE_INDEX:-1}
  95. --collect-app-info "list_job_${CI_JOB_NAME_SLUG}.txt"
  96. --modified-components ${MODIFIED_COMPONENTS}
  97. --modified-files ${MODIFIED_FILES}
  98. - python tools/ci/artifacts_handler.py upload
  99. .build_pytest_jtag_template:
  100. extends:
  101. - .build_cmake_template
  102. script:
  103. # CI specific options start from "--parallel-count xxx". could ignore when running locally
  104. - run_cmd python tools/ci/ci_build_apps.py $TEST_DIR -v
  105. -t $IDF_TARGET
  106. -m \"not host_test and jtag\"
  107. --pytest-apps
  108. --parallel-count ${CI_NODE_TOTAL:-1}
  109. --parallel-index ${CI_NODE_INDEX:-1}
  110. --collect-app-info "list_job_${CI_JOB_NAME_SLUG}.txt"
  111. --modified-components ${MODIFIED_COMPONENTS}
  112. --modified-files ${MODIFIED_FILES}
  113. - python tools/ci/artifacts_handler.py upload
  114. build_pytest_examples_esp32:
  115. extends:
  116. - .build_pytest_no_jtag_template
  117. - .rules:build:example_test-esp32
  118. parallel: 6
  119. variables:
  120. IDF_TARGET: esp32
  121. TEST_DIR: examples
  122. build_pytest_examples_esp32s2:
  123. extends:
  124. - .build_pytest_no_jtag_template
  125. - .rules:build:example_test-esp32s2
  126. parallel: 3
  127. variables:
  128. IDF_TARGET: esp32s2
  129. TEST_DIR: examples
  130. build_pytest_examples_esp32s3:
  131. extends:
  132. - .build_pytest_no_jtag_template
  133. - .rules:build:example_test-esp32s3
  134. parallel: 4
  135. variables:
  136. IDF_TARGET: esp32s3
  137. TEST_DIR: examples
  138. build_pytest_examples_esp32c3:
  139. extends:
  140. - .build_pytest_no_jtag_template
  141. - .rules:build:example_test-esp32c3
  142. parallel: 4
  143. variables:
  144. IDF_TARGET: esp32c3
  145. TEST_DIR: examples
  146. build_pytest_examples_esp32c2:
  147. extends:
  148. - .build_pytest_no_jtag_template
  149. - .rules:build:example_test-esp32c2
  150. parallel: 2
  151. variables:
  152. IDF_TARGET: esp32c2
  153. TEST_DIR: examples
  154. build_pytest_examples_esp32c6:
  155. extends:
  156. - .build_pytest_no_jtag_template
  157. - .rules:build:example_test-esp32c6
  158. parallel: 2
  159. variables:
  160. IDF_TARGET: esp32c6
  161. TEST_DIR: examples
  162. build_pytest_examples_esp32h2:
  163. extends:
  164. - .build_pytest_no_jtag_template
  165. - .rules:build:example_test-esp32h2
  166. parallel: 2
  167. variables:
  168. IDF_TARGET: esp32h2
  169. TEST_DIR: examples
  170. build_pytest_examples_jtag: # for all targets
  171. extends:
  172. - .build_pytest_jtag_template
  173. - .rules:build:example_test
  174. variables:
  175. IDF_TARGET: all
  176. TEST_DIR: examples
  177. build_pytest_components_esp32:
  178. extends:
  179. - .build_pytest_template
  180. - .rules:build:component_ut-esp32
  181. parallel: 5
  182. variables:
  183. IDF_TARGET: esp32
  184. TEST_DIR: components
  185. build_pytest_components_esp32s2:
  186. extends:
  187. - .build_pytest_template
  188. - .rules:build:component_ut-esp32s2
  189. parallel: 4
  190. variables:
  191. IDF_TARGET: esp32s2
  192. TEST_DIR: components
  193. build_pytest_components_esp32s3:
  194. extends:
  195. - .build_pytest_template
  196. - .rules:build:component_ut-esp32s3
  197. parallel: 4
  198. variables:
  199. IDF_TARGET: esp32s3
  200. TEST_DIR: components
  201. build_pytest_components_esp32c3:
  202. extends:
  203. - .build_pytest_template
  204. - .rules:build:component_ut-esp32c3
  205. parallel: 4
  206. variables:
  207. IDF_TARGET: esp32c3
  208. TEST_DIR: components
  209. build_pytest_components_esp32c2:
  210. extends:
  211. - .build_pytest_template
  212. - .rules:build:component_ut-esp32c2
  213. parallel: 3
  214. variables:
  215. IDF_TARGET: esp32c2
  216. TEST_DIR: components
  217. build_pytest_components_esp32c6:
  218. extends:
  219. - .build_pytest_template
  220. - .rules:build:component_ut-esp32c6
  221. parallel: 3
  222. variables:
  223. IDF_TARGET: esp32c6
  224. TEST_DIR: components
  225. build_pytest_components_esp32h2:
  226. extends:
  227. - .build_pytest_template
  228. - .rules:build:component_ut-esp32h2
  229. parallel: 4
  230. variables:
  231. IDF_TARGET: esp32h2
  232. TEST_DIR: components
  233. build_only_components_apps:
  234. extends:
  235. - .build_cmake_template
  236. - .rules:build:component_ut
  237. parallel: 5
  238. script:
  239. - set_component_ut_vars
  240. # CI specific options start from "--parallel-count xxx". could ignore when running locally
  241. - run_cmd python tools/ci/ci_build_apps.py $COMPONENT_UT_DIRS -v
  242. -t all
  243. --parallel-count ${CI_NODE_TOTAL:-1}
  244. --parallel-index ${CI_NODE_INDEX:-1}
  245. --modified-components ${MODIFIED_COMPONENTS}
  246. --modified-files ${MODIFIED_FILES}
  247. - python tools/ci/artifacts_handler.py upload
  248. build_pytest_test_apps_esp32:
  249. extends:
  250. - .build_pytest_template
  251. - .rules:build:custom_test-esp32
  252. variables:
  253. IDF_TARGET: esp32
  254. TEST_DIR: tools/test_apps
  255. build_pytest_test_apps_esp32s2:
  256. extends:
  257. - .build_pytest_template
  258. - .rules:build:custom_test-esp32s2
  259. variables:
  260. IDF_TARGET: esp32s2
  261. TEST_DIR: tools/test_apps
  262. build_pytest_test_apps_esp32s3:
  263. extends:
  264. - .build_pytest_template
  265. - .rules:build:custom_test-esp32s3
  266. parallel: 2
  267. variables:
  268. IDF_TARGET: esp32s3
  269. TEST_DIR: tools/test_apps
  270. build_pytest_test_apps_esp32c3:
  271. extends:
  272. - .build_pytest_template
  273. - .rules:build:custom_test-esp32c3
  274. variables:
  275. IDF_TARGET: esp32c3
  276. TEST_DIR: tools/test_apps
  277. build_pytest_test_apps_esp32c2:
  278. extends:
  279. - .build_pytest_template
  280. - .rules:build:custom_test-esp32c2
  281. variables:
  282. IDF_TARGET: esp32c2
  283. TEST_DIR: tools/test_apps
  284. build_pytest_test_apps_esp32c6:
  285. extends:
  286. - .build_pytest_template
  287. - .rules:build:custom_test-esp32c6
  288. variables:
  289. IDF_TARGET: esp32c6
  290. TEST_DIR: tools/test_apps
  291. build_pytest_test_apps_esp32h2:
  292. extends:
  293. - .build_pytest_template
  294. - .rules:build:custom_test-esp32h2
  295. variables:
  296. IDF_TARGET: esp32h2
  297. TEST_DIR: tools/test_apps
  298. build_only_tools_test_apps:
  299. extends:
  300. - .build_cmake_template
  301. - .rules:build:custom_test
  302. parallel: 9
  303. script:
  304. # CI specific options start from "--parallel-count xxx". could ignore when running locally
  305. - run_cmd python tools/ci/ci_build_apps.py tools/test_apps -v
  306. -t all
  307. --parallel-count ${CI_NODE_TOTAL:-1}
  308. --parallel-index ${CI_NODE_INDEX:-1}
  309. --modified-components ${MODIFIED_COMPONENTS}
  310. --modified-files ${MODIFIED_FILES}
  311. - python tools/ci/artifacts_handler.py upload
  312. .build_template_app_template:
  313. extends:
  314. - .build_template
  315. - .before_script:build
  316. variables:
  317. LOG_PATH: "${CI_PROJECT_DIR}/log_template_app"
  318. BUILD_PATH: "${CI_PROJECT_DIR}/build_template_app"
  319. BUILD_DIR: "${BUILD_PATH}/@t/@w"
  320. BUILD_LOG_CMAKE: "${LOG_PATH}/cmake_@t_@w.txt"
  321. BUILD_COMMAND_ARGS: ""
  322. artifacts:
  323. when: always
  324. paths:
  325. - log_template_app/*
  326. - size_info.txt
  327. - build_template_app/**/size.json
  328. expire_in: 1 week
  329. script:
  330. # Set the variable for 'esp-idf-template' testing
  331. - ESP_IDF_TEMPLATE_GIT=${ESP_IDF_TEMPLATE_GIT:-"https://github.com/espressif/esp-idf-template.git"}
  332. - retry_failed git clone ${ESP_IDF_TEMPLATE_GIT}
  333. # Try to use the same branch name for esp-idf-template that we're
  334. # using on esp-idf. If it doesn't exist then just stick to the default branch
  335. - python $CHECKOUT_REF_SCRIPT esp-idf-template esp-idf-template
  336. - export PATH="$IDF_PATH/tools:$PATH"
  337. # Only do the default cmake build for each target, remaining part are done in the build_template_app job
  338. - tools/ci/build_template_app.sh ${BUILD_COMMAND_ARGS}
  339. # build-related-pre-check-jobs ------------------------------------------------
  340. # Build at least one project for each target at earliest stage to reduce build cost for obvious failing commits
  341. fast_template_app:
  342. extends:
  343. - .build_template_app_template
  344. - .rules:build:target_test
  345. stage: pre_check
  346. variables:
  347. BUILD_COMMAND_ARGS: "-p"
  348. #------------------------------------------------------------------------------
  349. build_examples_cmake_esp32:
  350. extends:
  351. - .build_cmake_template
  352. - .rules:build:example_test-esp32
  353. parallel: 8
  354. variables:
  355. IDF_TARGET: esp32
  356. TEST_DIR: examples
  357. build_examples_cmake_esp32s2:
  358. extends:
  359. - .build_cmake_template
  360. - .rules:build:example_test-esp32s2
  361. parallel: 7
  362. variables:
  363. IDF_TARGET: esp32s2
  364. TEST_DIR: examples
  365. build_examples_cmake_esp32s3:
  366. extends:
  367. - .build_cmake_template
  368. - .rules:build:example_test-esp32s3
  369. parallel: 11
  370. variables:
  371. IDF_TARGET: esp32s3
  372. TEST_DIR: examples
  373. build_examples_cmake_esp32c2:
  374. extends:
  375. - .build_cmake_template
  376. - .rules:build:example_test-esp32c2
  377. parallel: 7
  378. variables:
  379. IDF_TARGET: esp32c2
  380. TEST_DIR: examples
  381. build_examples_cmake_esp32c3:
  382. extends:
  383. - .build_cmake_template
  384. - .rules:build:example_test-esp32c3
  385. parallel: 9
  386. variables:
  387. IDF_TARGET: esp32c3
  388. TEST_DIR: examples
  389. build_examples_cmake_esp32c6:
  390. extends:
  391. - .build_cmake_template
  392. - .rules:build:example_test-esp32c6
  393. parallel: 11
  394. variables:
  395. IDF_TARGET: esp32c6
  396. TEST_DIR: examples
  397. build_examples_cmake_esp32h2:
  398. extends:
  399. - .build_cmake_template
  400. - .rules:build:example_test-esp32h2
  401. parallel: 9
  402. variables:
  403. IDF_TARGET: esp32h2
  404. TEST_DIR: examples
  405. build_examples_cmake_esp32p4:
  406. extends:
  407. - .build_cmake_template
  408. - .rules:build:example_test-esp32p4
  409. parallel: 4
  410. variables:
  411. IDF_TARGET: esp32p4
  412. TEST_DIR: examples
  413. build_clang_test_apps_esp32:
  414. extends:
  415. - .build_cmake_clang_template
  416. - .rules:build:custom_test-esp32
  417. variables:
  418. IDF_TARGET: esp32
  419. build_clang_test_apps_esp32s2:
  420. extends:
  421. - .build_cmake_clang_template
  422. - .rules:build:custom_test-esp32s2
  423. variables:
  424. IDF_TARGET: esp32s2
  425. build_clang_test_apps_esp32s3:
  426. extends:
  427. - .build_cmake_clang_template
  428. - .rules:build:custom_test-esp32s3
  429. variables:
  430. IDF_TARGET: esp32s3
  431. .build_clang_test_apps_riscv:
  432. extends:
  433. - .build_cmake_clang_template
  434. variables:
  435. # For RISCV clang generates '.linker-options' sections of type 'llvm_linker_options' in asm files.
  436. # See (https://llvm.org/docs/Extensions.html#linker-options-section-linker-options).
  437. # Binutils gas ignores them with warning.
  438. # TODO: LLVM-112, Use integrated assembler.
  439. TEST_BUILD_OPTS_EXTRA: "--ignore-warning-str 'Warning: unrecognized section type'"
  440. build_clang_test_apps_esp32c3:
  441. extends:
  442. - .build_clang_test_apps_riscv
  443. - .rules:build:custom_test-esp32c3
  444. variables:
  445. IDF_TARGET: esp32c3
  446. build_clang_test_apps_esp32c2:
  447. extends:
  448. - .build_clang_test_apps_riscv
  449. - .rules:build:custom_test-esp32c2
  450. variables:
  451. IDF_TARGET: esp32c2
  452. build_clang_test_apps_esp32c6:
  453. extends:
  454. - .build_clang_test_apps_riscv
  455. - .rules:build:custom_test-esp32c6
  456. # TODO: c6 builds fail in master due to missing headers
  457. allow_failure: true
  458. variables:
  459. IDF_TARGET: esp32c6
  460. .test_build_system_template:
  461. stage: host_test
  462. extends:
  463. - .build_template
  464. - .rules:build:check
  465. needs:
  466. - job: fast_template_app
  467. artifacts: false
  468. optional: true
  469. script:
  470. - ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
  471. - cd ${IDF_PATH}/tools/test_build_system
  472. - retry_failed git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
  473. - pytest --parallel-count ${CI_NODE_TOTAL:-1} --parallel-index ${CI_NODE_INDEX:-1}
  474. --work-dir ${CI_PROJECT_DIR}/test_build_system --junitxml=${CI_PROJECT_DIR}/XUNIT_RESULT.xml
  475. --ignore-result-files known_failure_cases/known_failure_cases.txt
  476. pytest_build_system:
  477. extends: .test_build_system_template
  478. parallel: 3
  479. artifacts:
  480. paths:
  481. - XUNIT_RESULT.xml
  482. - test_build_system
  483. when: always
  484. expire_in: 2 days
  485. reports:
  486. junit: XUNIT_RESULT.xml
  487. pytest_build_system_macos:
  488. extends:
  489. - .test_build_system_template
  490. - .before_script:build:macos
  491. - .rules:build:macos
  492. tags:
  493. - macos_shell
  494. parallel: 3
  495. artifacts:
  496. paths:
  497. - XUNIT_RESULT.xml
  498. - test_build_system
  499. when: always
  500. expire_in: 2 days
  501. reports:
  502. junit: XUNIT_RESULT.xml
  503. build_docker:
  504. extends:
  505. - .before_script:minimal
  506. - .rules:build:docker
  507. stage: host_test
  508. needs: []
  509. image: espressif/docker-builder:1
  510. tags:
  511. - build_docker_amd64_brno
  512. variables:
  513. DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
  514. script:
  515. - export LOCAL_CI_REPOSITORY_URL=$CI_REPOSITORY_URL
  516. - 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
  517. - if [ -n "$LOCAL_GIT_MIRROR" ]; then export LOCAL_CI_REPOSITORY_URL="${LOCAL_GIT_MIRROR}/${CI_PROJECT_PATH}"; fi
  518. - echo "Using repository at $LOCAL_CI_REPOSITORY_URL"
  519. - 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}"
  520. # Build
  521. - docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/
  522. # We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227.
  523. # The workaround mentioned there works, but leaves around directories which need to be cleaned up manually.
  524. # Therefore, build a copy of the example located inside the container.
  525. - docker run --rm --workdir /opt/esp/idf/examples/get-started/blink ${DOCKER_TMP_IMAGE_NAME} idf.py build
  526. # This job builds template app with permutations of targets and optimization levels
  527. build_template_app:
  528. extends:
  529. - .build_template_app_template
  530. - .rules:build
  531. stage: host_test
  532. needs:
  533. - job: fast_template_app
  534. artifacts: false