Skip to content

Commit

Permalink
Add initial workflow code dependent on init
Browse files Browse the repository at this point in the history
  • Loading branch information
mbg committed May 26, 2023
1 parent 580d717 commit bbaaef5
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 8 deletions.
34 changes: 32 additions & 2 deletions lib/resolve-environment-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/resolve-environment-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions resolve-environment/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: 'CodeQL: Resolve Build Environment'
description: 'Attempt to infer a suitable environment configuration for the autobuilder'
author: 'GitHub'
inputs:
language:
description: The language to infer the build environment configuration for.
required: true
outputs:
configuration:
description: The inferred build environment configuration.
runs:
using: 'node16'
main: '../lib/resolve-environment-action.js'
67 changes: 62 additions & 5 deletions src/resolve-environment-action.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,75 @@
import * as core from "@actions/core";

import { checkForTimeout, wrapError } from "./util";
import {
createStatusReportBase,
getRequiredInput,
getTemporaryDirectory,
sendStatusReport,
} from "./actions-util";
import { getGitHubVersion } from "./api-client";
import * as configUtils from "./config-utils";
import { Language, resolveAlias } from "./languages";
import { getActionsLogger } from "./logging";
import { runResolveBuildEnvironment } from "./resolve-environment";
import { checkForTimeout, checkGitHubVersionInRange, wrapError } from "./util";
import { validateWorkflow } from "./workflow";

const actionName = "resolve-environment";

async function run() {
return;
const startedAt = new Date();
const logger = getActionsLogger();
const language: Language = resolveAlias(getRequiredInput("language"));

try {
const workflowErrors = await validateWorkflow(logger);

if (
!(await sendStatusReport(
await createStatusReportBase(
actionName,
"starting",
startedAt,
workflowErrors
)
))
) {
return;
}

const gitHubVersion = await getGitHubVersion();
checkGitHubVersionInRange(gitHubVersion, logger);

const config = await configUtils.getConfig(getTemporaryDirectory(), logger);
if (config === undefined) {
throw new Error(
"Config file could not be found at expected location. Has the 'init' action been called?"
);
}

const result = await runResolveBuildEnvironment(config.codeQLCmd, logger, language);
core.setOutput("configuration", result);
} catch (unwrappedError) {
const error = wrapError(unwrappedError);
core.setFailed(error.message);
await sendStatusReport(
await createStatusReportBase(
actionName,
"aborted",
startedAt,
error.message,
error.stack
)
);
return;
}
}

async function runWrapper() {
try {
await run();
} catch (error) {
core.setFailed(
`resolve environment action failed: ${wrapError(error).message}`
);
core.setFailed(`${actionName} action failed: ${wrapError(error).message}`);
}
await checkForTimeout();
}
Expand Down

0 comments on commit bbaaef5

Please sign in to comment.