Skip to content

Commit 9b4b29c

Browse files
authored
Merge branch 'main' into redsun82/swift-integration-test-pack
2 parents 414f18f + 3c7f751 commit 9b4b29c

File tree

258 files changed

+8185
-2380
lines changed

Some content is hidden

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

258 files changed

+8185
-2380
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ runs:
2626
echo "merge_base=$MERGE_BASE" >> $GITHUB_ENV
2727
- name: Read CodeQL query compilation - PR
2828
if: ${{ github.event_name == 'pull_request' }}
29-
uses: actions/cache@v3
29+
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
3030
with:
3131
path: '**/.cache'
32+
read-only: true
3233
key: codeql-compile-${{ inputs.key }}-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
3334
restore-keys: |
3435
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
3536
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-
3637
codeql-compile-${{ inputs.key }}-main-
3738
- name: Fill CodeQL query compilation cache - main
3839
if: ${{ github.event_name != 'pull_request' }}
39-
uses: actions/cache@v3
40+
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
4041
with:
4142
path: '**/.cache'
4243
key: codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main

.github/workflows/csharp-qltest.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: "C#: Run QL Tests"
2+
3+
on:
4+
push:
5+
paths:
6+
- "csharp/**"
7+
- "shared/**"
8+
- .github/actions/fetch-codeql/action.yml
9+
- codeql-workspace.yml
10+
branches:
11+
- main
12+
- "rc/*"
13+
pull_request:
14+
paths:
15+
- "csharp/**"
16+
- "shared/**"
17+
- .github/workflows/csharp-qltest.yml
18+
- .github/actions/fetch-codeql/action.yml
19+
- codeql-workspace.yml
20+
branches:
21+
- main
22+
- "rc/*"
23+
24+
defaults:
25+
run:
26+
working-directory: csharp
27+
28+
jobs:
29+
qlupgrade:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: ./.github/actions/fetch-codeql
34+
- name: Check DB upgrade scripts
35+
run: |
36+
echo >empty.trap
37+
codeql dataset import -S ql/lib/upgrades/initial/semmlecode.csharp.dbscheme testdb empty.trap
38+
codeql dataset upgrade testdb --additional-packs ql/lib
39+
diff -q testdb/semmlecode.csharp.dbscheme ql/lib/semmlecode.csharp.dbscheme
40+
- name: Check DB downgrade scripts
41+
run: |
42+
echo >empty.trap
43+
rm -rf testdb; codeql dataset import -S ql/lib/semmlecode.csharp.dbscheme testdb empty.trap
44+
codeql resolve upgrades --format=lines --allow-downgrades --additional-packs downgrades \
45+
--dbscheme=ql/lib/semmlecode.csharp.dbscheme --target-dbscheme=downgrades/initial/semmlecode.csharp.dbscheme |
46+
xargs codeql execute upgrades testdb
47+
diff -q testdb/semmlecode.csharp.dbscheme downgrades/initial/semmlecode.csharp.dbscheme
48+
qltest:
49+
runs-on: ubuntu-latest-xl
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
slice: ["1/2", "2/2"]
54+
steps:
55+
- uses: actions/checkout@v3
56+
- uses: ./.github/actions/fetch-codeql
57+
- uses: ./csharp/actions/create-extractor-pack
58+
- name: Cache compilation cache
59+
id: query-cache
60+
uses: ./.github/actions/cache-query-compilation
61+
with:
62+
key: csharp-qltest-${{ matrix.slice }}
63+
- name: Run QL tests
64+
run: |
65+
CODEQL_PATH=$(gh codeql version --format=json | jq -r .unpackedLocation)
66+
# The legacy ASP extractor is not in this repo, so take the one from the nightly build
67+
mv "$CODEQL_PATH/csharp/tools/extractor-asp.jar" "${{ github.workspace }}/csharp/extractor-pack/tools"
68+
# Safe guard against using the bundled extractor
69+
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 }}"
71+
env:
72+
GITHUB_TOKEN: ${{ github.token }}
73+
unit-tests:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v3
77+
- name: Setup dotnet
78+
uses: actions/setup-dotnet@v3
79+
with:
80+
dotnet-version: 6.0.202
81+
- name: Extractor unit tests
82+
run: |
83+
dotnet test -p:RuntimeFrameworkVersion=6.0.4 "${{ github.workspace }}/csharp/extractor/Semmle.Util.Tests"
84+
dotnet test -p:RuntimeFrameworkVersion=6.0.4 "${{ github.workspace }}/csharp/extractor/Semmle.Extraction.Tests"
85+
dotnet test -p:RuntimeFrameworkVersion=6.0.4 "${{ github.workspace }}/csharp/autobuilder/Semmle.Autobuild.CSharp.Tests"
86+
dotnet test -p:RuntimeFrameworkVersion=6.0.4 "${{ github.workspace }}/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests"

