Skip to content

Commit 51bd1ef

Browse files
authored
Merge pull request #11884 from erik-krogh/qlWin
QL/Ryby: fix qltest on Windows
2 parents bd56191 + 7135999 commit 51bd1ef

File tree

5 files changed

+70
-23
lines changed

5 files changed

+70
-23
lines changed

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

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,73 @@ jobs:
3333
~/.cargo/registry
3434
~/.cargo/git
3535
ql/target
36-
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
36+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/rust-toolchain.toml', 'ql/**/Cargo.lock') }}
3737
- name: Build extractor
3838
run: |
3939
cd ql;
4040
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
4141
env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh
42+
- name: Cache compilation cache
43+
id: query-cache
44+
uses: ./.github/actions/cache-query-compilation
45+
with:
46+
key: ql-for-ql-tests
4247
- name: Run QL tests
4348
run: |
44-
"${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
49+
"${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 --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" ql/ql/test
4550
env:
4651
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
47-
- name: Check QL formatting
52+
53+
other-os:
54+
strategy:
55+
matrix:
56+
os: [macos-latest, windows-latest]
57+
needs: [qltest]
58+
runs-on: ${{ matrix.os }}
59+
steps:
60+
- uses: actions/checkout@v3
61+
- name: Install GNU tar
62+
if: runner.os == 'macOS'
63+
run: |
64+
brew install gnu-tar
65+
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
66+
- name: Find codeql
67+
id: find-codeql
68+
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683
69+
with:
70+
languages: javascript # does not matter
71+
- uses: ./.github/actions/os-version
72+
id: os_version
73+
- uses: actions/cache@v3
74+
with:
75+
path: |
76+
~/.cargo/registry
77+
~/.cargo/git
78+
ql/target
79+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/rust-toolchain.toml', 'ql/**/Cargo.lock') }}
80+
- name: Build extractor
81+
if: runner.os != 'Windows'
82+
run: |
83+
cd ql;
84+
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
85+
env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh
86+
- name: Build extractor (Windows)
87+
if: runner.os == 'Windows'
88+
shell: pwsh
4889
run: |
49-
find ql/ql/src "(" -name "*.ql" -or -name "*.qll" ")" -print0 | xargs -0 "${CODEQL}" query format --check-only
90+
cd ql;
91+
$Env:PATH += ";$(dirname ${{ steps.find-codeql.outputs.codeql-path }})"
92+
pwsh ./scripts/create-extractor-pack.ps1
93+
- name: Run a single QL tests - Unix
94+
if: runner.os != 'Windows'
95+
run: |
96+
"${CODEQL}" test run --check-databases --search-path "${{ github.workspace }}/ql/extractor-pack" ql/ql/test/queries/style/DeadCode/DeadCode.qlref
5097
env:
5198
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
99+
- name: Run a single QL tests - Windows
100+
if: runner.os == 'Windows'
101+
shell: pwsh
102+
run: |
103+
$Env:PATH += ";$(dirname ${{ steps.find-codeql.outputs.codeql-path }})"
104+
codeql test run --check-databases --search-path "${{ github.workspace }}/ql/extractor-pack" ql/ql/test/queries/style/DeadCode/DeadCode.qlref
105+

.github/workflows/ruby-build.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ jobs:
205205
- name: Fetch CodeQL
206206
uses: ./.github/actions/fetch-codeql
207207

208-
- uses: actions/checkout@v3
209-
with:
210-
repository: Shopify/example-ruby-app
211-
ref: 67a0decc5eb550f3a9228eda53925c3afd40dfe9
212-
213208
- name: Download Ruby bundle
214209
uses: actions/download-artifact@v3
215210
with:
@@ -218,26 +213,15 @@ jobs:
218213
- name: Unzip Ruby bundle
219214
shell: bash
220215
run: unzip -q -d "${{ runner.temp }}/ruby-bundle" "${{ runner.temp }}/codeql-ruby-bundle.zip"
221-
- name: Prepare test files
222-
shell: bash
223-
run: |
224-
echo "import codeql.ruby.AST select count(File f)" > "test.ql"
225-
echo "| 4 |" > "test.expected"
226-
echo 'name: sample-tests
227-
version: 0.0.0
228-
dependencies:
229-
codeql/ruby-all: "*"
230-
extractor: ruby
231-
tests: .
232-
' > qlpack.yml
216+
233217
- name: Run QL test
234218
shell: bash
235219
run: |
236-
codeql test run --search-path "${{ runner.temp }}/ruby-bundle" --additional-packs "${{ runner.temp }}/ruby-bundle" .
220+
codeql test run --search-path "${{ runner.temp }}/ruby-bundle" --additional-packs "${{ runner.temp }}/ruby-bundle" ruby/ql/test/library-tests/ast/constants/
237221
- name: Create database
238222
shell: bash
239223
run: |
240-
codeql database create --search-path "${{ runner.temp }}/ruby-bundle" --language ruby --source-root . ../database
224+
codeql database create --search-path "${{ runner.temp }}/ruby-bundle" --language ruby --source-root ruby/ql/test/library-tests/ast/constants/ ../database
241225
- name: Analyze database
242226
shell: bash
243227
run: |

ql/rust-toolchain.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file specifies the Rust version used to develop and test the QL
2+
# extractor. It is set to the lowest version of Rust we want to support.
3+
4+
[toolchain]
5+
channel = "1.54"
6+
profile = "minimal"
7+
components = [ "rustfmt" ]

ql/tools/qltest.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type NUL && "%CODEQL_DIST%\codeql.exe" database index-files ^
88
--include-extension=.yml ^
99
--size-limit=5m ^
1010
--language=ql ^
11+
--working-dir=. ^
1112
"%CODEQL_EXTRACTOR_QL_WIP_DATABASE%"
1213

1314
exit /b %ERRORLEVEL%

ruby/tools/qltest.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type NUL && "%CODEQL_DIST%\codeql.exe" database index-files ^
88
--include=**/Gemfile ^
99
--size-limit=5m ^
1010
--language=ruby ^
11+
--working-dir=. ^
1112
"%CODEQL_EXTRACTOR_RUBY_WIP_DATABASE%"
1213

1314
exit /b %ERRORLEVEL%

0 commit comments

Comments
 (0)