Skip to content

Commit 7d45ca6

Browse files
committed
Merge branch 'main' into optionals2
2 parents 2780d9a + 15aa8b6 commit 7d45ca6

File tree

313 files changed

+4698
-5961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+4698
-5961
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Cache query compilation
2+
description: Caches CodeQL compilation caches - should be run both on PRs and pushes to main.
3+
4+
inputs:
5+
key:
6+
description: 'The cache key to use - should be unique to the workflow'
7+
required: true
8+
9+
outputs:
10+
cache-dir:
11+
description: "The directory where the cache was stored"
12+
value: ${{ steps.fill-compilation-dir.outputs.compdir }}
13+
14+
runs:
15+
using: composite
16+
steps:
17+
# Cache the query compilation caches.
18+
# calculate the merge-base with main, in a way that works both on PRs and pushes to main.
19+
- name: Calculate merge-base
20+
shell: bash
21+
if: ${{ github.event_name == 'pull_request' }}
22+
env:
23+
BASE_BRANCH: ${{ github.base_ref }}
24+
run: |
25+
MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
26+
echo "merge_base=$MERGE_BASE" >> $GITHUB_ENV
27+
- name: Read CodeQL query compilation - PR
28+
if: ${{ github.event_name == 'pull_request' }}
29+
uses: actions/cache@v3
30+
with:
31+
path: '**/.cache'
32+
key: codeql-compile-${{ inputs.key }}-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
33+
restore-keys: |
34+
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
35+
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-
36+
codeql-compile-${{ inputs.key }}-main-
37+
- name: Fill CodeQL query compilation cache - main
38+
if: ${{ github.event_name != 'pull_request' }}
39+
uses: actions/cache@v3
40+
with:
41+
path: '**/.cache'
42+
key: codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main
43+
restore-keys: | # restore from another random commit, to speed up compilation.
44+
codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-
45+
codeql-compile-${{ inputs.key }}-main-
46+
- name: Fill compilation cache directory
47+
id: fill-compilation-dir
48+
shell: bash
49+
run: |
50+
# Move all the existing cache into another folder, so we only preserve the cache for the current queries.
51+
mkdir -p ${COMBINED_CACHE_DIR}
52+
rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
53+
# copy the contents of the .cache folders into the combined cache folder.
54+
cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
55+
# clean up the .cache folders
56+
rm -rf **/.cache/*
57+
58+
echo "compdir=${COMBINED_CACHE_DIR}" >> $GITHUB_OUTPUT
59+
env:
60+
COMBINED_CACHE_DIR: ${{ github.workspace }}/compilation-dir

.github/workflows/compile-queries.yml

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,58 +14,26 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v3
17-
# calculate the merge-base with main, in a way that works both on PRs and pushes to main.
18-
- name: Calculate merge-base
19-
if: ${{ github.event_name == 'pull_request' }}
20-
env:
21-
BASE_BRANCH: ${{ github.base_ref }}
22-
run: |
23-
MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
24-
echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
25-
- name: Read CodeQL query compilation - PR
26-
if: ${{ github.event_name == 'pull_request' }}
27-
uses: actions/cache@v3
28-
with:
29-
path: '*/ql/src/.cache'
30-
key: codeql-compile-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
31-
restore-keys: |
32-
codeql-compile-${{ github.base_ref }}-${{ env.merge-base }}
33-
codeql-compile-${{ github.base_ref }}-
34-
codeql-compile-main-
35-
- name: Fill CodeQL query compilation cache - main
36-
if: ${{ github.event_name != 'pull_request' }}
37-
uses: actions/cache@v3
38-
with:
39-
path: '*/ql/src/.cache'
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-
4417
- name: Setup CodeQL
4518
uses: ./.github/actions/fetch-codeql
4619
with:
4720
channel: 'release'
21+
- name: Cache compilation cache
22+
id: query-cache
23+
uses: ./.github/actions/cache-query-compilation
24+
with:
25+
key: all-queries
4826
- name: check formatting
4927
run: find */ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 codeql query format --check-only
5028
- name: compile queries - check-only
5129
# run with --check-only if running in a PR (github.sha != main)
5230
if : ${{ github.event_name == 'pull_request' }}
5331
shell: bash
54-
run: codeql query compile -j0 */ql/src --keep-going --warnings=error --check-only
32+
run: codeql query compile -j0 */ql/{src,examples} --keep-going --warnings=error --check-only --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
5533
- name: compile queries - full
5634
# do full compile if running on main - this populates the cache
5735
if : ${{ github.event_name != 'pull_request' }}
5836
shell: bash
59-
run: |
60-
# Move all the existing cache into another folder, so we only preserve the cache for the current queries.
61-
mkdir -p ${COMBINED_CACHE_DIR}
62-
rm */ql/src/.cache/{lock,size}
63-
# copy the contents of the .cache folders into the combined cache folder.
64-
cp -r */ql/src/.cache/* ${COMBINED_CACHE_DIR}/
65-
# clean up the .cache folders
66-
rm -rf */ql/src/.cache/*
67-
68-
# compile the queries
69-
codeql query compile -j0 */ql/src --keep-going --warnings=error --compilation-cache ${COMBINED_CACHE_DIR}
37+
run: codeql query compile -j0 */ql/{src,examples} --keep-going --warnings=error --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
7038
env:
7139
COMBINED_CACHE_DIR: ${{ github.workspace }}/compilation-dir

