mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
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:
@@ -4,12 +4,12 @@ import * as toolcache from "@actions/tool-cache";
|
||||
import test from "ava";
|
||||
import nock from "nock";
|
||||
|
||||
import { Mode, setMode } from "./actions-util";
|
||||
import * as codeql from "./codeql";
|
||||
import * as defaults from "./defaults.json";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { setupTests, setupActionsVars } from "./testing-utils";
|
||||
import * as util from "./util";
|
||||
import { Mode, initializeEnvironment } from "./util";
|
||||
|
||||
setupTests(test);
|
||||
|
||||
@@ -24,7 +24,7 @@ const sampleGHAEApiDetails = {
|
||||
};
|
||||
|
||||
test.beforeEach(() => {
|
||||
setMode(Mode.actions);
|
||||
initializeEnvironment(Mode.actions, "1.2.3");
|
||||
});
|
||||
|
||||
test("download codeql bundle cache", async (t) => {
|
||||
@@ -371,14 +371,14 @@ test("getExtraOptions throws for bad content", (t) => {
|
||||
);
|
||||
});
|
||||
|
||||
test.only("getCodeQLActionRepository", (t) => {
|
||||
test("getCodeQLActionRepository", (t) => {
|
||||
const logger = getRunnerLogger(true);
|
||||
|
||||
setMode(Mode.actions);
|
||||
initializeEnvironment(Mode.actions, "1.2.3");
|
||||
const repoActions = codeql.getCodeQLActionRepository(logger);
|
||||
t.deepEqual(repoActions, "github/codeql-action");
|
||||
|
||||
setMode(Mode.runner);
|
||||
initializeEnvironment(Mode.runner, "1.2.3");
|
||||
|
||||
// isRunningLocalAction() === true
|
||||
delete process.env["GITHUB_ACTION_REPOSITORY"];
|
||||
|
||||
Reference in New Issue
Block a user