Add environment variables to signal feature and version to the CLI
This PR ensures environment variables are set before any invocation of the CLI. Here is a list of vars that are set: https://github.com/github/codeql-coreql-team/issues/1124#issuecomment-852463521 This ensures the CLI knows the features and versions of the containing actions/runner. Additionally: - Fix the user agent so that it more closely aligns with user agent spec - Refactor environment variable initialization so that it all happens in one place and call. - Move Mode, getRequiredEnvParam, setMode, getMode out of actions-util and into util. actions-util is meant for utils only called by the action, not the runner. The `prepareLocalRunEnvironment()` method is most likely deprecated and should be removed. I originally added it because I had a way of working where I would run the action from my local machine to test out changes, but this was always a little flaky. So, I no longer use this way of working. I will probably remove it soon.
This commit is contained in:
parent
539d968ad7
commit
3708898bf2
48 changed files with 387 additions and 250 deletions
|
|
@ -14,6 +14,9 @@ import { getActionsLogger } from "./logging";
|
|||
import * as upload_lib from "./upload-lib";
|
||||
import * as util from "./util";
|
||||
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
|
||||
interface AnalysisStatusReport
|
||||
extends upload_lib.UploadStatusReport,
|
||||
QueriesStatusReport {}
|
||||
|
|
@ -49,10 +52,9 @@ async function run() {
|
|||
const startedAt = new Date();
|
||||
let stats: AnalysisStatusReport | undefined = undefined;
|
||||
let config: Config | undefined = undefined;
|
||||
actionsUtil.setMode(actionsUtil.Mode.actions);
|
||||
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
||||
|
||||
try {
|
||||
actionsUtil.prepareLocalRunEnvironment();
|
||||
if (
|
||||
!(await actionsUtil.sendStatusReport(
|
||||
await actionsUtil.createStatusReportBase(
|
||||
|
|
@ -65,7 +67,7 @@ async function run() {
|
|||
return;
|
||||
}
|
||||
const logger = getActionsLogger();
|
||||
config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
||||
config = await getConfig(util.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
throw new Error(
|
||||
"Config file could not be found at expected location. Has the 'init' action been called?"
|
||||
|
|
@ -74,7 +76,7 @@ async function run() {
|
|||
|
||||
const apiDetails = {
|
||||
auth: actionsUtil.getRequiredInput("token"),
|
||||
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
url: util.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
};
|
||||
const outputDir = actionsUtil.getRequiredInput("output");
|
||||
const queriesStats = await runAnalyze(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue