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
10
lib/codeql.test.js
generated
10
lib/codeql.test.js
generated
|
|
@ -14,12 +14,12 @@ const path = __importStar(require("path"));
|
|||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const nock_1 = __importDefault(require("nock"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const codeql = __importStar(require("./codeql"));
|
||||
const defaults = __importStar(require("./defaults.json"));
|
||||
const logging_1 = require("./logging");
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
testing_utils_1.setupTests(ava_1.default);
|
||||
const sampleApiDetails = {
|
||||
auth: "token",
|
||||
|
|
@ -30,7 +30,7 @@ const sampleGHAEApiDetails = {
|
|||
url: "https://example.githubenterprise.com",
|
||||
};
|
||||
ava_1.default.beforeEach(() => {
|
||||
actions_util_1.setMode(actions_util_1.Mode.actions);
|
||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
||||
});
|
||||
ava_1.default("download codeql bundle cache", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
|
|
@ -190,12 +190,12 @@ ava_1.default("getExtraOptions throws for bad content", (t) => {
|
|||
t.throws(() => codeql.getExtraOptions({ foo: 87 }, ["foo"], []));
|
||||
t.throws(() => codeql.getExtraOptions({ "*": [42], foo: { "*": 87, bar: [99] } }, ["foo", "bar"], []));
|
||||
});
|
||||
ava_1.default.only("getCodeQLActionRepository", (t) => {
|
||||
ava_1.default("getCodeQLActionRepository", (t) => {
|
||||
const logger = logging_1.getRunnerLogger(true);
|
||||
actions_util_1.setMode(actions_util_1.Mode.actions);
|
||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
||||
const repoActions = codeql.getCodeQLActionRepository(logger);
|
||||
t.deepEqual(repoActions, "github/codeql-action");
|
||||
actions_util_1.setMode(actions_util_1.Mode.runner);
|
||||
util_1.initializeEnvironment(util_1.Mode.runner, "1.2.3");
|
||||
// isRunningLocalAction() === true
|
||||
delete process.env["GITHUB_ACTION_REPOSITORY"];
|
||||
process.env["RUNNER_TEMP"] = path.dirname(__dirname);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue