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