-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7410 from erik-krogh/erik-krogh/publish-ql-for-ql
Add QL for QL
- Loading branch information
Showing
145 changed files
with
40,880 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
name: Run QL for QL | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
queries: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Find codeql | ||
id: find-codeql | ||
uses: github/codeql-action/init@esbena/ql | ||
with: | ||
languages: javascript # does not matter | ||
- name: Get CodeQL version | ||
id: get-codeql-version | ||
run: | | ||
echo "::set-output name=version::$("${CODEQL}" --version | head -n 1 | rev | cut -d " " -f 1 | rev)" | ||
shell: bash | ||
env: | ||
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} | ||
- name: Cache queries | ||
id: cache-queries | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ runner.temp }}/query-pack.zip | ||
key: queries-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }} | ||
- name: Build query pack | ||
if: steps.cache-queries.outputs.cache-hit != 'true' | ||
run: | | ||
cd ql/ql/src | ||
"${CODEQL}" pack create | ||
cd .codeql/pack/codeql/ql-all/0.0.0 | ||
zip "${PACKZIP}" -r . | ||
env: | ||
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} | ||
PACKZIP: ${{ runner.temp }}/query-pack.zip | ||
- name: Upload query pack | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: query-pack-zip | ||
path: ${{ runner.temp }}/query-pack.zip | ||
|
||
extractors: | ||
strategy: | ||
fail-fast: false | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
ql/target | ||
key: ${{ runner.os }}-rust-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Check formatting | ||
run: cd ql; cargo fmt --all -- --check | ||
- name: Build | ||
run: cd ql; cargo build --verbose | ||
- name: Run tests | ||
run: cd ql; cargo test --verbose | ||
- name: Release build | ||
run: cd ql; cargo build --release | ||
- name: Generate dbscheme | ||
run: ql/target/release/ql-generator --dbscheme ql/ql/src/ql.dbscheme --library ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: extractor-ubuntu-latest | ||
path: | | ||
ql/target/release/ql-extractor | ||
ql/target/release/ql-extractor.exe | ||
retention-days: 1 | ||
package: | ||
runs-on: ubuntu-latest | ||
|
||
needs: | ||
- extractors | ||
- queries | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: query-pack-zip | ||
path: query-pack-zip | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: extractor-ubuntu-latest | ||
path: linux64 | ||
- run: | | ||
unzip query-pack-zip/*.zip -d pack | ||
cp -r ql/codeql-extractor.yml ql/tools ql/ql/src/ql.dbscheme.stats pack/ | ||
mkdir -p pack/tools/linux64 | ||
if [[ -f linux64/ql-extractor ]]; then | ||
cp linux64/ql-extractor pack/tools/linux64/extractor | ||
chmod +x pack/tools/linux64/extractor | ||
fi | ||
cd pack | ||
zip -rq ../codeql-ql.zip . | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: codeql-ql-pack | ||
path: codeql-ql.zip | ||
retention-days: 1 | ||
analyze: | ||
runs-on: ubuntu-latest | ||
|
||
needs: | ||
- package | ||
|
||
steps: | ||
- name: Download pack | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: codeql-ql-pack | ||
path: ${{ runner.temp }}/codeql-ql-pack-artifact | ||
|
||
- name: Prepare pack | ||
run: | | ||
unzip "${PACK_ARTIFACT}/*.zip" -d "${PACK}" | ||
env: | ||
PACK_ARTIFACT: ${{ runner.temp }}/codeql-ql-pack-artifact | ||
PACK: ${{ runner.temp }}/pack | ||
- name: Hack codeql-action options | ||
run: | | ||
JSON=$(jq -nc --arg pack "${PACK}" '.resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .database.init=["--search-path", $pack]') | ||
echo "CODEQL_ACTION_EXTRA_OPTIONS=${JSON}" >> ${GITHUB_ENV} | ||
env: | ||
PACK: ${{ runner.temp }}/pack | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@esbena/ql | ||
with: | ||
languages: ql | ||
db-location: ${{ runner.temp }}/db | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@esbena/ql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Collect database stats for QL for QL | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- ql/ql/src/ql.dbscheme | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- ql/ql/src/ql.dbscheme | ||
workflow_dispatch: | ||
|
||
jobs: | ||
measure: | ||
env: | ||
CODEQL_THREADS: 4 # TODO: remove this once it's set by the CLI | ||
strategy: | ||
matrix: | ||
repo: | ||
- github/codeql | ||
- github/codeql-go | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Find codeql | ||
id: find-codeql | ||
uses: github/codeql-action/init@esbena/ql | ||
with: | ||
languages: javascript # does not matter | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
ql/target | ||
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Build Extractor | ||
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./create-extractor-pack.sh | ||
env: | ||
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} | ||
- name: Checkout ${{ matrix.repo }} | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: ${{ matrix.repo }} | ||
path: ${{ github.workspace }}/repo | ||
- name: Create database | ||
run: | | ||
"${CODEQL}" database create \ | ||
--search-path "ql/extractor-pack" \ | ||
--threads 4 \ | ||
--language ql --source-root "${{ github.workspace }}/repo" \ | ||
"${{ runner.temp }}/database" | ||
env: | ||
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} | ||
- name: Measure database | ||
run: | | ||
mkdir -p "stats/${{ matrix.repo }}" | ||
"${CODEQL}" dataset measure --threads 4 --output "stats/${{ matrix.repo }}/stats.xml" "${{ runner.temp }}/database/db-ql" | ||
env: | ||
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: measurements | ||
path: stats | ||
retention-days: 1 | ||
|
||
merge: | ||
runs-on: ubuntu-latest | ||
needs: measure | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: measurements | ||
path: stats | ||
- run: | | ||
python -m pip install --user lxml | ||
find stats -name 'stats.xml' -print0 | sort -z | xargs -0 python ql/scripts/merge_stats.py --output ql/ql/src/ql.dbscheme.stats --normalise ql_tokeninfo | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: ql.dbscheme.stats | ||
path: ql/ql/src/ql.dbscheme.stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Run QL for QL Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- ql/* | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- ql/* | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
qltest: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Find codeql | ||
id: find-codeql | ||
uses: github/codeql-action/init@esbena/ql | ||
with: | ||
languages: javascript # does not matter | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
ql/target | ||
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Build extractor | ||
run: | | ||
cd ql; | ||
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }}); | ||
env "PATH=$PATH:$codeqlpath" ./create-extractor-pack.sh | ||
- name: Run QL tests | ||
run: | | ||
"${CODEQL}" test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path "${{ github.workspace }}/ql/extractor-pack" --consistency-queries ql/ql/consistency-queries ql/ql/test | ||
env: | ||
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} | ||
- name: Check QL formatting | ||
run: | | ||
find ql/ql "(" -name "*.ql" -or -name "*.qll" ")" -print0 | xargs -0 "${CODEQL}" query format --check-only | ||
env: | ||
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} | ||
- name: Check QL compilation | ||
run: | | ||
"${CODEQL}" query compile --check-only --threads=4 --warnings=error --search-path "${{ github.workspace }}/ql/extractor-pack" "ql/ql/src" "ql/ql/examples" | ||
env: | ||
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Cargo.lock -diff -whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
target | ||
extractor-pack | ||
.vscode/launch.json | ||
.cache | ||
ql/test/**/*.testproj | ||
ql/test/**/*.actual | ||
ql/test/**/CONSISTENCY | ||
work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "cargo", | ||
"subcommand": "build", | ||
"problemMatcher": [ | ||
"$rustc" | ||
], | ||
"group": "build", | ||
"label": "Rust: cargo build" | ||
} | ||
] | ||
} |
Oops, something went wrong.