@@ -17,9 +17,45 @@ permissions:
1717 contents : read
1818
1919jobs :
20- compile-queries :
20+ detect-changes :
2121 if : github.repository_owner == 'github'
22+ runs-on : ubuntu-latest
23+ outputs :
24+ languages : ${{ steps.detect.outputs.languages }}
25+ steps :
26+ - uses : actions/checkout@v5
27+ - name : Detect changed languages
28+ id : detect
29+ run : |
30+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
31+ # For PRs, detect which languages have changes
32+ changed_files=$(gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files.[].path')
33+ languages=()
34+ for lang in actions cpp csharp go java javascript python ruby rust swift; do
35+ if echo "$changed_files" | grep -qE "^($lang/|shared/)" ; then
36+ languages+=("$lang")
37+ fi
38+ done
39+ # If no specific language matched (e.g., only root files changed), run all
40+ # if [[ ${#languages[@]} -eq 0 ]]; then
41+ # languages=(actions cpp csharp go java javascript python ruby rust swift)
42+ # fi
43+ echo "languages=$(jq -c -n '$ARGS.positional' --args "${languages[@]}")" >> $GITHUB_OUTPUT
44+ else
45+ # For pushes to main/rc branches, run all languages
46+ echo 'languages=["actions","cpp","csharp","go","java","javascript","python","ruby","rust","swift"]' >> $GITHUB_OUTPUT
47+ fi
48+ env :
49+ GH_TOKEN : ${{ github.token }}
50+
51+ compile-queries :
52+ needs : detect-changes
53+ if : github.repository_owner == 'github' && needs.detect-changes.outputs.languages != '[]'
2254 runs-on : ubuntu-latest-xl
55+ strategy :
56+ fail-fast : false
57+ matrix :
58+ language : ${{ fromJson(needs.detect-changes.outputs.languages) }}
2359
2460 steps :
2561 - uses : actions/checkout@v5
@@ -31,16 +67,16 @@ jobs:
3167 id : query-cache
3268 uses : ./.github/actions/cache-query-compilation
3369 with :
34- key : all -queries
70+ key : ${{ matrix.language }} -queries
3571 - name : check formatting
36- run : find shared * /ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 -n 3000 -P 10 codeql query format -q --check-only
72+ run : find shared ${{ matrix.language }} /ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 -n 3000 -P 10 codeql query format -q --check-only
3773 - name : compile queries - check-only
3874 # run with --check-only if running in a PR (github.sha != main)
3975 if : ${{ github.event_name == 'pull_request' }}
4076 shell : bash
41- run : codeql query compile -q -j0 * /ql/{src,examples} --keep-going --warnings=error --check-only --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" --compilation-cache-size=500 --ram=56000
77+ run : codeql query compile -q -j0 ${{ matrix.language }} /ql/{src,examples} --keep-going --warnings=error --check-only --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" --compilation-cache-size=500 --ram=56000
4278 - name : compile queries - full
4379 # do full compile if running on main - this populates the cache
4480 if : ${{ github.event_name != 'pull_request' }}
4581 shell : bash
46- run : codeql query compile -q -j0 * /ql/{src,examples} --keep-going --warnings=error --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" --compilation-cache-size=500 --ram=56000
82+ run : codeql query compile -q -j0 ${{ matrix.language }} /ql/{src,examples} --keep-going --warnings=error --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" --compilation-cache-size=500 --ram=56000
0 commit comments