@@ -14,58 +14,26 @@ jobs:
1414
1515 steps :
1616 - uses : actions/checkout@v3
17- # calculate the merge-base with main, in a way that works both on PRs and pushes to main.
18- - name : Calculate merge-base
19- if : ${{ github.event_name == 'pull_request' }}
20- env :
21- BASE_BRANCH : ${{ github.base_ref }}
22- run : |
23- MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
24- echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
25- - name : Read CodeQL query compilation - PR
26- if : ${{ github.event_name == 'pull_request' }}
27- uses : actions/cache@v3
28- with :
29- path : ' */ql/src/.cache'
30- key : codeql-compile-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
31- restore-keys : |
32- codeql-compile-${{ github.base_ref }}-${{ env.merge-base }}
33- codeql-compile-${{ github.base_ref }}-
34- codeql-compile-main-
35- - name : Fill CodeQL query compilation cache - main
36- if : ${{ github.event_name != 'pull_request' }}
37- uses : actions/cache@v3
38- with :
39- path : ' */ql/src/.cache'
40- key : codeql-compile-${{ github.ref_name }}-${{ github.sha }} # just fill on main
41- restore-keys : | # restore from another random commit, to speed up compilation.
42- codeql-compile-${{ github.ref_name }}-
43- codeql-compile-main-
4417 - name : Setup CodeQL
4518 uses : ./.github/actions/fetch-codeql
4619 with :
4720 channel : ' release'
21+ - name : Cache compilation cache
22+ id : query-cache
23+ uses : ./.github/actions/cache-query-compilation
24+ with :
25+ key : all-queries
4826 - name : check formatting
4927 run : find */ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 codeql query format --check-only
5028 - name : compile queries - check-only
5129 # run with --check-only if running in a PR (github.sha != main)
5230 if : ${{ github.event_name == 'pull_request' }}
5331 shell : bash
54- run : codeql query compile -j0 */ql/src --keep-going --warnings=error --check-only
32+ run : codeql query compile -j0 */ql/{ src,examples} --keep-going --warnings=error --check-only --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
5533 - name : compile queries - full
5634 # do full compile if running on main - this populates the cache
5735 if : ${{ github.event_name != 'pull_request' }}
5836 shell : bash
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- # copy the contents of the .cache folders into the combined cache folder.
64- cp -r */ql/src/.cache/* ${COMBINED_CACHE_DIR}/
65- # clean up the .cache folders
66- rm -rf */ql/src/.cache/*
67-
68- # compile the queries
69- codeql query compile -j0 */ql/src --keep-going --warnings=error --compilation-cache ${COMBINED_CACHE_DIR}
37+ run : codeql query compile -j0 */ql/{src,examples} --keep-going --warnings=error --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
7038 env :
7139 COMBINED_CACHE_DIR : ${{ github.workspace }}/compilation-dir
0 commit comments