Skip to content

Commit 7dca1b4

Browse files
authored
Merge branch 'main' into atorralba/swift/path-injection
2 parents bf80840 + 5b31da4 commit 7dca1b4

File tree

772 files changed

+51704
-78644
lines changed

Some content is hidden

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

772 files changed

+51704
-78644
lines changed

.github/ISSUE_TEMPLATE/ql---general.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ assignees: ''
1010
**Description of the issue**
1111

1212
<!-- Please explain briefly what is the problem.
13-
If it is about an LGTM project, please include its URL.-->
13+
If it is about a GitHub project, please include its URL. -->
1414

.github/actions/cache-query-compilation/action.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ outputs:
1414
runs:
1515
using: composite
1616
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.
17+
# calculate the merge-base with main, in a way that works both on PRs and pushes to main.
1918
- name: Calculate merge-base
2019
shell: bash
2120
if: ${{ github.event_name == 'pull_request' }}
@@ -24,38 +23,33 @@ runs:
2423
run: |
2524
MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
2625
echo "merge_base=$MERGE_BASE" >> $GITHUB_ENV
27-
- name: Read CodeQL query compilation - PR
26+
- name: Restore read-only cache (PR)
2827
if: ${{ github.event_name == 'pull_request' }}
2928
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
3029
with:
3130
path: '**/.cache'
3231
read-only: true
33-
key: codeql-compile-${{ inputs.key }}-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
32+
key: codeql-compile-${{ inputs.key }}-pr-${{ github.sha }}
3433
restore-keys: |
3534
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
3635
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-
3736
codeql-compile-${{ inputs.key }}-main-
38-
- name: Fill CodeQL query compilation cache - main
37+
- name: Fill cache (push)
3938
if: ${{ github.event_name != 'pull_request' }}
4039
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
4140
with:
4241
path: '**/.cache'
4342
key: codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main
44-
restore-keys: | # restore from another random commit, to speed up compilation.
45-
codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-
43+
restore-keys: | # restore the latest cache if the exact cache is unavailable, to speed up compilation.
44+
codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-
4645
codeql-compile-${{ inputs.key }}-main-
4746
- name: Fill compilation cache directory
4847
id: fill-compilation-dir
49-
shell: bash
48+
shell: bash
5049
run: |
5150
# Move all the existing cache into another folder, so we only preserve the cache for the current queries.
52-
mkdir -p ${COMBINED_CACHE_DIR}
53-
rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
54-
# copy the contents of the .cache folders into the combined cache folder.
55-
cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
56-
# clean up the .cache folders
57-
rm -rf **/.cache/*
51+
node $GITHUB_WORKSPACE/.github/actions/cache-query-compilation/move-caches.js ${COMBINED_CACHE_DIR}
5852
5953
echo "compdir=${COMBINED_CACHE_DIR}" >> $GITHUB_OUTPUT
60-
env:
61-
COMBINED_CACHE_DIR: ${{ github.workspace }}/compilation-dir
54+
env:
55+
COMBINED_CACHE_DIR: ${{ runner.temp }}/compilation-dir
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// # Move all the existing cache into another folder, so we only preserve the cache for the current queries.
2+
// mkdir -p ${COMBINED_CACHE_DIR}
3+
// rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
4+
// # copy the contents of the .cache folders into the combined cache folder.
5+
// cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
6+
// # clean up the .cache folders
7+
// rm -rf **/.cache/*
8+
9+
const fs = require("fs");
10+
const path = require("path");
11+
12+
// the first argv is the cache folder to create.
13+
const COMBINED_CACHE_DIR = process.argv[2];
14+
15+
function* walkCaches(dir) {
16+
const files = fs.readdirSync(dir, { withFileTypes: true });
17+
for (const file of files) {
18+
if (file.isDirectory()) {
19+
const filePath = path.join(dir, file.name);
20+
yield* walkCaches(filePath);
21+
if (file.name === ".cache") {
22+
yield filePath;
23+
}
24+
}
25+
}
26+
}
27+
28+
async function copyDir(src, dest) {
29+
for await (const file of await fs.promises.readdir(src, { withFileTypes: true })) {
30+
const srcPath = path.join(src, file.name);
31+
const destPath = path.join(dest, file.name);
32+
if (file.isDirectory()) {
33+
if (!fs.existsSync(destPath)) {
34+
fs.mkdirSync(destPath);
35+
}
36+
await copyDir(srcPath, destPath);
37+
} else {
38+
await fs.promises.copyFile(srcPath, destPath);
39+
}
40+
}
41+
}
42+
43+
async function main() {
44+
const cacheDirs = [...walkCaches(".")];
45+
46+
for (const dir of cacheDirs) {
47+
console.log(`Found .cache dir at ${dir}`);
48+
}
49+
50+
// mkdir -p ${COMBINED_CACHE_DIR}
51+
fs.mkdirSync(COMBINED_CACHE_DIR, { recursive: true });
52+
53+
// rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
54+
await Promise.all(
55+
cacheDirs.map((cacheDir) =>
56+
(async function () {
57+
await fs.promises.rm(path.join(cacheDir, "lock"), { force: true });
58+
await fs.promises.rm(path.join(cacheDir, "size"), { force: true });
59+
})()
60+
)
61+
);
62+
63+
// # copy the contents of the .cache folders into the combined cache folder.
64+
// cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
65+
await Promise.all(
66+
cacheDirs.map((cacheDir) => copyDir(cacheDir, COMBINED_CACHE_DIR))
67+
);
68+
69+
// # clean up the .cache folders
70+
// rm -rf **/.cache/*
71+
await Promise.all(
72+
cacheDirs.map((cacheDir) => fs.promises.rm(cacheDir, { recursive: true }))
73+
);
74+
}
75+
main();

.github/workflows/compile-queries.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,3 @@ jobs:
3535
if : ${{ github.event_name != 'pull_request' }}
3636
shell: bash
3737
run: codeql query compile -j0 */ql/{src,examples} --keep-going --warnings=error --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
38-
env:
39-
COMBINED_CACHE_DIR: ${{ github.workspace }}/compilation-dir

