@@ -2,49 +2,51 @@ name: "Compile all queries using the latest stable CodeQL CLI"
22
33on :
44 push :
5- branches : [main] # makes sure the cache gets populated
6- pull_request :
7- branches :
5+ branches : # makes sure the cache gets populated - running on the branches people tend to merge into.
86 - main
97 - " rc/*"
8+ - " codeql-cli-*"
9+ pull_request :
1010
1111jobs :
1212 compile-queries :
1313 runs-on : ubuntu-latest-xl
1414
1515 steps :
1616 - uses : actions/checkout@v3
17- with :
18- fetch-depth : 0
1917 # calculate the merge-base with main, in a way that works both on PRs and pushes to main.
2018 - name : Calculate merge-base
2119 if : ${{ github.event_name == 'pull_request' }}
2220 env :
2321 BASE_BRANCH : ${{ github.base_ref }}
2422 run : |
25- MERGE_BASE=$(git merge-base --fork-point origin/$BASE_BRANCH)
26- echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
27- - name : Calculate merge-base - branch
28- if : ${{ github.event_name != 'pull_request' }}
29- # using github.sha instead, since we're directly on a branch, and not in a PR
30- run : |
31- MERGE_BASE=${{ github.sha }}
23+ MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
3224 echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
33- - name : Cache CodeQL query compilation
25+ - name : Read CodeQL query compilation - PR
26+ if : ${{ github.event_name == 'pull_request' }}
3427 uses : actions/cache@v3
3528 with :
3629 path : ' */ql/src/.cache'
37- # current GH HEAD first, merge-base second, generic third
38- key : codeql-stable-compile-${{ github.sha }}
30+ key : codeql-compile-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
3931 restore-keys : |
40- codeql-stable-compile-${{ env.merge-base }}
41- codeql-stable-compile-
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-
4244 - name : Setup CodeQL
4345 uses : ./.github/actions/fetch-codeql
4446 with :
4547 channel : ' release'
4648 - name : check formatting
47- run : codeql query format */ql/{src,lib,test}/**/*.{ qll,ql} --check-only
49+ run : find */ql -type f \( -name "*. qll" -o -name "*.ql" \) -print0 | xargs -0 codeql query format --check-only
4850 - name : compile queries - check-only
4951 # run with --check-only if running in a PR (github.sha != main)
5052 if : ${{ github.event_name == 'pull_request' }}
0 commit comments