Allow the CodeQL CLI path to be set from an environment variable (#3118)
This commit is contained in:
@@ -119,14 +119,6 @@ export interface DistributionConfig {
|
|||||||
ownerName?: string;
|
ownerName?: string;
|
||||||
repositoryName?: string;
|
repositoryName?: string;
|
||||||
onDidChangeConfiguration?: Event<void>;
|
onDidChangeConfiguration?: Event<void>;
|
||||||
|
|
||||||
/**
|
|
||||||
* This forces an update of the distribution, even if the settings haven't changed.
|
|
||||||
*
|
|
||||||
* This should only be used when the distribution has been updated outside of the extension
|
|
||||||
* and only in tests. It should not be called in production code.
|
|
||||||
*/
|
|
||||||
forceUpdateConfiguration(): void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query server configuration
|
// Query server configuration
|
||||||
@@ -265,7 +257,10 @@ export class DistributionConfigListener
|
|||||||
implements DistributionConfig
|
implements DistributionConfig
|
||||||
{
|
{
|
||||||
public get customCodeQlPath(): string | undefined {
|
public get customCodeQlPath(): string | undefined {
|
||||||
return CUSTOM_CODEQL_PATH_SETTING.getValue() || undefined;
|
const testCliPath =
|
||||||
|
isIntegrationTestMode() &&
|
||||||
|
process.env.VSCODE_CODEQL_TESTING_CODEQL_CLI_TEST_PATH;
|
||||||
|
return CUSTOM_CODEQL_PATH_SETTING.getValue() || testCliPath || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get includePrerelease(): boolean {
|
public get includePrerelease(): boolean {
|
||||||
@@ -283,10 +278,6 @@ export class DistributionConfigListener
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public forceUpdateConfiguration() {
|
|
||||||
this._onDidChangeConfiguration.fire(undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected handleDidChangeConfiguration(e: ConfigurationChangeEvent): void {
|
protected handleDidChangeConfiguration(e: ConfigurationChangeEvent): void {
|
||||||
this.handleDidChangeConfigurationForRelevantSettings(
|
this.handleDidChangeConfigurationForRelevantSettings(
|
||||||
DISTRIBUTION_CHANGE_SETTINGS,
|
DISTRIBUTION_CHANGE_SETTINGS,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const config = {
|
|||||||
extensionTestsEnv: {
|
extensionTestsEnv: {
|
||||||
...baseConfig.extensionTestsEnv,
|
...baseConfig.extensionTestsEnv,
|
||||||
INTEGRATION_TEST_MODE: "true",
|
INTEGRATION_TEST_MODE: "true",
|
||||||
|
VSCODE_CODEQL_TESTING_CODEQL_CLI_TEST_PATH: process.env.CLI_PATH,
|
||||||
},
|
},
|
||||||
retries: 3,
|
retries: 3,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const config = {
|
|||||||
extensionTestsEnv: {
|
extensionTestsEnv: {
|
||||||
...baseConfig.extensionTestsEnv,
|
...baseConfig.extensionTestsEnv,
|
||||||
INTEGRATION_TEST_MODE: "true",
|
INTEGRATION_TEST_MODE: "true",
|
||||||
|
VSCODE_CODEQL_TESTING_CODEQL_CLI_TEST_PATH: process.env.CLI_PATH,
|
||||||
},
|
},
|
||||||
retries: 3,
|
retries: 3,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from "../jest.activated-extension.setup";
|
} from "../jest.activated-extension.setup";
|
||||||
import { createWriteStream, existsSync, mkdirpSync } from "fs-extra";
|
import { createWriteStream, existsSync, mkdirpSync } from "fs-extra";
|
||||||
import { dirname } from "path";
|
import { dirname } from "path";
|
||||||
import { DB_URL, dbLoc, getActivatedExtension } from "../global.helper";
|
import { DB_URL, dbLoc } from "../global.helper";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
@@ -31,21 +31,6 @@ beforeAll(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await beforeAllAction();
|
await beforeAllAction();
|
||||||
|
|
||||||
// Activate the extension
|
|
||||||
const extension = await getActivatedExtension();
|
|
||||||
|
|
||||||
if (process.env.CLI_VERSION && process.env.CLI_VERSION !== "nightly") {
|
|
||||||
const cliVersion = await extension.cliServer.getVersion();
|
|
||||||
|
|
||||||
if (cliVersion.compare(process.env.CLI_VERSION) !== 0) {
|
|
||||||
// It seems like the CUSTOM_CODEQL_PATH_SETTING.updateValue() call in
|
|
||||||
// `beforeAllAction` doesn't fire the event that the config has changed.
|
|
||||||
// `forceUpdateConfiguration` will fire the event manually.
|
|
||||||
// This is a hacky workaround.
|
|
||||||
extension.distributionManager.config.forceUpdateConfiguration();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { CUSTOM_CODEQL_PATH_SETTING } from "../../src/config";
|
import { env } from "vscode";
|
||||||
import { ConfigurationTarget, env } from "vscode";
|
|
||||||
import { beforeEachAction as testConfigBeforeEachAction } from "./test-config";
|
import { beforeEachAction as testConfigBeforeEachAction } from "./test-config";
|
||||||
import * as tmp from "tmp";
|
import * as tmp from "tmp";
|
||||||
import { realpathSync } from "fs-extra";
|
import { realpathSync } from "fs-extra";
|
||||||
@@ -19,13 +18,6 @@ if (process.env.CI) {
|
|||||||
let removeStorage: tmp.DirResult["removeCallback"] | undefined;
|
let removeStorage: tmp.DirResult["removeCallback"] | undefined;
|
||||||
|
|
||||||
export async function beforeAllAction() {
|
export async function beforeAllAction() {
|
||||||
// Set the CLI version here before activation to ensure we don't accidentally try to download a cli
|
|
||||||
await testConfigBeforeEachAction();
|
|
||||||
await CUSTOM_CODEQL_PATH_SETTING.updateValue(
|
|
||||||
process.env.CLI_PATH,
|
|
||||||
ConfigurationTarget.Workspace,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create the temp directory to be used as extension local storage.
|
// Create the temp directory to be used as extension local storage.
|
||||||
const dir = tmp.dirSync();
|
const dir = tmp.dirSync();
|
||||||
let storagePath = realpathSync(dir.name);
|
let storagePath = realpathSync(dir.name);
|
||||||
@@ -46,11 +38,6 @@ export async function beforeEachAction() {
|
|||||||
jest.spyOn(env, "openExternal").mockResolvedValue(false);
|
jest.spyOn(env, "openExternal").mockResolvedValue(false);
|
||||||
|
|
||||||
await testConfigBeforeEachAction();
|
await testConfigBeforeEachAction();
|
||||||
|
|
||||||
await CUSTOM_CODEQL_PATH_SETTING.updateValue(
|
|
||||||
process.env.CLI_PATH,
|
|
||||||
ConfigurationTarget.Workspace,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function afterAllAction() {
|
export async function afterAllAction() {
|
||||||
|
|||||||
Reference in New Issue
Block a user