浏览代码

CI: kernel: use ccache to speedup workflow

Use ccache to speedup kernel compilation.
Ccache dir is cached across each build test. To refresh ccache directory
we generate an hash of the kernel include files, that includes the
kernel versions of every kernel supported and the kernel compile
includes.

Signed-off-by: Christian Marangi <[email protected]>
Christian Marangi 3 年之前
父节点
当前提交
137ba15e6e
共有 1 个文件被更改,包括 17 次插入0 次删除
  1. 17 0
      .github/workflows/kernel.yml

+ 17 - 0
.github/workflows/kernel.yml

@@ -18,6 +18,7 @@ jobs:
     outputs:
     outputs:
       target: ${{ steps.find_targets.outputs.target }}
       target: ${{ steps.find_targets.outputs.target }}
       owner_lc: ${{ steps.lower_owner.outputs.owner_lc }}
       owner_lc: ${{ steps.lower_owner.outputs.owner_lc }}
+      ccache_hash: ${{ steps.ccache_hash.outputs.ccache_hash }}
 
 
     steps:
     steps:
       - name: Checkout
       - name: Checkout
@@ -30,6 +31,13 @@ jobs:
             | tr '[:upper:]' '[:lower:]')
             | tr '[:upper:]' '[:lower:]')
           echo "::set-output name=owner_lc::$OWNER_LC"
           echo "::set-output name=owner_lc::$OWNER_LC"
 
 
+      - name: Generate ccache hash
+        id: ccache_hash
+        run: |
+          CCACHE_HASH=$(md5sum include/kernel-* | awk '{ print $1 }' \
+           | md5sum | awk '{ print $1 }')
+          echo "::set-output name=ccache_hash::$CCACHE_HASH"
+
       - name: Set targets
       - name: Set targets
         id: find_targets
         id: find_targets
         run: |
         run: |
@@ -133,6 +141,14 @@ jobs:
           path: openwrt/${{ env.TOOLCHAIN_FILE }}
           path: openwrt/${{ env.TOOLCHAIN_FILE }}
           key: ${{ env.TOOLCHAIN_FILE }}-${{ env.TOOLCHAIN_SHA256 }}
           key: ${{ env.TOOLCHAIN_FILE }}-${{ env.TOOLCHAIN_SHA256 }}
 
 
+      - name: Cache ccache
+        uses: actions/cache@v3
+        with:
+          path: openwrt/.ccache
+          key: ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-${{ needs.determine_targets.outputs.ccache_hash }}
+          restore-keys: |
+            ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-
+
       - name: Download external toolchain
       - name: Download external toolchain
         if: ${{ steps.cache-external-toolchain.outputs.cache-hit != 'true' }}
         if: ${{ steps.cache-external-toolchain.outputs.cache-hit != 'true' }}
         shell: su buildbot -c "sh -e {0}"
         shell: su buildbot -c "sh -e {0}"
@@ -153,6 +169,7 @@ jobs:
           echo CONFIG_ALL_KMODS=y >> .config
           echo CONFIG_ALL_KMODS=y >> .config
           echo CONFIG_DEVEL=y >> .config
           echo CONFIG_DEVEL=y >> .config
           echo CONFIG_AUTOREMOVE=y >> .config
           echo CONFIG_AUTOREMOVE=y >> .config
+          echo CONFIG_CCACHE=y >> .config
 
 
           ./scripts/ext-toolchain.sh \
           ./scripts/ext-toolchain.sh \
             --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
             --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \