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.
This commit is contained in:
Andrew Eisenberg
2021-11-03 16:04:14 -07:00
committed by GitHub
parent e9574d33a9
commit 0ef635bc68
4 changed files with 28 additions and 21 deletions

View File

@@ -74,7 +74,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
version: [stable, nightly]
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -104,31 +103,16 @@ jobs:
run: |
npm run lint
- name: Install CodeQL
run: |
mkdir codeql-home
if [ ${{ matrix.version }} = "stable" ]
then
curl -L --silent https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql.zip -o codeql-home/codeql.zip
else
curl -L --silent ${{ needs.find-nightly.outputs.url }}/codeql.zip -o codeql-home/codeql.zip
fi
unzip -q -o codeql-home/codeql.zip -d codeql-home
unzip -q -o codeql-home/codeql.zip codeql/codeql.exe -d codeql-home
rm codeql-home/codeql.zip
shell: bash
- name: Run unit tests (Linux)
working-directory: extensions/ql-vscode
if: matrix.os == 'ubuntu-latest'
run: |
CODEQL_PATH=$GITHUB_WORKSPACE/codeql-home/codeql/codeql npm run test
npm run test
- name: Run unit tests (Windows)
if: matrix.os == 'windows-latest'
working-directory: extensions/ql-vscode
run: |
$env:CODEQL_PATH=$(Join-Path $env:GITHUB_WORKSPACE -ChildPath 'codeql-home/codeql/codeql.exe')
npm run test
- name: Run integration tests (Linux)

13
.vscode/launch.json vendored
View File

@@ -96,6 +96,19 @@
// available in the workspace for the tests.
// "${workspaceRoot}/../codeql"
],
"env": {
// Optionally, set the version to use for the integration tests.
// Use "nightly" to use the latest nightly build.
// "CLI_VERSION": "2.7.0",
// If CLI_VERSION is set to nightly, set this to the url of the nightly build.
// "NIGHTLY_URL": "some url to grab the nightly build",
// Optionally, add a path to the codeql executable to be used during these tests.
// If not specified, one will be downloaded automatically.
// This option overrides the CLI_VERSION option.
// "CLI_PATH": "${workspaceRoot}/../semmle-code/target/intree/codeql/codeql",
},
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [

View File

@@ -77,9 +77,9 @@ $ vscode/scripts/code-cli.sh --install-extension dist/vscode-codeql-*.vsix # if
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.
### Running the unit/integration tests
### Running the unit tests and integration tests that do not require a CLI instance
Ensure the `CODEQL_PATH` environment variable is set to point to the `codeql` cli executable.
Unit tests and many integration tests do not require a copy of the CodeQL CLI.
Outside of vscode, run:
@@ -89,6 +89,16 @@ npm run test && npm run integration
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.
Only the _With CLI_ tests require a CLI instance to run. See below on how to do that.
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.
### Running the integration tests
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.
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.
## Releasing (write access required)
1. Double-check the `CHANGELOG.md` contains all desired change comments and has the version to be released with date at the top.

View File

@@ -58,8 +58,8 @@ export async function ensureCli(useCli: boolean) {
return;
}
if ('CODEQL_PATH' in process.env) {
const executablePath = process.env.CODEQL_PATH;
if ('CLI_PATH' in process.env) {
const executablePath = process.env.CLI_PATH;
console.log(`Using existing CLI at ${executablePath}`);
return;
}