浏览代码

CI: Add support for ccache and cache configuration on CI

PatTheMav 3 年之前
父节点
当前提交
16f1e367f3

+ 2 - 1
.github/scripts/.build.zsh

@@ -39,7 +39,7 @@ build() {
   trap '_trap_error' ZERR
 
   fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath})
-  autoload -Uz log_info log_error log_output set_loglevel check_${host_os} setup_${host_os} setup_obs
+  autoload -Uz log_info log_error log_output set_loglevel check_${host_os} setup_${host_os} setup_obs setup_ccache
 
   local -i _verbosity=1
   local -r _version='0.0.1'
@@ -137,6 +137,7 @@ Usage: %B${functrace[1]%:*}%b <option> [<options>]
       ;;
   }
 
+  setup_ccache
   setup_obs
 
   pushd ${project_root}

+ 14 - 0
.github/scripts/utils.zsh/setup_ccache

@@ -0,0 +1,14 @@
+autoload -Uz log_debug log_warning
+
+if (( ${+commands[ccache]} )) {
+  log_debug "Found ccache at ${commands[ccache]}"
+
+  if (( ${+CI} )) {
+    ccache --set-config=cache_dir="${GITHUB_WORKSPACE:-${HOME}}/.ccache"
+    ccache --set-config=max_size="${CCACHE_SIZE:-500M}"
+    ccache --set-config=compression=true
+    ccache -z > /dev/null
+  }
+} else {
+  log_warning "No ccache found on the system"
+}

+ 1 - 0
.github/scripts/utils.zsh/setup_linux

@@ -11,6 +11,7 @@ sudo apt-get -qq update
 sudo apt-get install -y \
     build-essential \
     ninja-build \
+    ccache \
     clang \
     clang-format \
     git \

+ 2 - 2
.github/workflows/main.yml

@@ -197,9 +197,9 @@ jobs:
         uses: actions/cache@v2.1.7
         with:
           path: ${{ github.workspace }}/.ccache
-          key: macos-${{ matrix.arch }}-ccache-plugin-${{ steps.setup.outputs.ccacheDate }}
+          key: linux-${{ matrix.arch }}-ccache-plugin-${{ steps.setup.outputs.ccacheDate }}
           restore-keys: |
-            macos-${{ matrix.arch }}-ccache-plugin-
+            linux-${{ matrix.arch }}-ccache-plugin-
 
       - name: Check for GitHub Labels
         id: seekingTesters