Skip to content

Commit e966c33

Browse files
authored
Merge pull request #203 from henrymercer/run-codeql-tests-on-actions
Add support for running unit tests requiring CodeQL on Actions
2 parents 3fb0624 + 1ad2ed8 commit e966c33

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,25 @@ jobs:
5454
npm run build-ci
5555
shell: bash
5656

57-
- name: Run unit tests
57+
- name: Install CodeQL
58+
run: |
59+
mkdir codeql-home
60+
curl -L --silent https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql.zip -o codeql-home/codeql.zip
61+
unzip -q -o codeql-home/codeql.zip -d codeql-home
62+
rm codeql-home/codeql.zip
63+
shell: bash
64+
65+
- name: Run unit tests (Linux)
66+
if: matrix.os == 'ubuntu-latest'
67+
run: |
68+
cd extensions/ql-vscode
69+
CODEQL_PATH=$GITHUB_WORKSPACE/codeql-home/codeql/codeql npm run test
70+
71+
- name: Run unit tests (Windows)
72+
if: matrix.os == 'windows-latest'
5873
run: |
5974
cd extensions/ql-vscode
75+
$env:CODEQL_PATH=$(Join-Path $env:GITHUB_WORKSPACE -ChildPath 'codeql-home/codeql/codeql.cmd')
6076
npm run test
6177
6278
- name: Run integration tests (Linux)

extensions/ql-vscode/test/pure-tests/query-test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ describe('using the query server', function () {
8686
const codeQlPath = process.env["CODEQL_PATH"]!;
8787
let qs: qsClient.QueryServerClient;
8888
let cliServer: cli.CodeQLCliServer;
89+
const queryServerStarted = new Checkpoint<void>();
8990
after(() => {
9091
if (qs) {
9192
qs.dispose();
@@ -122,6 +123,7 @@ describe('using the query server', function () {
122123
task => task(consoleProgressReporter, token)
123124
);
124125
await qs.startQueryServer();
126+
queryServerStarted.resolve();
125127
});
126128

127129
// Note this does not work with arrow functions as the test case bodies:
@@ -132,8 +134,10 @@ describe('using the query server', function () {
132134
const queryName = path.basename(queryTestCase.queryPath);
133135
const compilationSucceeded = new Checkpoint<void>();
134136
const evaluationSucceeded = new Checkpoint<void>();
137+
const parsedResults = new Checkpoint<void>();
135138

136139
it(`should be able to compile query ${queryName}`, async function () {
140+
await queryServerStarted.done();
137141
expect(fs.existsSync(queryTestCase.queryPath)).to.be.true;
138142
try {
139143
const qlProgram: messages.QlProgram = {
@@ -209,6 +213,7 @@ describe('using the query server', function () {
209213
}
210214
actualResultSets[reader.schema.name] = actualRows;
211215
}
216+
parsedResults.resolve();
212217
} finally {
213218
if (fileReader) {
214219
fileReader.dispose();
@@ -217,6 +222,7 @@ describe('using the query server', function () {
217222
});
218223

219224
it(`should have correct results for query ${queryName}`, async function () {
225+
await parsedResults.done();
220226
expect(actualResultSets!).not.to.be.empty;
221227
expect(Object.keys(actualResultSets!).sort()).to.eql(Object.keys(queryTestCase.expectedResultSets).sort());
222228
for (const name in queryTestCase.expectedResultSets) {

0 commit comments

Comments
 (0)