@@ -2,27 +2,25 @@ name: "Compile all queries using the latest stable CodeQL CLI"
2
2
3
3
on :
4
4
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.
8
6
- main
9
7
- " rc/*"
8
+ - " codeql-cli-*"
9
+ pull_request :
10
10
11
11
jobs :
12
12
compile-queries :
13
13
runs-on : ubuntu-latest-xl
14
14
15
15
steps :
16
16
- uses : actions/checkout@v3
17
- with :
18
- fetch-depth : 0
19
17
# calculate the merge-base with main, in a way that works both on PRs and pushes to main.
20
18
- name : Calculate merge-base
21
19
if : ${{ github.event_name == 'pull_request' }}
22
20
env :
23
21
BASE_BRANCH : ${{ github.base_ref }}
24
22
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 " " )
26
24
echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
27
25
- name : Read CodeQL query compilation - PR
28
26
if : ${{ github.event_name == 'pull_request' }}
@@ -31,14 +29,18 @@ jobs:
31
29
path : ' */ql/src/.cache'
32
30
key : codeql-compile-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
33
31
restore-keys : |
34
- codeql-compile-main-${{ env.merge-base }}
32
+ codeql-compile-${{ github.base_ref }}-${{ env.merge-base }}
33
+ codeql-compile-${{ github.base_ref }}-
35
34
codeql-compile-main-
36
35
- name : Fill CodeQL query compilation cache - main
37
36
if : ${{ github.event_name != 'pull_request' }}
38
37
uses : actions/cache@v3
39
38
with :
40
39
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-
42
44
- name : Setup CodeQL
43
45
uses : ./.github/actions/fetch-codeql
44
46
with :
0 commit comments