Skip to content

Commit 8216c3a

Browse files
committed
Install CodeQL as part of the action
1 parent 59a9e3a commit 8216c3a

4 files changed

Lines changed: 59 additions & 16 deletions

File tree

lib/resolve-environment-action.js

Lines changed: 14 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/resolve-environment-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resolve-environment/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: 'CodeQL: Resolve Build Environment'
22
description: 'Attempt to infer a suitable environment configuration for the autobuilder'
33
author: 'GitHub'
44
inputs:
5+
tools:
6+
description: URL of CodeQL tools
7+
required: false
8+
# If not specified the Action will check in several places until it finds the CodeQL tools.
59
token:
610
default: ${{ github.token }}
711
matrix:

src/resolve-environment-action.ts

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ import {
88
sendStatusReport,
99
} from "./actions-util";
1010
import { getGitHubVersion } from "./api-client";
11-
import * as configUtils from "./config-utils";
11+
import { Features } from "./feature-flags";
12+
import { initCodeQL } from "./init";
1213
import { Language, resolveAlias } from "./languages";
1314
import { getActionsLogger } from "./logging";
15+
import { parseRepositoryNwo } from "./repository";
1416
import { runResolveBuildEnvironment } from "./resolve-environment";
15-
import { checkForTimeout, checkGitHubVersionInRange, wrapError } from "./util";
17+
import {
18+
checkForTimeout,
19+
checkGitHubVersionInRange,
20+
getRequiredEnvParam,
21+
wrapError,
22+
} from "./util";
1623
import { validateWorkflow } from "./workflow";
1724

1825
const actionName = "resolve-environment";
@@ -22,6 +29,17 @@ async function run() {
2229
const logger = getActionsLogger();
2330
const language: Language = resolveAlias(getRequiredInput("language"));
2431

32+
const apiDetails = {
33+
auth: getRequiredInput("token"),
34+
externalRepoAuth: getOptionalInput("external-repository-token"),
35+
url: getRequiredEnvParam("GITHUB_SERVER_URL"),
36+
apiURL: getRequiredEnvParam("GITHUB_API_URL"),
37+
};
38+
39+
const repositoryNwo = parseRepositoryNwo(
40+
getRequiredEnvParam("GITHUB_REPOSITORY")
41+
);
42+
2543
try {
2644
const workflowErrors = await validateWorkflow(logger);
2745

@@ -41,12 +59,25 @@ async function run() {
4159
const gitHubVersion = await getGitHubVersion();
4260
checkGitHubVersionInRange(gitHubVersion, logger);
4361

44-
const config = await configUtils.getConfig(getTemporaryDirectory(), logger);
45-
if (config === undefined) {
46-
throw new Error(
47-
"Config file could not be found at expected location. Has the 'init' action been called?"
48-
);
49-
}
62+
const features = new Features(
63+
gitHubVersion,
64+
repositoryNwo,
65+
getTemporaryDirectory(),
66+
logger
67+
);
68+
69+
const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(
70+
gitHubVersion.type
71+
);
72+
73+
const initCodeQLResult = await initCodeQL(
74+
getOptionalInput("tools"),
75+
apiDetails,
76+
getTemporaryDirectory(),
77+
gitHubVersion.type,
78+
codeQLDefaultVersionInfo,
79+
logger
80+
);
5081

5182
const workingDirectory = getOptionalInput("working-directory");
5283
if (workingDirectory) {
@@ -57,7 +88,7 @@ async function run() {
5788
}
5889

5990
const result = await runResolveBuildEnvironment(
60-
config.codeQLCmd,
91+
initCodeQLResult.codeql.getPath(),
6192
logger,
6293
language
6394
);

0 commit comments

Comments
 (0)