1+ name : " Compile all queries using the latest stable CodeQL CLI"
2+
3+ on :
4+ push :
5+ branches : [main] # makes sure the cache gets populated
6+ pull_request :
7+ branches :
8+ - main
9+ - " rc/*"
10+
11+ jobs :
12+ compile-queries :
13+ runs-on : ubuntu-latest-xl
14+
15+ steps :
16+ - uses : actions/checkout@v3
17+ with :
18+ fetch-depth : 0
19+ # calculate the merge-base with main, in a way that works both on PRs and pushes to main.
20+ - name : Calculate merge-base
21+ id : merge-base
22+ env :
23+ BASE_BRANCH : ${{ github.base_ref }}
24+ run : |
25+ MERGE_BASE=$(git merge-base --fork-point origin/$BASE_BRANCH)
26+ echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
27+ - name : Cache CodeQL query compilation
28+ uses : actions/cache@v3
29+ with :
30+ path : ' */ql/src/.cache'
31+ # current GH HEAD first, merge-base second, generic third
32+ key : codeql-stable-compile-${{ github.sha }}
33+ restore-keys : |
34+ codeql-stable-compile-${{ env.merge-base }}
35+ codeql-stable-compile-
36+ - name : Setup CodeQL
37+ uses : ./.github/actions/fetch-codeql
38+ with :
39+ channel : ' release'
40+ - name : check formatting
41+ run : codeql query format */ql/{src,lib,test}/**/*.{qll,ql} --check-only
42+ - name : compile queries - check-only
43+ # run with --check-only if running in a PR (github.sha != main)
44+ if : ${{ github.sha != steps.merge-base.outputs.merge-base }}
45+ shell : bash
46+ run : codeql query compile -j0 */ql/src --keep-going --warnings=error --check-only
47+ - name : compile queries - full
48+ # do full compile if running on main - this populates the cache
49+ if : ${{ github.sha == steps.merge-base.outputs.merge-base }}
50+ shell : bash
51+ run : codeql query compile -j0 */ql/src --keep-going --warnings=error
0 commit comments