.github/workflows/ruby-build.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,39 @@ jobs:
4848
run: |
4949
brew install gnu-tar
5050
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
51+
- name: Cache entire extractor
52+
uses: actions/cache@v3
53+
id: cache-extractor
54+
with:
55+
path: |
56+
ruby/target/release/ruby-autobuilder
57+
ruby/target/release/ruby-autobuilder.exe
58+
ruby/target/release/ruby-extractor
59+
ruby/target/release/ruby-extractor.exe
60+
ruby/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
61+
key: ${{ runner.os }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
5162
- uses: actions/cache@v3
63+
if: steps.cache-extractor.outputs.cache-hit != 'true'
5264
with:
5365
path: |
5466
~/.cargo/registry
5567
~/.cargo/git
5668
ruby/target
5769
key: ${{ runner.os }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
5870
- name: Check formatting
71+
if: steps.cache-extractor.outputs.cache-hit != 'true'
5972
run: cargo fmt --all -- --check
6073
- name: Build
74+
if: steps.cache-extractor.outputs.cache-hit != 'true'
6175
run: cargo build --verbose
6276
- name: Run tests
77+
if: steps.cache-extractor.outputs.cache-hit != 'true'
6378
run: cargo test --verbose
6479
- name: Release build
80+
if: steps.cache-extractor.outputs.cache-hit != 'true'
6581
run: cargo build --release
6682
- name: Generate dbscheme
67-
if: ${{ matrix.os == 'ubuntu-latest' }}
83+
if: ${{ matrix.os == 'ubuntu-latest' && steps.cache-extractor.outputs.cache-hit != 'true'}}
6884
run: target/release/ruby-generator --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
6985
- uses: actions/upload-artifact@v3
7086
if: ${{ matrix.os == 'ubuntu-latest' }}

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
# It's useful (though not required) to be able to unpack codeql in the ql checkout itself
2828
/codeql/
2929

30-
csharp/extractor/Semmle.Extraction.CSharp.Driver/Properties/launchSettings.json
31-
3230
# Avoid committing cached package components
3331
.codeql
3432

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"omnisharp.autoStart": false
2+
"omnisharp.autoStart": false,
3+
"cmake.sourceDirectory": "${workspaceFolder}/swift",
4+
"cmake.buildDirectory": "${workspaceFolder}/bazel-cmake-build"
35
}

CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/javascript/ @github/codeql-javascript
66
/python/ @github/codeql-python
77
/ruby/ @github/codeql-ruby
8-
/swift/ @github/codeql-c
8+
/swift/ @github/codeql-swift
99
/java/kotlin-extractor/ @github/codeql-kotlin
1010
/java/kotlin-explorer/ @github/codeql-kotlin
1111

@@ -45,4 +45,4 @@ WORKSPACE.bazel @github/codeql-ci-reviewers
4545
/.github/workflows/js-ml-tests.yml @github/codeql-ml-powered-queries-reviewers
4646
/.github/workflows/ql-for-ql-* @github/codeql-ql-for-ql-reviewers
4747
/.github/workflows/ruby-* @github/codeql-ruby
48-
/.github/workflows/swift.yml @github/codeql-c
48+
/.github/workflows/swift.yml @github/codeql-swift

codeql-workspace.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ provide:
2626
- "ruby/extractor-pack/codeql-extractor.yml"
2727
- "swift/extractor-pack/codeql-extractor.yml"
2828
- "swift/integration-tests/qlpack.yml"
29-
- "ql/extractor-pack/codeql-extractor.ym"
29+
- "ql/extractor-pack/codeql-extractor.yml"
3030

3131
versionPolicies:
3232
default:

cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ CppAutobuilder CreateAutoBuilder(bool isWindows,
257257
Actions.GetCurrentDirectory = cwd;
258258
Actions.IsWindows = isWindows;
259259

260-
var options = new AutobuildOptions(Actions, Language.Cpp);
260+
var options = new CppAutobuildOptions(Actions);
261261
return new CppAutobuilder(Actions, options);
262262
}
263263

264-
void TestAutobuilderScript(Autobuilder autobuilder, int expectedOutput, int commandsRun)
264+
void TestAutobuilderScript(CppAutobuilder autobuilder, int expectedOutput, int commandsRun)
265265
{
266266
Assert.Equal(expectedOutput, autobuilder.GetBuildScript().Run(Actions, StartCallback, EndCallback));
267267

@@ -299,7 +299,7 @@ public void TestCppAutobuilderSuccess()
299299
{
300300
Actions.RunProcess[@"cmd.exe /C nuget restore C:\Project\test.sln -DisableParallelProcessing"] = 1;
301301
Actions.RunProcess[@"cmd.exe /C C:\Project\.nuget\nuget.exe restore C:\Project\test.sln -DisableParallelProcessing"] = 0;
302-
Actions.RunProcess[@"cmd.exe /C CALL ^""C:\Program Files ^(x86^)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat^"" && set Platform=&& type NUL && C:\odasa\tools\odasa index --auto msbuild C:\Project\test.sln /t:rebuild /p:Platform=""x86"" /p:Configuration=""Release"" /p:MvcBuildViews=true"] = 0;
302+
Actions.RunProcess[@"cmd.exe /C CALL ^""C:\Program Files ^(x86^)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat^"" && set Platform=&& type NUL && msbuild C:\Project\test.sln /t:rebuild /p:Platform=""x86"" /p:Configuration=""Release"""] = 0;
303303
Actions.RunProcessOut[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationPath"] = "";
304304
Actions.RunProcess[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationPath"] = 1;
305305
Actions.RunProcess[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationVersion"] = 0;

cpp/autobuilder/Semmle.Autobuild.Cpp/CppAutobuilder.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,26 @@
22

33
namespace Semmle.Autobuild.Cpp
44
{
5-
public class CppAutobuilder : Autobuilder
5+
/// <summary>
6+
/// Encapsulates C++ build options.
7+
/// </summary>
8+
public class CppAutobuildOptions : AutobuildOptionsShared
69
{
7-
public CppAutobuilder(IBuildActions actions, AutobuildOptions options) : base(actions, options) { }
10+
public override Language Language => Language.Cpp;
11+
12+
13+
/// <summary>
14+
/// Reads options from environment variables.
15+
/// Throws ArgumentOutOfRangeException for invalid arguments.
16+
/// </summary>
17+
public CppAutobuildOptions(IBuildActions actions) : base(actions)
18+
{
19+
}
20+
}
21+
22+
public class CppAutobuilder : Autobuilder<CppAutobuildOptions>
23+
{
24+
public CppAutobuilder(IBuildActions actions, CppAutobuildOptions options) : base(actions, options) { }
825

926
public override BuildScript GetBuildScript()
1027
{

cpp/autobuilder/Semmle.Autobuild.Cpp/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ static int Main()
1111
try
1212
{
1313
var actions = SystemBuildActions.Instance;
14-
var options = new AutobuildOptions(actions, Language.Cpp);
14+
var options = new CppAutobuildOptions(actions);
1515
try
1616
{
1717
Console.WriteLine("CodeQL C++ autobuilder");
1818
var builder = new CppAutobuilder(actions, options);
1919
return builder.AttemptBuild();
2020
}
21-
catch(InvalidEnvironmentException ex)
21+
catch (InvalidEnvironmentException ex)
2222
{
2323
Console.WriteLine("The environment is invalid: {0}", ex.Message);
2424
}

0 commit comments

Comments
 (0)