.github/workflows/ql-for-ql-tests.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,3 @@ jobs:
4747
find ql/ql/src "(" -name "*.ql" -or -name "*.qll" ")" -print0 | xargs -0 "${CODEQL}" query format --check-only
4848
env:
4949
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
50-
- name: Check QL compilation
51-
run: |
52-
"${CODEQL}" query compile --check-only --threads=4 --warnings=error --search-path "${{ github.workspace }}/ql/extractor-pack" "ql/ql/src" "ql/ql/examples"
53-
env:
54-
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}

.github/workflows/ruby-build.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,23 @@ jobs:
8686
ruby/target/release/ruby-extractor.exe
8787
retention-days: 1
8888
compile-queries:
89-
runs-on: ubuntu-latest
90-
env:
91-
CODEQL_THREADS: 4 # TODO: remove this once it's set by the CLI
89+
runs-on: ubuntu-latest-xl
9290
steps:
9391
- uses: actions/checkout@v3
9492
- name: Fetch CodeQL
9593
uses: ./.github/actions/fetch-codeql
94+
- name: Cache compilation cache
95+
id: query-cache
96+
uses: ./.github/actions/cache-query-compilation
97+
with:
98+
key: ruby-build
9699
- name: Build Query Pack
97100
run: |
98101
codeql pack create ../shared/ssa --output target/packs
99102
codeql pack create ../misc/suite-helpers --output target/packs
103+
codeql pack create ../shared/regex --output target/packs
100104
codeql pack create ql/lib --output target/packs
101-
codeql pack create ql/src --output target/packs
105+
codeql pack create -j0 ql/src --output target/packs --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
102106
PACK_FOLDER=$(readlink -f target/packs/codeql/ruby-queries/*)
103107
codeql generate query-help --format=sarifv2.1.0 --output="${PACK_FOLDER}/rules.sarif" ql/src
104108
(cd ql/src; find queries \( -name '*.qhelp' -o -name '*.rb' -o -name '*.erb' \) -exec bash -c 'mkdir -p "'"${PACK_FOLDER}"'/$(dirname "{}")"' \; -exec cp "{}" "${PACK_FOLDER}/{}" \;)

.github/workflows/ruby-qltest.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
paths:
66
- "ruby/**"
7-
- .github/workflows/ruby-qltest.yml
7+
- .github/workflows/ruby-build.yml
88
- .github/actions/fetch-codeql/action.yml
99
- codeql-workspace.yml
1010
branches:
@@ -28,16 +28,6 @@ defaults:
2828
working-directory: ruby
2929

3030
jobs:
31-
qlcompile:
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v3
35-
- uses: ./.github/actions/fetch-codeql
36-
- name: Check QL compilation
37-
run: |
38-
codeql query compile --check-only --threads=0 --ram 5000 --warnings=error "ql/src" "ql/examples"
39-
env:
40-
GITHUB_TOKEN: ${{ github.token }}
4131
qlupgrade:
4232
runs-on: ubuntu-latest
4333
steps:
@@ -58,17 +48,20 @@ jobs:
5848
xargs codeql execute upgrades testdb
5949
diff -q testdb/ruby.dbscheme downgrades/initial/ruby.dbscheme
6050
qltest:
61-
runs-on: ubuntu-latest
51+
runs-on: ubuntu-latest-xl
6252
strategy:
6353
fail-fast: false
64-
matrix:
65-
slice: ["1/2", "2/2"]
6654
steps:
6755
- uses: actions/checkout@v3
6856
- uses: ./.github/actions/fetch-codeql
6957
- uses: ./ruby/actions/create-extractor-pack
58+
- name: Cache compilation cache
59+
id: query-cache
60+
uses: ./.github/actions/cache-query-compilation
61+
with:
62+
key: ruby-qltest
7063
- name: Run QL tests
7164
run: |
72-
codeql test run --threads=0 --ram 5000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}/ruby/extractor-pack" --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test
65+
codeql test run --threads=0 --ram 52000 --search-path "${{ github.workspace }}/ruby/extractor-pack" --check-databases --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
7366
env:
7467
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/swift.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- 'swift/ql/lib/codeql/swift/elements/**'
4040
- 'swift/ql/lib/codeql/swift/generated/**'
4141
- 'swift/ql/test/extractor-tests/generated/**'
42+
- 'swift/ql/.generated.list'
4243
ql:
4344
- 'github/workflows/swift.yml'
4445
- 'swift/**/*.ql'

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ repos:
4444

4545
- id: swift-codegen
4646
name: Run Swift checked in code generation
47-
files: ^swift/(schema.py$|codegen/|.*/generated/|ql/lib/(swift\.dbscheme$|codeql/swift/elements))
47+
files: ^swift/(schema.py$|codegen/|.*/generated/|ql/lib/(swift\.dbscheme$|codeql/swift/elements)|ql/\.generated.list)
4848
language: system
4949
entry: bazel run //swift/codegen -- --quiet
5050
pass_filenames: false

cpp/ql/lib/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.4
2+
3+
No user-facing changes.
4+
15
## 0.4.3
26

37
### Minor Analysis Improvements
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: deprecated
3+
---
4+
5+
6+
* Deprecated `semmle.code.cpp.valuenumbering.GlobalValueNumberingImpl`. Use `semmle.code.cpp.valuenumbering.GlobalValueNumbering`, which exposes the same API.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: breaking
3+
---
4+
The predicates in the `MustFlow::Configuration` class used by the `MustFlow` library (`semmle.code.cpp.ir.dataflow.MustFlow`) have changed to be defined directly in terms of the C++ IR instead of IR dataflow nodes.

0 commit comments

Comments
 (0)