build.yaml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. # Copyright (c) 2020-2021 Project CHIP Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. name: Builds
  15. on:
  16. push:
  17. pull_request:
  18. merge_group:
  19. workflow_dispatch:
  20. workflow_call:
  21. inputs:
  22. run-codeql:
  23. required: false
  24. type: boolean
  25. concurrency:
  26. group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
  27. cancel-in-progress: true
  28. env:
  29. CHIP_NO_LOG_TIMESTAMPS: true
  30. jobs:
  31. build_linux_gcc_debug:
  32. name: Build on Linux (gcc_debug)
  33. runs-on: ubuntu-latest
  34. if: github.actor != 'restyled-io[bot]'
  35. container:
  36. image: ghcr.io/project-chip/chip-build:1
  37. volumes:
  38. - "/tmp/log_output:/tmp/test_logs"
  39. options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0
  40. net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"
  41. steps:
  42. - name: Dump GitHub context
  43. env:
  44. GITHUB_CONTEXT: ${{ toJSON(github) }}
  45. run: echo "$GITHUB_CONTEXT"
  46. - name: Dump Concurrency context
  47. env:
  48. CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
  49. run: echo "$CONCURRENCY_CONTEXT"
  50. - name: Checkout
  51. uses: actions/checkout@v4
  52. - name: Try to ensure the directories for core dumping exist and we
  53. can write them.
  54. run: |
  55. mkdir /tmp/cores || true
  56. sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true
  57. - name: Checkout submodules & Bootstrap
  58. uses: ./.github/actions/checkout-submodules-and-bootstrap
  59. with:
  60. platform: linux
  61. - name: Initialize CodeQL
  62. if: ${{ inputs.run-codeql }}
  63. uses: github/codeql-action/init@v2
  64. with:
  65. languages: "cpp"
  66. - name: Setup Build
  67. run: scripts/build/gn_gen.sh --args="chip_config_memory_debug_checks=true chip_config_memory_debug_dmalloc=false"
  68. - name: Run Build
  69. run: scripts/run_in_build_env.sh "ninja -C ./out"
  70. - name: Run Tests
  71. run: scripts/tests/gn_tests.sh
  72. # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
  73. # TODO https://github.com/project-chip/connectedhomeip/issues/1512
  74. # - name: Run Code Coverage
  75. # if: ${{ contains('main', env.BUILD_TYPE) }}
  76. # run: scripts/tools/codecoverage.sh
  77. # - name: Upload Code Coverage
  78. # if: ${{ contains('main', env.BUILD_TYPE) }}
  79. # run: bash <(curl -s https://codecov.io/bash)
  80. - name: Setup Build Without Detail Logging
  81. run: scripts/build/gn_gen.sh --args="chip_detail_logging=false"
  82. - name: Run Build Without Detail Logging
  83. run: scripts/run_in_build_env.sh "ninja -C ./out"
  84. - name: Setup Build Without Progress Logging
  85. run: scripts/build/gn_gen.sh --args="chip_detail_logging=false chip_progress_logging=false"
  86. - name: Run Build Without Progress Logging
  87. run: scripts/run_in_build_env.sh "ninja -C ./out"
  88. - name: Setup Build Without Error Logging
  89. run: scripts/build/gn_gen.sh --args="chip_detail_logging=false chip_progress_logging=false chip_error_logging=false"
  90. - name: Run Build Without Error Logging
  91. run: scripts/run_in_build_env.sh "ninja -C ./out"
  92. - name: Uploading core files
  93. uses: actions/upload-artifact@v3
  94. if: ${{ failure() && !env.ACT }}
  95. with:
  96. name: crash-core-linux-gcc-debug
  97. path: /tmp/cores/
  98. # Cores are big; don't hold on to them too long.
  99. retention-days: 5
  100. - name: Perform CodeQL Analysis
  101. if: ${{ inputs.run-codeql }}
  102. uses: ./.github/actions/perform-codeql-analysis
  103. with:
  104. language: cpp
  105. # OBJDIR on linux is > 10K files and takes more than 50 minutes to upload, usually
  106. # having the job timeout.
  107. #
  108. # If re-enabling, some subset of this should be picked
  109. #
  110. # - name: Uploading objdir for debugging
  111. # uses: actions/upload-artifact@v3
  112. # if: ${{ failure() && !env.ACT }}
  113. # with:
  114. # name: crash-objdir-linux-gcc-debug
  115. # path: out/
  116. # # objdirs are big; don't hold on to them too long.
  117. # retention-days: 5
  118. build_linux:
  119. name: Build on Linux (fake, gcc_release, clang, simulated)
  120. runs-on: ubuntu-latest
  121. if: github.actor != 'restyled-io[bot]'
  122. container:
  123. image: ghcr.io/project-chip/chip-build:1
  124. volumes:
  125. - "/tmp/log_output:/tmp/test_logs"
  126. options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0
  127. net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"
  128. steps:
  129. - name: Dump GitHub context
  130. env:
  131. GITHUB_CONTEXT: ${{ toJSON(github) }}
  132. run: echo "$GITHUB_CONTEXT"
  133. - name: Dump Concurrency context
  134. env:
  135. CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
  136. run: echo "$CONCURRENCY_CONTEXT"
  137. - name: Checkout
  138. uses: actions/checkout@v4
  139. - name: Try to ensure the directories for core dumping exist and we
  140. can write them.
  141. run: |
  142. mkdir /tmp/cores || true
  143. sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true
  144. - name: Checkout submodules & Bootstrap
  145. uses: ./.github/actions/checkout-submodules-and-bootstrap
  146. with:
  147. platform: linux
  148. - name: Initialize CodeQL
  149. if: ${{ inputs.run-codeql }}
  150. uses: github/codeql-action/init@v2
  151. with:
  152. languages: "cpp"
  153. - name: Setup and Build Simulated Device
  154. run: |
  155. BUILD_TYPE=simulated
  156. GN_ARGS='chip_tests_zap_config="app1" chip_project_config_include_dirs=["../../examples/placeholder/linux/apps/app1/include", "../../config/standalone"] chip_config_network_layer_ble=false'
  157. CHIP_ROOT_PATH=examples/placeholder/linux
  158. CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_gen.sh --args="$GN_ARGS"
  159. scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
  160. - name: Setup Build, Run Build and Run Tests
  161. run: |
  162. BUILD_TYPE=gcc_release scripts/build/gn_gen.sh --args="is_debug=false"
  163. scripts/run_in_build_env.sh "ninja -C ./out/gcc_release"
  164. BUILD_TYPE=gcc_release scripts/tests/gn_tests.sh
  165. - name: Clean output
  166. run: rm -rf ./out
  167. - name: Run Tests with sanitizers
  168. env:
  169. LSAN_OPTIONS: detect_leaks=1
  170. run: |
  171. for BUILD_TYPE in asan tsan ubsan; do
  172. case $BUILD_TYPE in
  173. "asan") GN_ARGS='is_clang=true is_asan=true';;
  174. "msan") GN_ARGS='is_clang=true is_msan=true';;
  175. "tsan") GN_ARGS='is_clang=true is_tsan=true chip_enable_wifi=false';;
  176. "ubsan") GN_ARGS='is_clang=true is_ubsan=true';;
  177. esac
  178. rm -rf ./out/sanitizers
  179. BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
  180. BUILD_TYPE=sanitizers scripts/tests/gn_tests.sh
  181. done
  182. - name: Ensure codegen is done for sanitize
  183. run: |
  184. ./scripts/run_in_build_env.sh "./scripts/run_codegen_targets.sh out/sanitizers"
  185. - name: Clang-tidy validation
  186. run: |
  187. ./scripts/run_in_build_env.sh \
  188. "./scripts/run-clang-tidy-on-compile-commands.py \
  189. --compile-database out/sanitizers/compile_commands.json \
  190. --file-exclude-regex '/(repo|zzz_generated|lwip/standalone)/|-ReadImpl|-InvokeSubscribeImpl' \
  191. check \
  192. "
  193. - name: Clean output
  194. run: rm -rf ./out
  195. - name: Build using build_examples.py
  196. run: |
  197. ./scripts/run_in_build_env.sh \
  198. "./scripts/build/build_examples.py \
  199. --target linux-x64-minmdns-ipv6only-clang \
  200. --target linux-x64-rpc-console \
  201. build \
  202. "
  203. - name: Create a pre-generate directory and ensure compile-time codegen would fail
  204. run: |
  205. ./scripts/run_in_build_env.sh "./scripts/codepregen.py ./zzz_pregenerated"
  206. mv scripts/codegen.py scripts/codegen.py.renamed
  207. - name: Clean output
  208. run: rm -rf ./out
  209. - name: Build using build_examples.py (pregen)
  210. run: |
  211. ./scripts/run_in_build_env.sh \
  212. "./scripts/build/build_examples.py \
  213. --target linux-x64-all-clusters-ipv6only-clang \
  214. --target linux-x64-chip-tool-ipv6only-clang \
  215. --pregen-dir ./zzz_pregenerated \
  216. build \
  217. "
  218. - name: Check no code generation in output
  219. run: |
  220. CNT=$(find out -name "CHIPClusters.h" | wc -l)
  221. if [ "${CNT}" != "0" ]; then
  222. echo "ERROR: found unexpected generated files:"
  223. find out -name "CHIPClusters.h"
  224. exit 1
  225. fi
  226. - name: Undo code pre-generation changes (make compile time codegen work again)
  227. run: |
  228. rm -rf ./zzz_pregenerated
  229. mv scripts/codegen.py.renamed scripts/codegen.py
  230. - name: Run fake linux tests with build_examples
  231. run: |
  232. ./scripts/run_in_build_env.sh \
  233. "./scripts/build/build_examples.py --target linux-fake-tests build"
  234. - name: Perform CodeQL Analysis
  235. if: ${{ inputs.run-codeql }}
  236. uses: ./.github/actions/perform-codeql-analysis
  237. with:
  238. language: cpp
  239. - name: Uploading core files
  240. uses: actions/upload-artifact@v3
  241. if: ${{ failure() && !env.ACT }}
  242. with:
  243. name: crash-core-linux
  244. path: /tmp/cores/
  245. # Cores are big; don't hold on to them too long.
  246. retention-days: 5
  247. # OBJDIR on linux is > 10K files and takes more than 50 minutes to upload, usually
  248. # having the job timeout.
  249. #
  250. # If re-enabling, some subset of this should be picked
  251. #
  252. # - name: Uploading objdir for debugging
  253. # uses: actions/upload-artifact@v3
  254. # if: ${{ failure() && !env.ACT }}
  255. # with:
  256. # name: crash-objdir-linux
  257. # path: out/
  258. # # objdirs are big; don't hold on to them too long.
  259. # retention-days: 5
  260. build_linux_python_lib:
  261. name: Build on Linux (python_lib)
  262. runs-on: ubuntu-latest
  263. if: github.actor != 'restyled-io[bot]'
  264. container:
  265. image: ghcr.io/project-chip/chip-build:1
  266. volumes:
  267. - "/tmp/log_output:/tmp/test_logs"
  268. options: --sysctl "net.ipv6.conf.all.disable_ipv6=0
  269. net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"
  270. steps:
  271. - name: Dump GitHub context
  272. env:
  273. GITHUB_CONTEXT: ${{ toJSON(github) }}
  274. run: echo "$GITHUB_CONTEXT"
  275. - name: Dump Concurrency context
  276. env:
  277. CONCURRENCY_CONTEXT: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
  278. run: echo "$CONCURRENCY_CONTEXT"
  279. - name: Checkout
  280. uses: actions/checkout@v4
  281. - name: Checkout submodules & Bootstrap
  282. uses: ./.github/actions/checkout-submodules-and-bootstrap
  283. with:
  284. platform: linux
  285. - name: Setup Build, Run Build and Run Tests
  286. run: |
  287. scripts/build/gn_gen.sh --args="enable_rtti=true enable_pylib=true chip_config_memory_debug_checks=false chip_config_memory_debug_dmalloc=false"
  288. scripts/run_in_build_env.sh "ninja -C ./out"
  289. scripts/tests/gn_tests.sh
  290. - name: Run Python library specific unit tests
  291. run: |
  292. scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_core-0.0-cp37-abi3-linux_x86_64.whl'
  293. scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_clusters-0.0-py3-none-any.whl'
  294. scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_repl-0.0-py3-none-any.whl'
  295. scripts/run_in_build_env.sh '(cd src/controller/python/test/unit_tests/ && python3 -m unittest -v)'
  296. - name: Run Python Setup Payload Generator Test
  297. run: |
  298. scripts/run_in_build_env.sh 'scripts/examples/gn_build_example.sh examples/chip-tool out/'
  299. scripts/run_in_build_env.sh 'pip3 install -r src/setup_payload/python/requirements.txt'
  300. scripts/run_in_build_env.sh 'python3 src/setup_payload/tests/run_python_setup_payload_gen_test.py out/chip-tool'
  301. build_darwin:
  302. name: Build on Darwin (clang, python_lib, simulated)
  303. runs-on: macos-latest
  304. if: github.actor != 'restyled-io[bot]'
  305. steps:
  306. - name: Checkout
  307. uses: actions/checkout@v4
  308. - name: Checkout submodules & Bootstrap
  309. uses: ./.github/actions/checkout-submodules-and-bootstrap
  310. with:
  311. platform: darwin
  312. - name: Try to ensure the directory for diagnostic log collection exists
  313. run: |
  314. mkdir -p ~/Library/Logs/DiagnosticReports || true
  315. - name: Initialize CodeQL
  316. if: ${{ inputs.run-codeql }}
  317. uses: github/codeql-action/init@v2
  318. with:
  319. languages: "cpp"
  320. - name: Setup and Build Simulated Device
  321. run: |
  322. BUILD_TYPE=simulated
  323. GN_ARGS='chip_tests_zap_config="app1" chip_project_config_include_dirs=["../../examples/placeholder/linux/apps/app1/include", "../../config/standalone"] chip_config_network_layer_ble=false'
  324. CHIP_ROOT_PATH=examples/placeholder/linux
  325. CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_gen.sh --args="$GN_ARGS"
  326. scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
  327. - name: Setup Build, Run Build and Run Tests
  328. # We can't enable leak checking here in LSAN_OPTIONS, because on
  329. # Darwin that's only supported with a new enough clang, and we're
  330. # not building with the pigweed clang here.
  331. run: |
  332. for BUILD_TYPE in default python_lib; do
  333. case $BUILD_TYPE in
  334. # We want to build various standalone example apps
  335. # (similar to what examples-linux-standalone.yaml
  336. # does), so use target_os="all" to get those picked
  337. # up as part of the "unified" build. But then to
  338. # save CI resources we want to exclude the
  339. # "host clang" build, which uses the pigweed
  340. # clang.
  341. "default") GN_ARGS='target_os="all" is_asan=true enable_host_clang_build=false';;
  342. "python_lib") GN_ARGS='enable_rtti=true enable_pylib=true';;
  343. esac
  344. BUILD_TYPE=$BUILD_TYPE scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
  345. scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
  346. BUILD_TYPE=$BUILD_TYPE scripts/tests/gn_tests.sh
  347. done
  348. - name: Ensure codegen is done for sanitize
  349. run: |
  350. ./scripts/run_in_build_env.sh "./scripts/run_codegen_targets.sh out/default"
  351. - name: Clang-tidy validation
  352. run: |
  353. ./scripts/run_in_build_env.sh \
  354. "./scripts/run-clang-tidy-on-compile-commands.py \
  355. --compile-database out/default/compile_commands.json \
  356. check \
  357. "
  358. - name: Uploading diagnostic logs
  359. uses: actions/upload-artifact@v3
  360. if: ${{ failure() && !env.ACT }}
  361. with:
  362. name: crash-log-darwin
  363. path: ~/Library/Logs/DiagnosticReports/
  364. - name: Perform CodeQL Analysis
  365. if: ${{ inputs.run-codeql }}
  366. uses: ./.github/actions/perform-codeql-analysis
  367. with:
  368. language: cpp
  369. # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
  370. # TODO https://github.com/project-chip/connectedhomeip/issues/1512
  371. build_linux_gcc_coverage:
  372. name: Build on Linux (coverage)
  373. runs-on: ubuntu-latest
  374. if: github.actor != 'restyled-io[bot]'
  375. container:
  376. image: ghcr.io/project-chip/chip-build:1
  377. volumes:
  378. - "/tmp/log_output:/tmp/test_logs"
  379. options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0
  380. net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1"
  381. steps:
  382. - name: Checkout
  383. uses: actions/checkout@v4
  384. - name: Checkout submodules & Bootstrap
  385. uses: ./.github/actions/checkout-submodules-and-bootstrap
  386. with:
  387. platform: linux
  388. - name: Run Build Coverage
  389. run: ./scripts/build_coverage.sh