.github/workflows/csharp-qltest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
mv "$CODEQL_PATH/csharp/tools/extractor-asp.jar" "${{ github.workspace }}/csharp/extractor-pack/tools"
6868
# Safe guard against using the bundled extractor
6969
rm -rf "$CODEQL_PATH/csharp"
70-
codeql test run --threads=0 --ram 52000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}/csharp/extractor-pack" --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
70+
codeql test run --threads=0 --ram 50000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}/csharp/extractor-pack" --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
7171
env:
7272
GITHUB_TOKEN: ${{ github.token }}
7373
unit-tests:

.github/workflows/go-tests-other-os.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ on:
55
- "go/**"
66
- "!go/ql/**" # don't run other-os if only ql/ files changed
77
- .github/workflows/go-tests-other-os.yml
8-
- .github/actions/fetch-codeql/action.yml
9-
- .github/actions/cache-query-compilation/action.yml
8+
- .github/actions/**
109
- codeql-workspace.yml
1110
jobs:
1211
test-mac:

.github/workflows/go-tests.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ on:
44
paths:
55
- "go/**"
66
- .github/workflows/go-tests.yml
7-
- .github/actions/fetch-codeql/action.yml
8-
- .github/actions/cache-query-compilation/action.yml
7+
- .github/actions/**
98
- codeql-workspace.yml
109
branches:
1110
- main
@@ -14,8 +13,7 @@ on:
1413
paths:
1514
- "go/**"
1615
- .github/workflows/go-tests.yml
17-
- .github/actions/fetch-codeql/action.yml
18-
- .github/actions/cache-query-compilation/action.yml
16+
- .github/actions/**
1917
- codeql-workspace.yml
2018
jobs:
2119
test-linux:
@@ -64,7 +62,7 @@ jobs:
6462
uses: ./.github/actions/cache-query-compilation
6563
with:
6664
key: go-qltest
67-
65+
6866
- name: Test
6967
run: |
7068
cd go

.github/workflows/js-ml-tests.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,43 @@ defaults:
2323
working-directory: javascript/ql/experimental/adaptivethreatmodeling
2424

2525
jobs:
26-
qlcompile:
27-
name: Check QL compilation
28-
runs-on: ubuntu-latest
26+
qltest:
27+
name: Test QL
28+
runs-on: ubuntu-latest-xl
2929
steps:
3030
- uses: actions/checkout@v3
3131

3232
- uses: ./.github/actions/fetch-codeql
3333

3434
- name: Install pack dependencies
3535
run: |
36-
for pack in modelbuilding src; do
36+
for pack in modelbuilding src test; do
3737
codeql pack install --mode verify -- "${pack}"
3838
done
39+
40+
- name: Cache compilation cache
41+
id: query-cache
42+
uses: ./.github/actions/cache-query-compilation
43+
with:
44+
key: js-ml-test
3945

4046
- name: Check QL compilation
4147
run: |
4248
codeql query compile \
4349
--check-only \
44-
--ram 5120 \
50+
--ram 50000 \
4551
--additional-packs "${{ github.workspace }}" \
4652
--threads=0 \
53+
--compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" \
4754
-- \
4855
lib modelbuilding src
4956
50-
qltest:
51-
name: Run QL tests
52-
runs-on: ubuntu-latest
53-
steps:
54-
- uses: actions/checkout@v3
55-
56-
- uses: ./.github/actions/fetch-codeql
57-
58-
- name: Install pack dependencies
59-
run: codeql pack install -- test
60-
6157
- name: Run QL tests
6258
run: |
6359
codeql test run \
6460
--threads=0 \
65-
--ram 5120 \
61+
--ram 50000 \
6662
--additional-packs "${{ github.workspace }}" \
63+
--compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" \
6764
-- \
68-
test
65+
test

.github/workflows/ruby-qltest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ jobs:
6262
key: ruby-qltest
6363
- name: Run QL tests
6464
run: |
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 }}"
65+
codeql test run --threads=0 --ram 50000 --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 }}"
6666
env:
6767
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/swift.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ on:
77
- "misc/bazel/**"
88
- "*.bazel*"
99
- .github/workflows/swift.yml
10-
- .github/actions/fetch-codeql/action.yml
11-
- .github/actions/cache-query-compilation/action.yml
10+
- .github/actions/**
1211
- codeql-workspace.yml
1312
- .pre-commit-config.yaml
1413
- "!**/*.md"
@@ -22,8 +21,7 @@ on:
2221
- "misc/bazel/**"
2322
- "*.bazel*"
2423
- .github/workflows/swift.yml
25-
- .github/actions/fetch-codeql/action.yml
26-
- .github/actions/cache-query-compilation/action.yml
24+
- .github/actions/**
2725
- codeql-workspace.yml
2826
- "!**/*.md"
2927
- "!**/*.qhelp"
@@ -35,20 +33,15 @@ jobs:
3533
# not using a matrix as you cannot depend on a specific job in a matrix, and we want to start linux checks
3634
# without waiting for the macOS build
3735
build-and-test-macos:
38-
if: ${{ github.event_name == 'pull_request' }}
3936
runs-on: macos-12-xl
4037
steps:
4138
- uses: actions/checkout@v3
42-
- uses: ./swift/actions/create-extractor-pack
43-
- uses: ./swift/actions/run-quick-tests
44-
- uses: ./swift/actions/print-unextracted
39+
- uses: ./swift/actions/build-and-test
4540
build-and-test-linux:
4641
runs-on: ubuntu-latest-xl
4742
steps:
4843
- uses: actions/checkout@v3
49-
- uses: ./swift/actions/create-extractor-pack
50-
- uses: ./swift/actions/run-quick-tests
51-
- uses: ./swift/actions/print-unextracted
44+
- uses: ./swift/actions/build-and-test
5245
qltests-linux:
5346
needs: build-and-test-linux
5447
runs-on: ubuntu-latest-xl
@@ -80,7 +73,10 @@ jobs:
8073
runs-on: ubuntu-latest
8174
steps:
8275
- uses: actions/checkout@v3
83-
- uses: ./swift/actions/setup-env
76+
- uses: bazelbuild/setup-bazelisk@v2
77+
- uses: actions/setup-python@v4
78+
with:
79+
python-version-file: 'swift/.python-version'
8480
- uses: pre-commit/[email protected]
8581
name: Check that python code is properly formatted
8682
with:

0 commit comments

Comments
 (0)