@@ -2,27 +2,25 @@ 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 )
23+ MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " " )
2624 echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
2725 - name : Read CodeQL query compilation - PR
2826 if : ${{ github.event_name == 'pull_request' }}
@@ -31,14 +29,18 @@ jobs:
3129 path : ' */ql/src/.cache'
3230 key : codeql-compile-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
3331 restore-keys : |
34- codeql-compile-main-${{ env.merge-base }}
32+ codeql-compile-${{ github.base_ref }}-${{ env.merge-base }}
33+ codeql-compile-${{ github.base_ref }}-
3534 codeql-compile-main-
3635 - name : Fill CodeQL query compilation cache - main
3736 if : ${{ github.event_name != 'pull_request' }}
3837 uses : actions/cache@v3
3938 with :
4039 path : ' */ql/src/.cache'
41- key : codeql-compile-main-${{ github.sha }} # just fill on main
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 :
0 commit comments