bsp_buildings.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. outputs:
  41. filtered_matrix: ${{ steps.filter.outputs.filtered_matrix }}
  42. steps:
  43. - name: Checkout repo
  44. uses: actions/checkout@main
  45. with:
  46. sparse-checkout: .github/ALL_BSP_COMPILE.json
  47. persist-credentials: false
  48. - name: Read matrix config
  49. id: read-config
  50. run: |
  51. #读取ALL_BSP_COMPILE.json文件
  52. raw_matrix_base64=$(cat .github/ALL_BSP_COMPILE.json |egrep -v '^//'|base64 -w 0)
  53. echo "raw_matrix=$raw_matrix_base64" >> $GITHUB_OUTPUT
  54. - name: Get changed files
  55. id: changed_files
  56. if: github.event_name == 'pull_request'
  57. run: |
  58. changed_files=$(curl -s \
  59. "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \
  60. jq -r '.[].filename')
  61. prefix=$(echo "$changed_files" | cut -d'/' -f1 | sort -u )
  62. has_bsp=true
  63. for r in "$prefix"; do
  64. if [[ ! "$r" == "bsp" ]]; then
  65. has_bsp=false
  66. break
  67. fi
  68. done
  69. if [[ $has_bsp == true ]]; then
  70. changed_files=$(echo "${changed_files}"| cut -d'/' -f2 | sort -u| tr '\n' ',' | sed 's/,$//')
  71. echo "CHANGED_FILES=[${changed_files}]" >> $GITHUB_OUTPUT
  72. fi
  73. #获取修改文件的路径,如果有bsp以外的文件夹则编译全部bsp,否则获取对应文件夹名
  74. echo "${changed_files}"
  75. - name: Filter matrix
  76. id: filter
  77. run: |
  78. raw_matrix=$(echo "${{ steps.read-config.outputs.raw_matrix }}" | base64 --decode)
  79. CHANGED_FILES=${{ steps.changed_files.outputs.CHANGED_FILES }}
  80. CHANGED_FILES=$(echo "$CHANGED_FILES" | sed 's/\[\|\]//g')
  81. # 将修改的文件路径与ALL_BSP_COMPILE.json文件的SUB_RTT_BSP进行判断,判断是否包含
  82. filtered_matrix=[]
  83. echo "${CHANGED_FILES}"
  84. if [[ -z "$CHANGED_FILES" ]]; then
  85. FILTER_CONDITION='.legs[]'
  86. filtered_matrix=$(jq -c "{legs: [$FILTER_CONDITION]}" <<< "$raw_matrix")
  87. else
  88. CONDITIONS=$(echo "$CHANGED_FILES" | awk 'BEGIN { RS="," } { printf "contains(\"%s\") or ", $1 }')
  89. CONDITIONS=${CONDITIONS% or }
  90. FILTER_CONDITION=".legs[] | select(any(.SUB_RTT_BSP[]; $CONDITIONS))"
  91. filtered_matrix=$(jq -c "{legs: [$FILTER_CONDITION]}" <<< "$raw_matrix")
  92. fi
  93. echo "filtered_matrix=${filtered_matrix}" >> $GITHUB_OUTPUT
  94. echo ${filtered_matrix}
  95. build:
  96. runs-on: ubuntu-22.04
  97. needs: generate-matrix
  98. name: ${{ matrix.legs.RTT_BSP }}
  99. if: github.repository_owner == 'RT-Thread'
  100. strategy:
  101. fail-fast: false
  102. matrix: ${{ fromJson(needs.generate-matrix.outputs.filtered_matrix) }}
  103. steps:
  104. - uses: actions/checkout@main
  105. - name: Set up Python
  106. uses: actions/setup-python@main
  107. with:
  108. python-version: 3.8
  109. - name: Install Tools
  110. shell: bash
  111. run: |
  112. wget https://raw.githubusercontent.com/RT-Thread/env/master/install_ubuntu.sh
  113. chmod 777 install_ubuntu.sh
  114. ./install_ubuntu.sh
  115. pip install -r tools/requirements.txt
  116. git config --global http.postBuffer 524288000
  117. echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV
  118. echo "RTT_CC=gcc" >> $GITHUB_ENV
  119. echo "export PATH=~/.env/tools/scripts:$PATH" > ~/.env/env.sh
  120. - name: Cache GCC Arm Toolchain
  121. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm'}}
  122. id: cache-gcc-arm
  123. uses: actions/cache@main
  124. with:
  125. path: /opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi
  126. key: ${{ runner.os }}-arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi
  127. - name: Download Arm ToolChains
  128. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && (steps.cache-gcc-arm.outputs.cache-hit != 'true') }}
  129. shell: bash
  130. run: |
  131. 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
  132. sudo tar -xf arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz -C /opt
  133. - name: Install Arm ToolChains2
  134. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm'}}
  135. shell: bash
  136. run: |
  137. /opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc --version
  138. echo "RTT_EXEC_PATH=/opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/bin" >> $GITHUB_ENV
  139. - name: Install LLVM-Arm ToolChains
  140. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'llvm-arm' && success() }}
  141. shell: bash
  142. run: |
  143. 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
  144. sudo tar zxf LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz -C /opt
  145. sudo apt-get -qq install libncurses5 libncurses5-dev libncursesw5-dev
  146. /opt/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin/clang --version
  147. echo "RTT_CC=llvm-arm" >> $GITHUB_ENV
  148. echo "RTT_EXEC_PATH=/opt/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin" >> $GITHUB_ENV
  149. - name: Install AArch64 ToolChains
  150. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-aarch64' && success() }}
  151. shell: bash
  152. run: |
  153. 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
  154. sudo tar -xf gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz -C /opt
  155. /opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc --version
  156. echo "RTT_EXEC_PATH=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin" >> $GITHUB_ENV
  157. - name: Install Mips ToolChains
  158. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-mips' && success() }}
  159. shell: bash
  160. run: |
  161. 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
  162. sudo tar xjf mips-2016.05-7-mips-sde-elf-i686-pc-linux-gnu.tar.bz2 -C /opt
  163. /opt/mips-2016.05/bin/mips-sde-elf-gcc --version
  164. echo "RTT_EXEC_PATH=/opt/mips-2016.05/bin" >> $GITHUB_ENV
  165. - name: Install Riscv64-unknown-elf ToolChains
  166. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv64-unknown-elf' && success() }}
  167. run: |
  168. 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
  169. sudo tar zxf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
  170. /opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
  171. echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
  172. - name: Install Xuantie-900-gcc-elf-newlib Tools
  173. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-Xuantie-900-gcc-elf-newlib' && success() }}
  174. run: |
  175. 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
  176. sudo tar -zxvf Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2-20250410.tar.gz -C /opt
  177. /opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2/bin/riscv64-unknown-elf-gcc --version
  178. echo "RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2/bin" >> $GITHUB_ENV
  179. - name: Install k230 MUSL ToolChains
  180. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'riscv64-unknown-linux-musl-' && matrix.legs.RTT_BSP == 'K230' && success() }}
  181. run: |
  182. wget -q https://download.rt-thread.org/rt-smart/riscv64/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_251248.tar.bz2
  183. sudo tar xjf riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_251248.tar.bz2 -C /opt
  184. /opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/riscv64-unknown-linux-musl-gcc --version
  185. echo "RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
  186. - name: Install riscv32-unknown-elf Toolchains
  187. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'RISC-V-GCC-RV32' && success() }}
  188. run: |
  189. 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
  190. sudo tar zxf riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz -C /opt
  191. /opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-gcc --version
  192. echo "RTT_EXEC_PATH=/opt/riscv32-unknown-elf-newlib-multilib/bin/" >> $GITHUB_ENV
  193. - name: Install Riscv-none-embed ToolChains
  194. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv-none-embed' && success() }}
  195. run: |
  196. 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
  197. sudo tar zxf xpack-riscv-none-embed-gcc-8.3.0-2.3-linux-x64.tar.gz -C /opt
  198. /opt/xpack-riscv-none-embed-gcc-8.3.0-2.3/bin/riscv-none-embed-gcc --version
  199. echo "RTT_EXEC_PATH=/opt/xpack-riscv-none-embed-gcc-8.3.0-2.3/bin" >> $GITHUB_ENV
  200. - name: Install riscv32-esp-elf ToolChains
  201. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv32-esp32' && success() }}
  202. run: |
  203. 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
  204. sudo tar xf riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz -C /opt
  205. /opt/riscv32-esp-elf/bin/riscv32-esp-elf-gcc --version
  206. pip3 install esptool
  207. echo "RTT_EXEC_PATH=/opt/riscv32-esp-elf/bin" >> $GITHUB_ENV
  208. - name: Install Arm Musl ToolChains
  209. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && matrix.legs.RTT_SMART_TOOL_CHAIN == 'arm-linux-musleabi' && success() }}
  210. shell: bash
  211. run: |
  212. 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
  213. sudo tar xjf arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
  214. /opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin/arm-linux-musleabi-gcc --version
  215. - name: Install Simulator Tools
  216. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'gcc' && success() }}
  217. run: |
  218. sudo apt-get -qq install libsdl2-dev
  219. - name: Install i386-unknown-elf Tools
  220. if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-i386-unknown-elf' && success() }}
  221. run: |
  222. wget -q https://github.com/zhkag/toolchains/releases/download/i386-unknown/i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2
  223. sudo tar -jxvf i386-unknown-elf_for_x86_64-pc-linux-gnu_latest.tar.bz2 -C /opt
  224. /opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin/i386-unknown-elf-gcc --version
  225. echo "RTT_EXEC_PATH=/opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
  226. - name: Bsp Scons Compile
  227. if: ${{ success() }}
  228. shell: bash
  229. env:
  230. RTT_BSP: ${{ matrix.legs.RTT_BSP }}
  231. RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }}
  232. SRTT_BSP: ${{ join(matrix.legs.SUB_RTT_BSP, ',') }}
  233. run: |
  234. source ~/.env/env.sh
  235. python tools/ci/bsp_buildings.py
  236. - name: Upload output as artifact
  237. if: ${{ success() }}
  238. uses: actions/upload-artifact@main
  239. with:
  240. name: ${{ matrix.legs.RTT_BSP }}
  241. if-no-files-found: ignore
  242. path: output/
  243. - name: Post failure comment
  244. if: failure()
  245. run: |
  246. curl -X POST -H "Authorization: token ${{ secrets.RTTHREAD_GITHUB_TOKEN }}" \
  247. -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."}' \
  248. "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
  249. # 整合所有的output为一个文件夹
  250. collect-artifacts:
  251. needs: build
  252. runs-on: ubuntu-latest
  253. if: github.event_name != 'pull_request' #排除Pull request
  254. steps:
  255. #这里会下载所有产物
  256. - name: Download all artifacts
  257. uses: actions/download-artifact@main
  258. with:
  259. path: output/
  260. merge-multiple: true
  261. - run: ls -R output/
  262. - name: Upload combined output as artifact
  263. uses: actions/upload-artifact@main
  264. with:
  265. name: 00_all_bsp_output_${{ github.sha }}
  266. path: output/