Improve readability of CodeQL bundle tests
This commit is contained in:
parent
96a8424f0c
commit
d45b0eba23
3 changed files with 122 additions and 199 deletions
92
lib/codeql.test.js
generated
92
lib/codeql.test.js
generated
|
|
@ -79,45 +79,55 @@ ava_1.default.beforeEach(() => {
|
||||||
trapCacheDownloadTime: 0,
|
trapCacheDownloadTime: 0,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
async function mockApiAndSetupCodeQL({ version, isPinned, tmpDir, toolsInput, apiDetails, }) {
|
||||||
|
var _a;
|
||||||
|
const platform = process.platform === "win32"
|
||||||
|
? "win64"
|
||||||
|
: process.platform === "linux"
|
||||||
|
? "linux64"
|
||||||
|
: "osx64";
|
||||||
|
const baseUrl = (_a = apiDetails === null || apiDetails === void 0 ? void 0 : apiDetails.url) !== null && _a !== void 0 ? _a : "https://example.com";
|
||||||
|
const relativeUrl = apiDetails
|
||||||
|
? `/github/codeql-action/releases/download/${version}/codeql-bundle-${platform}.tar.gz`
|
||||||
|
: `/download/codeql-bundle-${version}/codeql-bundle.tar.gz`;
|
||||||
|
(0, nock_1.default)(baseUrl)
|
||||||
|
.get(relativeUrl)
|
||||||
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`));
|
||||||
|
await codeql.setupCodeQL(toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`, apiDetails !== null && apiDetails !== void 0 ? apiDetails : sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
||||||
|
}
|
||||||
(0, ava_1.default)("download codeql bundle cache", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
const versions = ["20200601", "20200610"];
|
const versions = ["20200601", "20200610"];
|
||||||
for (let i = 0; i < versions.length; i++) {
|
for (let i = 0; i < versions.length; i++) {
|
||||||
const version = versions[i];
|
const version = versions[i];
|
||||||
(0, nock_1.default)("https://example.com")
|
await mockApiAndSetupCodeQL({ version, tmpDir });
|
||||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
|
||||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
|
||||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||||
}
|
}
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
t.is(toolcache.findAllVersions("CodeQL").length, 2);
|
||||||
t.is(cachedVersions.length, 2);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
(0, nock_1.default)("https://example.com")
|
await mockApiAndSetupCodeQL({
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
version: "20200601",
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
isPinned: true,
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
tmpDir,
|
||||||
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
(0, nock_1.default)("https://example.com")
|
await mockApiAndSetupCodeQL({ version: "20200610", tmpDir });
|
||||||
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("don't download codeql bundle cache with pinned different version cached", async (t) => {
|
(0, ava_1.default)("don't download codeql bundle cache with pinned different version cached", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
(0, nock_1.default)("https://example.com")
|
await mockApiAndSetupCodeQL({
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
version: "20200601",
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
isPinned: true,
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
tmpDir,
|
||||||
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
|
|
@ -127,20 +137,14 @@ ava_1.default.beforeEach(() => {
|
||||||
(0, ava_1.default)("download codeql bundle cache with different version cached (not pinned)", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache with different version cached (not pinned)", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
(0, nock_1.default)("https://example.com")
|
await mockApiAndSetupCodeQL({ version: "20200601", tmpDir });
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
await mockApiAndSetupCodeQL({
|
||||||
? "win64"
|
version: defaults.bundleVersion,
|
||||||
: process.platform === "linux"
|
tmpDir,
|
||||||
? "linux64"
|
apiDetails: sampleApiDetails,
|
||||||
: "osx64";
|
toolsInput: { input: undefined },
|
||||||
(0, nock_1.default)("https://github.com")
|
});
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
|
|
@ -148,20 +152,18 @@ ava_1.default.beforeEach(() => {
|
||||||
(0, ava_1.default)('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
|
(0, ava_1.default)('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
(0, nock_1.default)("https://example.com")
|
await mockApiAndSetupCodeQL({
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
version: "20200601",
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
isPinned: true,
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
tmpDir,
|
||||||
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
await mockApiAndSetupCodeQL({
|
||||||
? "win64"
|
version: defaults.bundleVersion,
|
||||||
: process.platform === "linux"
|
apiDetails: sampleApiDetails,
|
||||||
? "linux64"
|
toolsInput: { input: "latest" },
|
||||||
: "osx64";
|
tmpDir,
|
||||||
(0, nock_1.default)("https://github.com")
|
});
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -9,17 +9,14 @@ import * as yaml from "js-yaml";
|
||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
|
import { GitHubApiDetails } from "./api-client";
|
||||||
import * as codeql from "./codeql";
|
import * as codeql from "./codeql";
|
||||||
import { AugmentationProperties, Config } from "./config-utils";
|
import { AugmentationProperties, Config } from "./config-utils";
|
||||||
import * as defaults from "./defaults.json";
|
import * as defaults from "./defaults.json";
|
||||||
import { createFeatureFlags, FeatureFlag } from "./feature-flags";
|
import { createFeatureFlags, FeatureFlag } from "./feature-flags";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import {
|
import { setupTests, setupActionsVars } from "./testing-utils";
|
||||||
setupTests,
|
|
||||||
setupActionsVars,
|
|
||||||
mockFeatureFlagApiEndpoint,
|
|
||||||
} from "./testing-utils";
|
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
import { Mode, initializeEnvironment } from "./util";
|
import { Mode, initializeEnvironment } from "./util";
|
||||||
|
|
||||||
|
|
@ -68,6 +65,52 @@ test.beforeEach(() => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function mockApiAndSetupCodeQL({
|
||||||
|
version,
|
||||||
|
isPinned,
|
||||||
|
tmpDir,
|
||||||
|
toolsInput,
|
||||||
|
apiDetails,
|
||||||
|
}: {
|
||||||
|
version: string;
|
||||||
|
isPinned?: boolean;
|
||||||
|
tmpDir: string;
|
||||||
|
toolsInput?: { input?: string };
|
||||||
|
apiDetails?: GitHubApiDetails;
|
||||||
|
}) {
|
||||||
|
const platform =
|
||||||
|
process.platform === "win32"
|
||||||
|
? "win64"
|
||||||
|
: process.platform === "linux"
|
||||||
|
? "linux64"
|
||||||
|
: "osx64";
|
||||||
|
|
||||||
|
const baseUrl = apiDetails?.url ?? "https://example.com";
|
||||||
|
const relativeUrl = apiDetails
|
||||||
|
? `/github/codeql-action/releases/download/${version}/codeql-bundle-${platform}.tar.gz`
|
||||||
|
: `/download/codeql-bundle-${version}/codeql-bundle.tar.gz`;
|
||||||
|
|
||||||
|
nock(baseUrl)
|
||||||
|
.get(relativeUrl)
|
||||||
|
.replyWithFile(
|
||||||
|
200,
|
||||||
|
path.join(
|
||||||
|
__dirname,
|
||||||
|
`/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await codeql.setupCodeQL(
|
||||||
|
toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`,
|
||||||
|
apiDetails ?? sampleApiDetails,
|
||||||
|
tmpDir,
|
||||||
|
util.GitHubVariant.DOTCOM,
|
||||||
|
createFeatureFlags([]),
|
||||||
|
getRunnerLogger(true),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test("download codeql bundle cache", async (t) => {
|
test("download codeql bundle cache", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
@ -77,31 +120,11 @@ test("download codeql bundle cache", async (t) => {
|
||||||
for (let i = 0; i < versions.length; i++) {
|
for (let i = 0; i < versions.length; i++) {
|
||||||
const version = versions[i];
|
const version = versions[i];
|
||||||
|
|
||||||
nock("https://example.com")
|
await mockApiAndSetupCodeQL({ version, tmpDir });
|
||||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(
|
|
||||||
200,
|
|
||||||
path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)
|
|
||||||
);
|
|
||||||
|
|
||||||
mockFeatureFlagApiEndpoint(200, {});
|
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
|
||||||
`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`,
|
|
||||||
sampleApiDetails,
|
|
||||||
tmpDir,
|
|
||||||
util.GitHubVariant.DOTCOM,
|
|
||||||
createFeatureFlags([]),
|
|
||||||
getRunnerLogger(true),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
t.is(toolcache.findAllVersions("CodeQL").length, 2);
|
||||||
|
|
||||||
t.is(cachedVersions.length, 2);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -109,42 +132,14 @@ test("download codeql bundle cache explicitly requested with pinned different ve
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
nock("https://example.com")
|
await mockApiAndSetupCodeQL({
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
version: "20200601",
|
||||||
.replyWithFile(
|
isPinned: true,
|
||||||
200,
|
|
||||||
path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)
|
|
||||||
);
|
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
|
||||||
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
|
||||||
sampleApiDetails,
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
});
|
||||||
createFeatureFlags([]),
|
|
||||||
getRunnerLogger(true),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
|
|
||||||
nock("https://example.com")
|
await mockApiAndSetupCodeQL({ version: "20200610", tmpDir });
|
||||||
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(
|
|
||||||
200,
|
|
||||||
path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)
|
|
||||||
);
|
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
|
||||||
"https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz",
|
|
||||||
sampleApiDetails,
|
|
||||||
tmpDir,
|
|
||||||
util.GitHubVariant.DOTCOM,
|
|
||||||
createFeatureFlags([]),
|
|
||||||
getRunnerLogger(true),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -153,22 +148,11 @@ test("don't download codeql bundle cache with pinned different version cached",
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
nock("https://example.com")
|
await mockApiAndSetupCodeQL({
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
version: "20200601",
|
||||||
.replyWithFile(
|
isPinned: true,
|
||||||
200,
|
|
||||||
path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)
|
|
||||||
);
|
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
|
||||||
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
|
||||||
sampleApiDetails,
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
});
|
||||||
createFeatureFlags([]),
|
|
||||||
getRunnerLogger(true),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
|
|
||||||
|
|
@ -192,49 +176,16 @@ test("download codeql bundle cache with different version cached (not pinned)",
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
nock("https://example.com")
|
await mockApiAndSetupCodeQL({ version: "20200601", tmpDir });
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(
|
|
||||||
200,
|
|
||||||
path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)
|
|
||||||
);
|
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
|
||||||
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
|
||||||
sampleApiDetails,
|
|
||||||
tmpDir,
|
|
||||||
util.GitHubVariant.DOTCOM,
|
|
||||||
createFeatureFlags([]),
|
|
||||||
getRunnerLogger(true),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform =
|
|
||||||
process.platform === "win32"
|
|
||||||
? "win64"
|
|
||||||
: process.platform === "linux"
|
|
||||||
? "linux64"
|
|
||||||
: "osx64";
|
|
||||||
|
|
||||||
nock("https://github.com")
|
await mockApiAndSetupCodeQL({
|
||||||
.get(
|
version: defaults.bundleVersion,
|
||||||
`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`
|
|
||||||
)
|
|
||||||
.replyWithFile(
|
|
||||||
200,
|
|
||||||
path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)
|
|
||||||
);
|
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
|
||||||
undefined,
|
|
||||||
sampleApiDetails,
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
apiDetails: sampleApiDetails,
|
||||||
createFeatureFlags([]),
|
toolsInput: { input: undefined },
|
||||||
getRunnerLogger(true),
|
});
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
|
|
||||||
|
|
@ -246,50 +197,20 @@ test('download codeql bundle cache with pinned different version cached if "late
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
nock("https://example.com")
|
await mockApiAndSetupCodeQL({
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
version: "20200601",
|
||||||
.replyWithFile(
|
isPinned: true,
|
||||||
200,
|
|
||||||
path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)
|
|
||||||
);
|
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
|
||||||
"https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz",
|
|
||||||
sampleApiDetails,
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
});
|
||||||
createFeatureFlags([]),
|
|
||||||
getRunnerLogger(true),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
|
|
||||||
const platform =
|
await mockApiAndSetupCodeQL({
|
||||||
process.platform === "win32"
|
version: defaults.bundleVersion,
|
||||||
? "win64"
|
apiDetails: sampleApiDetails,
|
||||||
: process.platform === "linux"
|
toolsInput: { input: "latest" },
|
||||||
? "linux64"
|
|
||||||
: "osx64";
|
|
||||||
|
|
||||||
nock("https://github.com")
|
|
||||||
.get(
|
|
||||||
`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`
|
|
||||||
)
|
|
||||||
.replyWithFile(
|
|
||||||
200,
|
|
||||||
path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)
|
|
||||||
);
|
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
|
||||||
"latest",
|
|
||||||
sampleApiDetails,
|
|
||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
});
|
||||||
createFeatureFlags([]),
|
|
||||||
getRunnerLogger(true),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue