Skip to content

Commit 0ef635b

Browse files
authored
Use the correct environment variable in integration tests (#994)
Also, fix documentation and launch configs to specify the correct and complete set of environment variables we should be using.
1 parent e9574d3 commit 0ef635b

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ jobs:
7474
strategy:
7575
matrix:
7676
os: [ubuntu-latest, windows-latest]
77-
version: [stable, nightly]
7877
steps:
7978
- name: Checkout
8079
uses: actions/checkout@v2
@@ -104,31 +103,16 @@ jobs:
104103
run: |
105104
npm run lint
106105
107-
- name: Install CodeQL
108-
run: |
109-
mkdir codeql-home
110-
if [ ${{ matrix.version }} = "stable" ]
111-
then
112-
curl -L --silent https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql.zip -o codeql-home/codeql.zip
113-
else
114-
curl -L --silent ${{ needs.find-nightly.outputs.url }}/codeql.zip -o codeql-home/codeql.zip
115-
fi
116-
unzip -q -o codeql-home/codeql.zip -d codeql-home
117-
unzip -q -o codeql-home/codeql.zip codeql/codeql.exe -d codeql-home
118-
rm codeql-home/codeql.zip
119-
shell: bash
120-
121106
- name: Run unit tests (Linux)
122107
working-directory: extensions/ql-vscode
123108
if: matrix.os == 'ubuntu-latest'
124109
run: |
125-
CODEQL_PATH=$GITHUB_WORKSPACE/codeql-home/codeql/codeql npm run test
110+
npm run test
126111
127112
- name: Run unit tests (Windows)
128113
if: matrix.os == 'windows-latest'
129114
working-directory: extensions/ql-vscode
130115
run: |
131-
$env:CODEQL_PATH=$(Join-Path $env:GITHUB_WORKSPACE -ChildPath 'codeql-home/codeql/codeql.exe')
132116
npm run test
133117
134118
- name: Run integration tests (Linux)

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@
9696
// available in the workspace for the tests.
9797
// "${workspaceRoot}/../codeql"
9898
],
99+
"env": {
100+
// Optionally, set the version to use for the integration tests.
101+
// Use "nightly" to use the latest nightly build.
102+
// "CLI_VERSION": "2.7.0",
103+
104+
// If CLI_VERSION is set to nightly, set this to the url of the nightly build.
105+
// "NIGHTLY_URL": "some url to grab the nightly build",
106+
107+
// Optionally, add a path to the codeql executable to be used during these tests.
108+
// If not specified, one will be downloaded automatically.
109+
// This option overrides the CLI_VERSION option.
110+
// "CLI_PATH": "${workspaceRoot}/../semmle-code/target/intree/codeql/codeql",
111+
},
99112
"stopOnEntry": false,
100113
"sourceMaps": true,
101114
"outFiles": [

CONTRIBUTING.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ $ vscode/scripts/code-cli.sh --install-extension dist/vscode-codeql-*.vsix # if
7777

7878
You can use VS Code to debug the extension without explicitly installing it. Just open this directory as a workspace in VS Code, and hit `F5` to start a debugging session.
7979

80-
### Running the unit/integration tests
80+
### Running the unit tests and integration tests that do not require a CLI instance
8181

82-
Ensure the `CODEQL_PATH` environment variable is set to point to the `codeql` cli executable.
82+
Unit tests and many integration tests do not require a copy of the CodeQL CLI.
8383

8484
Outside of vscode, run:
8585

@@ -89,6 +89,16 @@ npm run test && npm run integration
8989

9090
Alternatively, you can run the tests inside of vscode. There are several vscode launch configurations defined that run the unit and integration tests. They can all be found in the debug view.
9191

92+
Only the _With CLI_ tests require a CLI instance to run. See below on how to do that.
93+
94+
Running from a terminal, you _must_ set the `TEST_CODEQL_PATH` variable to point to a checkout of the `github/codeql` repository. The appropriate CLI version will be downloaded as part of the test.
95+
96+
### Running the integration tests
97+
98+
The _Launch Integration Tests - With CLI_ tests require a CLI instance in order to run. There are several environment variables you can use to configure this.
99+
100+
From inside of VSCode, open the `launch.json` file and in the _Launch Integration Tests - With CLI_ uncomment and change the environment variables appropriate for your purpose.
101+
92102
## Releasing (write access required)
93103

94104
1. Double-check the `CHANGELOG.md` contains all desired change comments and has the version to be released with date at the top.

extensions/ql-vscode/src/vscode-tests/ensureCli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export async function ensureCli(useCli: boolean) {
5858
return;
5959
}
6060

61-
if ('CODEQL_PATH' in process.env) {
62-
const executablePath = process.env.CODEQL_PATH;
61+
if ('CLI_PATH' in process.env) {
62+
const executablePath = process.env.CLI_PATH;
6363
console.log(`Using existing CLI at ${executablePath}`);
6464
return;
6565
}

0 commit comments

Comments
 (0)