build.yml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. name: Build sub target
  2. on:
  3. workflow_call:
  4. secrets:
  5. coverity_api_token:
  6. inputs:
  7. container_name:
  8. type: string
  9. default: tools
  10. target:
  11. required: true
  12. type: string
  13. subtarget:
  14. required: true
  15. type: string
  16. testing:
  17. type: boolean
  18. build_toolchain:
  19. type: boolean
  20. include_feeds:
  21. type: boolean
  22. build_full:
  23. type: boolean
  24. build_kernel:
  25. type: boolean
  26. build_all_modules:
  27. type: boolean
  28. build_all_kmods:
  29. type: boolean
  30. build_all_boards:
  31. type: boolean
  32. use_openwrt_container:
  33. type: boolean
  34. default: true
  35. coverity_project_name:
  36. type: string
  37. default: OpenWrt
  38. coverity_check_packages:
  39. type: string
  40. coverity_compiler_template_list:
  41. type: string
  42. default: >-
  43. arm-openwrt-linux-gcc
  44. coverity_force_compile_packages:
  45. type: string
  46. default: >-
  47. curl
  48. libnl
  49. mbedtls
  50. wolfssl
  51. openssl
  52. build_external_toolchain:
  53. type: boolean
  54. upload_external_toolchain:
  55. type: boolean
  56. use_ccache_cache:
  57. type: boolean
  58. default: true
  59. ccache_type:
  60. type: string
  61. default: kernel
  62. upload_ccache_cache:
  63. type: boolean
  64. permissions:
  65. contents: read
  66. jobs:
  67. setup_build:
  68. name: Setup build ${{ inputs.target }}/${{ inputs.subtarget }}
  69. runs-on: ubuntu-latest
  70. outputs:
  71. owner_lc: ${{ steps.lower_owner.outputs.owner_lc }}
  72. container_tag: ${{ steps.determine_tools_container.outputs.container_tag }}
  73. container_name: ${{ steps.determine_tools_container.outputs.container_name }}
  74. steps:
  75. - name: Checkout
  76. uses: actions/checkout@v3
  77. - name: Set lower case owner name
  78. id: lower_owner
  79. run: |
  80. OWNER_LC=$(echo "${{ github.repository_owner }}" \
  81. | tr '[:upper:]' '[:lower:]')
  82. if [ ${{ inputs.use_openwrt_container }} == "true" ]; then
  83. OWNER_LC=openwrt
  84. fi
  85. echo "owner_lc=$OWNER_LC" >> $GITHUB_OUTPUT
  86. # Per branch tools container tag
  87. # By default stick to latest
  88. # For official test targetting openwrt stable branch
  89. # Get the branch or parse the tag and push dedicated tools containers
  90. # For local test to use the correct container for stable release testing
  91. # you need to use for the branch name a prefix of openwrt-[0-9][0-9].[0-9][0-9]-
  92. - name: Determine tools container tag
  93. id: determine_tools_container
  94. run: |
  95. CONTAINER_NAME=${{ inputs.container_name }}
  96. CONTAINER_TAG=latest
  97. if [ -n "${{ github.base_ref }}" ]; then
  98. if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
  99. CONTAINER_TAG="${{ github.base_ref }}"
  100. fi
  101. elif [ ${{ github.ref_type }} == "branch" ]; then
  102. if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
  103. CONTAINER_TAG=${{ github.ref_name }}
  104. elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
  105. CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
  106. fi
  107. elif [ ${{ github.ref_type }} == "tag" ]; then
  108. if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
  109. CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
  110. fi
  111. fi
  112. if [ "$CONTAINER_NAME" = "toolchain" ]; then
  113. GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
  114. GHCR_HEADER="Authorization: Bearer ${GHCR_TOKEN}"
  115. GHCR_MANIFEST_LINK=https://ghcr.io/v2/${{ steps.lower_owner.outputs.owner_lc }}/${{ inputs.container_name }}/manifests/${{ inputs.target }}-${{ inputs.subtarget }}-"$CONTAINER_TAG"
  116. # Check if container exist
  117. if [ $(curl -s -o /dev/null -w "%{http_code}" -H "$GHCR_HEADER" -I "$GHCR_MANIFEST_LINK") = 200 ]; then
  118. CONTAINER_TAG=${{ inputs.target }}-${{ inputs.subtarget }}-"$CONTAINER_TAG"
  119. else
  120. CONTAINER_NAME=tools
  121. fi
  122. fi
  123. echo "Tools container to use $CONTAINER_NAME:$CONTAINER_TAG"
  124. echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
  125. echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT
  126. build:
  127. name: Build ${{ inputs.target }}/${{ inputs.subtarget }}
  128. needs: setup_build
  129. runs-on: ubuntu-latest
  130. container: ghcr.io/${{ needs.setup_build.outputs.owner_lc }}/${{ needs.setup_build.outputs.container_name }}:${{ needs.setup_build.outputs.container_tag }}
  131. permissions:
  132. contents: read
  133. packages: read
  134. actions: write
  135. steps:
  136. - name: Checkout master directory
  137. uses: actions/checkout@v3
  138. with:
  139. path: openwrt
  140. - name: Checkout packages feed
  141. if: inputs.include_feeds == true
  142. uses: actions/checkout@v3
  143. with:
  144. repository: openwrt/packages
  145. path: openwrt/feeds/packages
  146. - name: Checkout luci feed
  147. if: inputs.include_feeds == true
  148. uses: actions/checkout@v3
  149. with:
  150. repository: openwrt/luci
  151. path: openwrt/feeds/luci
  152. - name: Checkout routing feed
  153. if: inputs.include_feeds == true
  154. uses: actions/checkout@v3
  155. with:
  156. repository: openwrt/routing
  157. path: openwrt/feeds/routing
  158. - name: Checkout telephony feed
  159. if: inputs.include_feeds == true
  160. uses: actions/checkout@v3
  161. with:
  162. repository: openwrt/telephony
  163. path: openwrt/feeds/telephony
  164. - name: Parse toolchain file
  165. if: inputs.build_toolchain == false
  166. id: parse-toolchain
  167. working-directory: openwrt
  168. run: |
  169. if [ -d /external-toolchain/ ]; then
  170. echo "toolchain-type=external_container" >> $GITHUB_OUTPUT
  171. exit 0
  172. fi
  173. TOOLCHAIN_PATH=snapshots
  174. if [ -n "${{ github.base_ref }}" ]; then
  175. if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
  176. major_ver="$(echo ${{ github.base_ref }} | sed 's/^openwrt-/v/')"
  177. fi
  178. elif [ "${{ github.ref_type }}" = "branch" ]; then
  179. if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
  180. major_ver="$(echo ${{ github.ref_name }} | sed 's/^openwrt-/v/')"
  181. elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
  182. major_ver="$(echo ${{ github.ref_name }} | sed 's/^openwrt-\([0-9][0-9]\.[0-9][0-9]\)-.*/v\1/')"
  183. fi
  184. elif [ "${{ github.ref_type }}" = "tag" ]; then
  185. if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
  186. major_ver="$(echo ${{ github.ref_name }} | sed 's/^\(v[0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
  187. fi
  188. fi
  189. if [ -n "$major_ver" ]; then
  190. git fetch --tags -f
  191. latest_tag="$(git tag --sort=-creatordate -l $major_ver* | head -n1)"
  192. if [ -n "$latest_tag" ]; then
  193. TOOLCHAIN_PATH=releases/$(echo $latest_tag | sed 's/^v//')
  194. fi
  195. fi
  196. SUMS_FILE="https://downloads.cdn.openwrt.org/$TOOLCHAIN_PATH/targets/${{ inputs.target }}/${{ inputs.subtarget }}/sha256sums"
  197. if curl $SUMS_FILE | grep -q ".*openwrt-toolchain.*tar.xz"; then
  198. TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-toolchain.*tar.xz")"
  199. TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
  200. echo "toolchain-type=external_toolchain" >> $GITHUB_OUTPUT
  201. elif curl $SUMS_FILE | grep -q ".*openwrt-sdk.*tar.xz"; then
  202. TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-sdk.*tar.xz")"
  203. TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-sdk.*\).tar.xz/\1/p')
  204. echo "toolchain-type=external_sdk" >> $GITHUB_OUTPUT
  205. else
  206. echo "toolchain-type=internal" >> $GITHUB_OUTPUT
  207. fi
  208. echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
  209. echo "TOOLCHAIN_PATH=$TOOLCHAIN_PATH" >> "$GITHUB_ENV"
  210. - name: Download and extract ccache cache from s3
  211. id: restore-ccache-cache-s3
  212. if: inputs.use_ccache_cache == true
  213. working-directory: openwrt
  214. run: |
  215. ENDPOINT=https://storage.googleapis.com
  216. BUCKET=openwrt-ci-cache
  217. CCACHE_TAR=ccache-${{ inputs.ccache_type }}-${{ inputs.target }}-${{ inputs.subtarget }}.tar
  218. if curl -o /dev/null -s --head --fail $ENDPOINT/$BUCKET/$CCACHE_TAR; then
  219. wget -O - $ENDPOINT/$BUCKET/$CCACHE_TAR | tar -xf -
  220. echo "cache-hit=true" >> $GITHUB_OUTPUT
  221. fi
  222. - name: Fix permission
  223. run: |
  224. chown -R buildbot:buildbot openwrt
  225. - name: Prepare prebuilt tools
  226. shell: su buildbot -c "sh -e {0}"
  227. working-directory: openwrt
  228. run: |
  229. mkdir -p staging_dir build_dir
  230. ln -s /prebuilt_tools/staging_dir/host staging_dir/host
  231. ln -s /prebuilt_tools/build_dir/host build_dir/host
  232. ./scripts/ext-tools.sh --refresh
  233. - name: Update & Install feeds
  234. if: inputs.include_feeds == true
  235. shell: su buildbot -c "sh -e {0}"
  236. working-directory: openwrt
  237. run: |
  238. ./scripts/feeds update -a
  239. ./scripts/feeds install -a
  240. - name: Restore ccache cache
  241. id: restore-ccache-cache
  242. if: inputs.use_ccache_cache == true && steps.restore-ccache-cache-s3.outputs.cache-hit != 'true'
  243. uses: actions/cache/restore@v3
  244. with:
  245. path: openwrt/.ccache
  246. key: ccache-${{ inputs.ccache_type }}-${{ inputs.target }}/${{ inputs.subtarget }}-${{ hashFiles('openwrt/include/kernel-**') }}
  247. restore-keys: |
  248. ccache-${{ inputs.ccache_type }}-${{ inputs.target }}/${{ inputs.subtarget }}-
  249. - name: Import GPG keys
  250. shell: su buildbot -c "sh -e {0}"
  251. if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type != 'internal' && steps.parse-toolchain.outputs.toolchain-type != 'external_container'
  252. run: gpg --receive-keys 0xCD84BCED626471F1 0x1D53D1877742E911 0xCD54E82DADB3684D
  253. - name: Download external toolchain/sdk
  254. if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type != 'internal' && steps.parse-toolchain.outputs.toolchain-type != 'external_container'
  255. shell: su buildbot -c "sh -e {0}"
  256. working-directory: openwrt
  257. run: |
  258. wget https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ inputs.target }}/${{ inputs.subtarget }}/${{ env.TOOLCHAIN_FILE }}.tar.xz
  259. wget https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ inputs.target }}/${{ inputs.subtarget }}/sha256sums.asc
  260. wget https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ inputs.target }}/${{ inputs.subtarget }}/sha256sums
  261. gpg --with-fingerprint --verify sha256sums.asc
  262. sha256sum --check --ignore-missing sha256sums
  263. tar --xz -xf ${{ env.TOOLCHAIN_FILE }}.tar.xz
  264. rm ${{ env.TOOLCHAIN_FILE }}.tar.xz sha256sums
  265. - name: Configure testing kernel
  266. if: inputs.testing == true
  267. shell: su buildbot -c "sh -e {0}"
  268. working-directory: openwrt
  269. run: |
  270. echo CONFIG_TESTING_KERNEL=y >> .config
  271. - name: Configure all kernel modules
  272. if: inputs.build_all_kmods == true
  273. shell: su buildbot -c "sh -e {0}"
  274. working-directory: openwrt
  275. run: |
  276. echo CONFIG_ALL_KMODS=y >> .config
  277. - name: Configure all modules
  278. if: inputs.build_all_modules == true
  279. shell: su buildbot -c "sh -e {0}"
  280. working-directory: openwrt
  281. run: |
  282. echo CONFIG_ALL=y >> .config
  283. - name: Configure all boards
  284. if: inputs.build_all_boards == true
  285. shell: su buildbot -c "sh -e {0}"
  286. working-directory: openwrt
  287. run: |
  288. echo CONFIG_TARGET_MULTI_PROFILE=y >> .config
  289. echo CONFIG_TARGET_PER_DEVICE_ROOTFS=y >> .config
  290. echo CONFIG_TARGET_ALL_PROFILES=y >> .config
  291. # ccache for some reason have problem detecting compiler type
  292. # with external toolchain. This cause the complete malfunction
  293. # of ccache with the result of tons of unsupported compiler
  294. # option error.
  295. # To fix this force compiler type to gcc.
  296. - name: Configure ccache and apply fixes
  297. if: inputs.use_ccache_cache == true
  298. shell: su buildbot -c "sh -e {0}"
  299. working-directory: openwrt
  300. env:
  301. SYSTEM_CCACHE_CONF: staging_dir/host/etc/ccache.conf
  302. run: |
  303. touch $SYSTEM_CCACHE_CONF
  304. echo compiler_type=gcc >> $SYSTEM_CCACHE_CONF
  305. echo CONFIG_CCACHE=y >> .config
  306. - name: Configure external toolchain in container
  307. if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_container'
  308. shell: su buildbot -c "sh -e {0}"
  309. working-directory: openwrt
  310. run: |
  311. echo CONFIG_DEVEL=y >> .config
  312. echo CONFIG_AUTOREMOVE=y >> .config
  313. ./scripts/ext-toolchain.sh \
  314. --toolchain /external-toolchain/$(ls /external-toolchain/ | grep openwrt-toolchain)/toolchain-* \
  315. --overwrite-config \
  316. --config ${{ inputs.target }}/${{ inputs.subtarget }}
  317. - name: Configure external toolchain
  318. if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_toolchain'
  319. shell: su buildbot -c "sh -e {0}"
  320. working-directory: openwrt
  321. run: |
  322. echo CONFIG_DEVEL=y >> .config
  323. echo CONFIG_AUTOREMOVE=y >> .config
  324. ./scripts/ext-toolchain.sh \
  325. --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
  326. --overwrite-config \
  327. --config ${{ inputs.target }}/${{ inputs.subtarget }}
  328. - name: Adapt external sdk to external toolchain format
  329. if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk'
  330. shell: su buildbot -c "sh -e {0}"
  331. working-directory: openwrt
  332. run: |
  333. TOOLCHAIN_DIR=${{ env.TOOLCHAIN_FILE }}/staging_dir/$(ls ${{ env.TOOLCHAIN_FILE }}/staging_dir | grep toolchain)
  334. TOOLCHAIN_BIN=$TOOLCHAIN_DIR/bin
  335. OPENWRT_DIR=$(pwd)
  336. # Find target name from toolchain info.mk
  337. GNU_TARGET_NAME=$(cat $TOOLCHAIN_DIR/info.mk | grep TARGET_CROSS | sed 's/^TARGET_CROSS=\(.*\)-$/\1/')
  338. cd $TOOLCHAIN_BIN
  339. # Revert sdk wrapper scripts applied to all the bins
  340. for app in $(find . -name "*.bin"); do
  341. TARGET_APP=$(echo $app | sed 's/\.\/\.\(.*\)\.bin/\1/')
  342. rm $TARGET_APP
  343. mv .$TARGET_APP.bin $TARGET_APP
  344. done
  345. # Setup the wrapper script in the sdk toolchain dir simulating an external toolchain build
  346. cp $OPENWRT_DIR/target/toolchain/files/wrapper.sh $GNU_TARGET_NAME-wrapper.sh
  347. for app in cc gcc g++ c++ cpp ld as ; do
  348. [ -f $GNU_TARGET_NAME-$app ] && mv $GNU_TARGET_NAME-$app $GNU_TARGET_NAME-$app.bin
  349. ln -sf $GNU_TARGET_NAME-wrapper.sh $GNU_TARGET_NAME-$app
  350. done
  351. - name: Configure external toolchain with sdk
  352. if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk'
  353. shell: su buildbot -c "sh -e {0}"
  354. working-directory: openwrt
  355. run: |
  356. echo CONFIG_DEVEL=y >> .config
  357. echo CONFIG_AUTOREMOVE=y >> .config
  358. ./scripts/ext-toolchain.sh \
  359. --toolchain ${{ env.TOOLCHAIN_FILE }}/staging_dir/toolchain-* \
  360. --overwrite-config \
  361. --config ${{ inputs.target }}/${{ inputs.subtarget }}
  362. - name: Configure internal toolchain
  363. if: inputs.build_toolchain == true || steps.parse-toolchain.outputs.toolchain-type == 'internal'
  364. shell: su buildbot -c "sh -e {0}"
  365. working-directory: openwrt
  366. run: |
  367. echo CONFIG_DEVEL=y >> .config
  368. echo CONFIG_AUTOREMOVE=y >> .config
  369. echo "CONFIG_TARGET_${{ inputs.target }}=y" >> .config
  370. echo "CONFIG_TARGET_${{ inputs.target }}_${{ inputs.subtarget }}=y" >> .config
  371. make defconfig
  372. - name: Show configuration
  373. shell: su buildbot -c "sh -e {0}"
  374. working-directory: openwrt
  375. run: ./scripts/diffconfig.sh
  376. - name: Build tools
  377. shell: su buildbot -c "sh -e {0}"
  378. working-directory: openwrt
  379. run: make tools/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  380. - name: Build toolchain
  381. shell: su buildbot -c "sh -e {0}"
  382. working-directory: openwrt
  383. run: make toolchain/install -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  384. - name: Build Kernel
  385. if: inputs.build_kernel == true
  386. shell: su buildbot -c "sh -e {0}"
  387. working-directory: openwrt
  388. run: make target/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  389. - name: Build Kernel Kmods
  390. if: inputs.build_kernel == true
  391. shell: su buildbot -c "sh -e {0}"
  392. working-directory: openwrt
  393. run: make package/linux/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  394. - name: Build everything
  395. if: inputs.build_full == true
  396. shell: su buildbot -c "sh -e {0}"
  397. working-directory: openwrt
  398. run: make -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  399. - name: Build external toolchain
  400. if: inputs.build_external_toolchain == true
  401. shell: su buildbot -c "sh -e {0}"
  402. working-directory: openwrt
  403. run: make target/toolchain/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  404. - name: Coverity prepare toolchain
  405. if: inputs.coverity_check_packages != ''
  406. shell: su buildbot -c "sh -e {0}"
  407. working-directory: openwrt
  408. run: |
  409. wget -q https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.coverity_api_token }}&project=${{ inputs.coverity_project_name }}" -O coverity.tar.gz
  410. wget -q https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.coverity_api_token }}&project=${{ inputs.coverity_project_name }}&md5=1" -O coverity.tar.gz.md5
  411. echo ' coverity.tar.gz' >> coverity.tar.gz.md5
  412. md5sum -c coverity.tar.gz.md5
  413. mkdir cov-analysis-linux64
  414. tar xzf coverity.tar.gz --strip 1 -C cov-analysis-linux64
  415. export PATH=$(pwd)/cov-analysis-linux64/bin:$PATH
  416. for template in ${{ inputs.coverity_compiler_template_list }}; do
  417. cov-configure --template --comptype gcc --compiler "$template"
  418. done
  419. - name: Clean and recompile packages with Coverity toolchain
  420. if: inputs.coverity_check_packages != ''
  421. shell: su buildbot -c "bash {0}"
  422. working-directory: openwrt
  423. run: |
  424. set -o pipefail -o errexit
  425. coverity_check_packages=(${{ inputs.coverity_check_packages }})
  426. printf -v clean_packages "package/%s/clean " "${coverity_check_packages[@]}"
  427. make -j$(nproc) BUILD_LOG=1 $clean_packages || ret=$? .github/workflows/scripts/show_build_failures.sh
  428. coverity_force_compile_packages=(${{ inputs.coverity_force_compile_packages }})
  429. printf -v force_compile_packages "package/%s/compile " "${coverity_force_compile_packages[@]}"
  430. make -j$(nproc) BUILD_LOG=1 $force_compile_packages || ret=$? .github/workflows/scripts/show_build_failures.sh
  431. printf -v compile_packages "package/%s/compile " "${coverity_check_packages[@]}"
  432. export PATH=$(pwd)/cov-analysis-linux64/bin:$PATH
  433. cov-build --dir cov-int make -j $(nproc) BUILD_LOG=1 $compile_packages || ret=$? .github/workflows/scripts/show_build_failures.sh
  434. - name: Upload build to Coverity for analysis
  435. if: inputs.coverity_check_packages != ''
  436. shell: su buildbot -c "sh -e {0}"
  437. working-directory: openwrt
  438. run: |
  439. tar czf cov-int.tar.gz ./cov-int
  440. curl \
  441. --form token="${{ secrets.coverity_api_token }}" \
  442. --form email="[email protected]" \
  443. --form [email protected] \
  444. --form version="${{ github.ref_name }}-${{ github.sha }}" \
  445. --form description="OpenWrt ${{ github.ref_name }}-${{ github.sha }}" \
  446. "https://scan.coverity.com/builds?project=${{ inputs.coverity_project_name }}"
  447. - name: Upload logs
  448. if: failure()
  449. uses: actions/upload-artifact@v3
  450. with:
  451. name: ${{ inputs.target }}-${{ inputs.subtarget }}-logs
  452. path: "openwrt/logs"
  453. - name: Delete already present ccache cache
  454. if: steps.restore-ccache-cache.outputs.cache-hit == 'true' && inputs.use_ccache_cache == true &&
  455. github.event_name == 'push' && steps.restore-ccache-cache-s3.outputs.cache-hit != 'true'
  456. uses: octokit/[email protected]
  457. with:
  458. route: DELETE /repos/{repository}/actions/caches?key={key}
  459. env:
  460. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  461. INPUT_REPOSITORY: ${{ github.repository }}
  462. INPUT_KEY: ${{ steps.restore-ccache-cache.outputs.cache-primary-key }}
  463. - name: Save ccache cache
  464. if: inputs.use_ccache_cache == true && github.event_name == 'push' &&
  465. steps.restore-ccache-cache-s3.outputs.cache-hit != 'true'
  466. uses: actions/cache/save@v3
  467. with:
  468. path: openwrt/.ccache
  469. key: ${{ steps.restore-ccache-cache.outputs.cache-primary-key }}
  470. - name: Archive ccache
  471. if: inputs.use_ccache_cache == true && github.event_name == 'push' &&
  472. inputs.upload_ccache_cache == true
  473. shell: su buildbot -c "sh -e {0}"
  474. working-directory: openwrt
  475. run: tar -cf ccache-${{ inputs.ccache_type }}-${{ inputs.target }}-${{ inputs.subtarget }}.tar .ccache
  476. - name: Upload ccache cache
  477. if: inputs.use_ccache_cache == true && github.event_name == 'push' &&
  478. inputs.upload_ccache_cache == true
  479. uses: actions/upload-artifact@v3
  480. with:
  481. name: ${{ inputs.target }}-${{ inputs.subtarget }}-ccache-cache
  482. path: openwrt/ccache-${{ inputs.ccache_type }}-${{ inputs.target }}-${{ inputs.subtarget }}.tar
  483. retention-days: 1
  484. - name: Find external toolchain name
  485. id: get-toolchain-name
  486. if: inputs.upload_external_toolchain == true
  487. working-directory: openwrt
  488. run: |
  489. TOOLCHAIN_NAME=$(ls bin/targets/${{inputs.target }}/${{ inputs.subtarget }} | grep toolchain)
  490. echo "toolchain-name=$TOOLCHAIN_NAME" >> $GITHUB_OUTPUT
  491. - name: Upload prebuilt toolchain
  492. if: inputs.upload_external_toolchain == true
  493. uses: actions/upload-artifact@v3
  494. with:
  495. name: ${{ inputs.target }}-${{ inputs.subtarget }}-external-toolchain
  496. path: openwrt/bin/targets/${{ inputs.target }}/${{ inputs.subtarget }}/${{ steps.get-toolchain-name.outputs.toolchain-name }}
  497. retention-days: 1