99outputs :
1010 cache-dir :
1111 description : " The directory where the cache was stored"
12- value : ${{ steps.fill -compilation-dir.outputs.compdir }}
12+ value : ${{ steps.output -compilation-dir.outputs.compdir }}
1313
1414runs :
1515 using : composite
2727 if : ${{ github.event_name == 'pull_request' }}
2828 uses : actions/cache/restore@v3
2929 with :
30- path : ' **/.cache'
30+ path : |
31+ **/.cache
32+ ~/.codeql/compile-cache
3133 key : codeql-compile-${{ inputs.key }}-pr-${{ github.sha }}
3234 restore-keys : |
3335 codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
@@ -37,12 +39,22 @@ runs:
3739 if : ${{ github.event_name != 'pull_request' }}
3840 uses : actions/cache@v3
3941 with :
40- path : ' **/.cache'
42+ path : |
43+ **/.cache
44+ ~/.codeql/compile-cache
4145 key : codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main
4246 restore-keys : | # restore the latest cache if the exact cache is unavailable, to speed up compilation.
4347 codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-
4448 codeql-compile-${{ inputs.key }}-main-
49+ - name : Output-compilationdir
50+ id : output-compilation-dir
51+ shell : bash
52+ run : |
53+ echo "compdir=${COMBINED_CACHE_DIR}" >> $GITHUB_OUTPUT
54+ env :
55+ COMBINED_CACHE_DIR : ${{ runner.temp }}/compilation-dir
4556 - name : Fill compilation cache directory
57+ id : fill-compilation-dir
4658 uses : actions/github-script@v6
4759 env :
4860 COMBINED_CACHE_DIR : ${{ runner.temp }}/compilation-dir
5870
5971 const fs = require("fs");
6072 const path = require("path");
73+ const os = require("os");
6174
6275 // the first argv is the cache folder to create.
6376 const COMBINED_CACHE_DIR = process.env.COMBINED_CACHE_DIR;
@@ -97,6 +110,17 @@ runs:
97110 console.log(`Found .cache dir at ${dir}`);
98111 }
99112
113+ const globalCacheDir = path.join(os.homedir(), ".codeql", "compile-cache");
114+ if (fs.existsSync(globalCacheDir)) {
115+ console.log("Found global home dir: " + globalCacheDir);
116+ cacheDirs.push(globalCacheDir);
117+ }
118+
119+ if (cacheDirs.length === 0) {
120+ console.log("No cache dirs found");
121+ return;
122+ }
123+
100124 // mkdir -p ${COMBINED_CACHE_DIR}
101125 fs.mkdirSync(COMBINED_CACHE_DIR, { recursive: true });
102126
0 commit comments