bsp_buildings.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. #
  2. # Copyright (c) 2025, RT-Thread Development Team
  3. #
  4. # SPDX-License-Identifier: Apache-2.0
  5. #
  6. # Change Logs:
  7. # Date Author Notes
  8. # 2025-03-22 Supperthomas 添加upload 上传编译固件
  9. # 2025-03-31 Hydevcode 将需要编译的bsp列表分离,根据修改的文件对相应的bsp编译
  10. name: RT-Thread BSP Static Build Check
  11. # Controls when the action will run. Triggers the workflow on push or pull request
  12. # events but only for the RT-Thread organization master branch
  13. on:
  14. # Runs at 16:00 UTC (BeiJing 00:00) every day
  15. schedule:
  16. - cron: '0 16 * * *'
  17. push:
  18. branches:
  19. - master
  20. paths-ignore:
  21. - documentation/**
  22. - '**/README.md'
  23. - '**/README_zh.md'
  24. pull_request:
  25. branches:
  26. - master
  27. paths-ignore:
  28. - documentation/**
  29. - '**/README.md'
  30. - '**/README_zh.md'
  31. repository_dispatch:
  32. types:
  33. - online-pkgs-static-building-trigger-event
  34. workflow_dispatch:
  35. permissions:
  36. contents: read # to fetch code (actions/checkout)
  37. jobs:
  38. generate-matrix:
  39. runs-on: ubuntu-22.04
  40. name: 🔍 Summary of Git Diff Changes
  41. outputs:
  42. filtered_matrix: ${{ steps.filter.outputs.filtered_matrix }}
  43. steps:
  44. - name: Checkout repo
  45. uses: actions/checkout@main
  46. with:
  47. persist-credentials: false
  48. fetch-depth: 0
  49. - name: Filter matrix
  50. id: filter
  51. run: |
  52. git config --global http.postBuffer 524288000
  53. git remote -v
  54. git fetch origin
  55. git branch
  56. git branch -a
  57. python tools/ci/git_diff_show.py origin/master
  58. raw_matrix=$(cat .github/ALL_BSP_COMPILE_TEMP.json)
  59. FILTER_CONDITION='.legs[]'
  60. filtered_matrix=$(jq -c "{legs: [$FILTER_CONDITION]}" <<< "$raw_matrix")
  61. echo "filtered_matrix=${filtered_matrix}" >> $GITHUB_OUTPUT
  62. echo ${filtered_matrix}
  63. build:
  64. runs-on: ubuntu-22.04
  65. needs: generate-matrix
  66. name: ${{ matrix.legs.RTT_BSP }}
  67. if: github.repository_owner == 'RT-Thread'
  68. strategy:
  69. fail-fast: false
  70. matrix: ${{ fromJson(needs.generate-matrix.outputs.filtered_matrix) }}
  71. steps:
  72. - uses: actions/checkout@main
  73. - name: Set up Python
  74. uses: actions/setup-python@main
  75. with:
  76. python-version: 3.8
  77. - name: Install Tools
  78. shell: bash
  79. run: |
  80. wget https://raw.githubusercontent.com/RT-Thread/env/master/install_ubuntu.sh
  81. chmod 777 install_ubuntu.sh
  82. ./install_ubuntu.sh
  83. pip install -r tools/requirements.txt
  84. git config --global http.postBuffer 524288000
  85. echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV
  86. echo "RTT_CC=gcc" >> $GITHUB_ENV
  87. echo "export PATH=~/.env/tools/scripts:$PATH" > ~/.env/env.sh
  88. - name: Cache GCC Arm Toolchain
  89. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm'}}
  90. id: cache-gcc-arm
  91. uses: actions/cache@main
  92. with:
  93. path: /opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi
  94. key: ${{ runner.os }}-arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi
  95. - name: Download Arm ToolChains
  96. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && (steps.cache-gcc-arm.outputs.cache-hit != 'true') }}
  97. shell: bash
  98. run: |
  99. wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.8/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz
  100. sudo tar -xf arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz -C /opt
  101. - name: Install Arm ToolChains2
  102. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm'}}
  103. shell: bash
  104. run: |
  105. /opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc --version
  106. echo "RTT_EXEC_PATH=/opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin" >> $GITHUB_ENV
  107. - name: Install LLVM-Arm ToolChains
  108. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'llvm-arm' && success() }}
  109. shell: bash
  110. run: |
  111. wget -q https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-16.0.0/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz
  112. sudo tar zxf LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz -C /opt
  113. sudo apt-get -qq install libncurses5 libncurses5-dev libncursesw5-dev
  114. /opt/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin/clang --version
  115. echo "RTT_CC=llvm-arm" >> $GITHUB_ENV
  116. echo "RTT_EXEC_PATH=/opt/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin" >> $GITHUB_ENV
  117. - name: Install AArch64 ToolChains
  118. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-aarch64' && success() }}
  119. shell: bash
  120. run: |
  121. wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.6/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz
  122. sudo tar -xf gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz -C /opt
  123. /opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc --version
  124. echo "RTT_EXEC_PATH=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin" >> $GITHUB_ENV
  125. - name: Install Mips ToolChains
  126. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-mips' && success() }}
  127. shell: bash
  128. run: |
  129. wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.1/mips-2016.05-7-mips-sde-elf-i686-pc-linux-gnu.tar.bz2
  130. sudo tar xjf mips-2016.05-7-mips-sde-elf-i686-pc-linux-gnu.tar.bz2 -C /opt
  131. /opt/mips-2016.05/bin/mips-sde-elf-gcc --version
  132. echo "RTT_EXEC_PATH=/opt/mips-2016.05/bin" >> $GITHUB_ENV
  133. - name: Install Riscv64-unknown-elf ToolChains
  134. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv64-unknown-elf' && success() }}
  135. run: |
  136. wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.4/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
  137. sudo tar zxf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
  138. /opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
  139. echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
  140. - name: Install Xuantie-900-gcc-elf-newlib Tools
  141. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-Xuantie-900-gcc-elf-newlib' && success() }}
  142. run: |
  143. wget -q https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1744884010580/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2-20250410.tar.gz
  144. sudo tar -zxvf Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2-20250410.tar.gz -C /opt
  145. /opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2/bin/riscv64-unknown-elf-gcc --version
  146. echo "RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2/bin" >> $GITHUB_ENV
  147. - name: Install k230 MUSL ToolChains
  148. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'riscv64-unknown-linux-musl-' && matrix.legs.RTT_BSP == 'K230' && success() }}
  149. run: |
  150. wget -q https://download.rt-thread.org/rt-smart/riscv64/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_251248.tar.bz2
  151. sudo tar xjf riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_251248.tar.bz2 -C /opt
  152. /opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/riscv64-unknown-linux-musl-gcc --version
  153. echo "RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
  154. - name: Install riscv32-unknown-elf Toolchains
  155. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'RISC-V-GCC-RV32' && success() }}
  156. run: |
  157. wget -q https://github.com/hpmicro/riscv-gnu-toolchain/releases/download/2022.05.15/riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz
  158. sudo tar zxf riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz -C /opt
  159. /opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-gcc --version
  160. echo "RTT_EXEC_PATH=/opt/riscv32-unknown-elf-newlib-multilib/bin/" >> $GITHUB_ENV
  161. - name: Install Riscv-none-embed ToolChains
  162. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv-none-embed' && success() }}
  163. run: |
  164. wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.5/xpack-riscv-none-embed-gcc-8.3.0-2.3-linux-x64.tar.gz
  165. sudo tar zxf xpack-riscv-none-embed-gcc-8.3.0-2.3-linux-x64.tar.gz -C /opt
  166. /opt/xpack-riscv-none-embed-gcc-8.3.0-2.3/bin/riscv-none-embed-gcc --version
  167. echo "RTT_EXEC_PATH=/opt/xpack-riscv-none-embed-gcc-8.3.0-2.3/bin" >> $GITHUB_ENV
  168. - name: Install riscv32-esp-elf ToolChains
  169. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv32-esp32' && success() }}
  170. run: |
  171. wget -q https://github.com/espressif/crosstool-NG/releases/download/esp-2022r1-RC1/riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz
  172. sudo tar xf riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz -C /opt
  173. /opt/riscv32-esp-elf/bin/riscv32-esp-elf-gcc --version
  174. pip3 install esptool
  175. echo "RTT_EXEC_PATH=/opt/riscv32-esp-elf/bin" >> $GITHUB_ENV
  176. - name: Install Arm Musl ToolChains
  177. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && matrix.legs.RTT_SMART_TOOL_CHAIN == 'arm-linux-musleabi' && success() }}
  178. shell: bash
  179. run: |
  180. wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2
  181. sudo tar xjf arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
  182. /opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin/arm-linux-musleabi-gcc --version
  183. - name: Install Simulator Tools
  184. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'gcc' && success() }}
  185. run: |
  186. sudo apt-get -qq install libsdl2-dev
  187. - name: Install i386-unknown-elf Tools
  188. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-i386-unknown-elf' && success() }}
  189. run: |
  190. wget -q https://github.com/zhkag/toolchains/releases/download/i386-unknown/i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2
  191. sudo tar -jxvf i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2 -C /opt
  192. /opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin/i386-unknown-elf-gcc --version
  193. echo "RTT_EXEC_PATH=/opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
  194. - name: Bsp Scons Compile
  195. if: ${{ success() }}
  196. shell: bash
  197. env:
  198. RTT_BSP: ${{ matrix.legs.RTT_BSP }}
  199. RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }}
  200. SRTT_BSP: ${{ join(matrix.legs.SUB_RTT_BSP, ',') }}
  201. run: |
  202. source ~/.env/env.sh
  203. python tools/ci/bsp_buildings.py
  204. - name: Upload output as artifact
  205. if: ${{ success() }}
  206. uses: actions/upload-artifact@main
  207. with:
  208. name: ${{ matrix.legs.RTT_BSP }}
  209. if-no-files-found: ignore
  210. path: output/
  211. - name: Post failure comment
  212. if: failure()
  213. run: |
  214. curl -X POST -H "Authorization: token ${{ secrets.RTTHREAD_GITHUB_TOKEN }}" \
  215. -d '{"body":"@${{ github.actor }}, Thank you for your contribution, but there was an error with the action. Could you please help check the BSP compilation issue? Thank you."}' \
  216. "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
  217. # 整合所有的output为一个文件夹
  218. collect-artifacts:
  219. needs: build
  220. runs-on: ubuntu-latest
  221. if: github.event_name != 'pull_request' #排除Pull request
  222. steps:
  223. #这里会下载所有产物
  224. - name: Download all artifacts
  225. uses: actions/download-artifact@main
  226. with:
  227. path: output/
  228. merge-multiple: true
  229. - run: ls -R output/
  230. - name: Upload combined output as artifact
  231. uses: actions/upload-artifact@main
  232. with:
  233. name: 00_all_bsp_output_${{ github.sha }}
  234. path: output/