From 389b7ceff58f569d63aedbe3fcfcf6e8a1d97510 Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Mon, 20 Feb 2023 15:34:03 +0100 Subject: [PATCH] support the new shared compilation cache directory --- .../cache-query-compilation/action.yml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/actions/cache-query-compilation/action.yml b/.github/actions/cache-query-compilation/action.yml index e2d4c0d4a0f2..0ad0b7da9822 100644 --- a/.github/actions/cache-query-compilation/action.yml +++ b/.github/actions/cache-query-compilation/action.yml @@ -27,7 +27,9 @@ runs: if: ${{ github.event_name == 'pull_request' }} uses: actions/cache/restore@v3 with: - path: '**/.cache' + path: | + **/.cache + ~/.codeql/compile-cache key: codeql-compile-${{ inputs.key }}-pr-${{ github.sha }} restore-keys: | codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }} @@ -37,7 +39,9 @@ runs: if: ${{ github.event_name != 'pull_request' }} uses: actions/cache@v3 with: - path: '**/.cache' + path: | + **/.cache + ~/.codeql/compile-cache key: codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main restore-keys: | # restore the latest cache if the exact cache is unavailable, to speed up compilation. codeql-compile-${{ inputs.key }}-${{ github.ref_name }}- @@ -66,6 +70,7 @@ runs: const fs = require("fs"); const path = require("path"); + const os = require("os"); // the first argv is the cache folder to create. const COMBINED_CACHE_DIR = process.env.COMBINED_CACHE_DIR; @@ -105,6 +110,17 @@ runs: console.log(`Found .cache dir at ${dir}`); } + const globalCacheDir = path.join(os.homedir(), ".codeql", "compile-cache"); + if (fs.existsSync(globalCacheDir)) { + console.log("Found global home dir: " + globalCacheDir); + cacheDirs.push(globalCacheDir); + } + + if (cacheDirs.length === 0) { + console.log("No cache dirs found"); + return; + } + // mkdir -p ${COMBINED_CACHE_DIR} fs.mkdirSync(COMBINED_CACHE_DIR, { recursive: true });