Skip to content

Commit 65c1e23

Browse files
committed
clean up the cache when compiling on main
1 parent dc440aa commit 65c1e23

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

.github/workflows/compile-queries.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,20 @@ jobs:
5656
# do full compile if running on main - this populates the cache
5757
if : ${{ github.event_name != 'pull_request' }}
5858
shell: bash
59-
run: codeql query compile -j0 */ql/src --keep-going --warnings=error
59+
run: |
60+
# Move all the existing cache into another folder, so we only preserve the cache for the current queries.
61+
mkdir -p ${COMBINED_CACHE_DIR}
62+
rm */ql/src/.cache/{lock,size}
63+
# replicate the folder structure from the .cache folders into the combined cache folder. (because cp doesn't have a "create missing folders" option)
64+
find */ql/src/.cache -type d | cut -d "/" -f 6,7 | sort | uniq > folders.txt
65+
cat folders.txt | xargs -I {} mkdir -p ${COMBINED_CACHE_DIR}/{}
66+
# copy the contents of the .cache folders into the combined cache folder.
67+
cp -r */ql/src/.cache/* ${COMBINED_CACHE_DIR}/
68+
# clean up the .cache folders
69+
rm -rf */ql/src/.cache/*
70+
rm folders.txt
71+
72+
# compile the queries
73+
codeql query compile -j0 */ql/src --keep-going --warnings=error --compilation-cache ${COMBINED_CACHE_DIR}
74+
env:
75+
COMBINED_CACHE_DIR: ${{ github.workspace }}/compilation-dir

0 commit comments

Comments
 (0)