From 65c1e239eb1249d02361e65b0ffc38a1ada60593 Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Tue, 15 Nov 2022 14:49:06 +0100 Subject: [PATCH 1/2] clean up the cache when compiling on main --- .github/workflows/compile-queries.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile-queries.yml b/.github/workflows/compile-queries.yml index bdcf0ba8d8ab..73b674aff30b 100644 --- a/.github/workflows/compile-queries.yml +++ b/.github/workflows/compile-queries.yml @@ -56,4 +56,20 @@ jobs: # do full compile if running on main - this populates the cache if : ${{ github.event_name != 'pull_request' }} shell: bash - run: codeql query compile -j0 */ql/src --keep-going --warnings=error \ No newline at end of file + run: | + # Move all the existing cache into another folder, so we only preserve the cache for the current queries. + mkdir -p ${COMBINED_CACHE_DIR} + rm */ql/src/.cache/{lock,size} + # replicate the folder structure from the .cache folders into the combined cache folder. (because cp doesn't have a "create missing folders" option) + find */ql/src/.cache -type d | cut -d "/" -f 6,7 | sort | uniq > folders.txt + cat folders.txt | xargs -I {} mkdir -p ${COMBINED_CACHE_DIR}/{} + # copy the contents of the .cache folders into the combined cache folder. + cp -r */ql/src/.cache/* ${COMBINED_CACHE_DIR}/ + # clean up the .cache folders + rm -rf */ql/src/.cache/* + rm folders.txt + + # compile the queries + codeql query compile -j0 */ql/src --keep-going --warnings=error --compilation-cache ${COMBINED_CACHE_DIR} + env: + COMBINED_CACHE_DIR: ${{ github.workspace }}/compilation-dir \ No newline at end of file From e4b0d8dbf3ad3ffca4f13cb381d4bfc9c2676ad8 Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Wed, 16 Nov 2022 16:07:49 +0100 Subject: [PATCH 2/2] simplify the copy-logic, because cp -r actually creates the folders --- .github/workflows/compile-queries.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/compile-queries.yml b/.github/workflows/compile-queries.yml index 73b674aff30b..94378250c857 100644 --- a/.github/workflows/compile-queries.yml +++ b/.github/workflows/compile-queries.yml @@ -60,14 +60,10 @@ jobs: # Move all the existing cache into another folder, so we only preserve the cache for the current queries. mkdir -p ${COMBINED_CACHE_DIR} rm */ql/src/.cache/{lock,size} - # replicate the folder structure from the .cache folders into the combined cache folder. (because cp doesn't have a "create missing folders" option) - find */ql/src/.cache -type d | cut -d "/" -f 6,7 | sort | uniq > folders.txt - cat folders.txt | xargs -I {} mkdir -p ${COMBINED_CACHE_DIR}/{} # copy the contents of the .cache folders into the combined cache folder. cp -r */ql/src/.cache/* ${COMBINED_CACHE_DIR}/ # clean up the .cache folders rm -rf */ql/src/.cache/* - rm folders.txt # compile the queries codeql query compile -j0 */ql/src --keep-going --warnings=error --compilation-cache ${COMBINED_CACHE_DIR}