Skip to content

Commit ec87a93

Browse files
authored
Merge pull request github#11078 from erik-krogh/stableCI
add workflow that checks compilation of all queries with the latest stable release
2 parents c82d8cb + 5918e01 commit ec87a93

File tree

7 files changed

+69
-8
lines changed

7 files changed

+69
-8
lines changed

.github/actions/fetch-codeql/action.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
name: Fetch CodeQL
22
description: Fetches the latest version of CodeQL
3+
4+
inputs:
5+
channel:
6+
description: 'The CodeQL channel to use'
7+
required: false
8+
default: 'nightly'
9+
310
runs:
411
using: composite
512
steps:
613
- name: Fetch CodeQL
714
shell: bash
15+
env:
16+
GITHUB_TOKEN: ${{ github.token }}
17+
CHANNEL: ${{ inputs.channel }}
818
run: |
919
gh extension install github/gh-codeql
10-
gh codeql set-channel nightly
20+
gh codeql set-channel "$CHANNEL"
1121
gh codeql version
1222
gh codeql version --format=json | jq -r .unpackedLocation >> "${GITHUB_PATH}"
13-
env:
14-
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/compile-queries.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

go/ql/src/Metrics/FLinesOfCode.ql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* @treemap.warnOn highValues
77
* @metricType file
88
* @metricAggregate avg sum max
9-
* @precision very-high
109
* @id go/lines-of-code-in-files
1110
* @tags maintainability
1211
*/

go/ql/src/Metrics/FLinesOfComment.ql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* @treemap.warnOn lowValues
77
* @metricType file
88
* @metricAggregate avg sum max
9-
* @precision very-high
109
* @id go/lines-of-comments-in-files
1110
* @tags documentation
1211
*/

go/ql/src/experimental/CWE-400/DatabaseCallInLoop.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,5 @@ query predicate edges(CallGraphNode pred, CallGraphNode succ) {
6666

6767
from LoopStmt loop, DatabaseAccess dbAccess
6868
where edges*(loop, dbAccess.asExpr())
69-
select dbAccess, loop, dbAccess, "This calls " + dbAccess.toString() + " in a $@.", loop, "loop"
69+
select dbAccess, loop, dbAccess.asExpr(), "This calls " + dbAccess.toString() + " in a $@.", loop,
70+
"loop"

go/ql/src/experimental/InconsistentCode/DeferInLoop.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This can lead to unintentionally holding resources open like file handles or database transactions.
55
* @id go/examples/deferinloop
66
* @kind problem
7+
* @problem.severity warning
8+
* @precision high
79
* @tags defer
810
* nesting
911
*/

swift/ql/lib/codeql/swift/controlflow/internal/Completion.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ abstract class Completion extends TCompletion {
7070
predicate isValidFor(ControlFlowElement n) {
7171
this.isValidForSpecific(n)
7272
or
73-
mayHaveThrowCompletion(n, this)
73+
this instanceof ThrowCompletion and
74+
mayHaveThrowCompletion(n)
7475
or
7576
not any(Completion c).isValidForSpecific(n) and
7677
this = TSimpleCompletion()
@@ -320,7 +321,7 @@ private predicate mustHaveThrowCompletion(ThrowStmt throw, ThrowCompletion c) {
320321

321322
private predicate isThrowingType(AnyFunctionType type) { type.isThrowing() }
322323

323-
private predicate mayHaveThrowCompletion(ControlFlowElement n, ThrowCompletion c) {
324+
private predicate mayHaveThrowCompletion(ControlFlowElement n) {
324325
// An AST expression that may throw.
325326
isThrowingType(n.asAstNode().(ApplyExpr).getFunction().getType())
326327
or

0 commit comments

Comments
 (0)