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:
Andrew Eisenberg 2021-06-01 14:49:07 -07:00
parent 539d968ad7
commit 3708898bf2
48 changed files with 387 additions and 250 deletions

10
lib/toolcache.js generated
View file

@ -15,7 +15,7 @@ const io = __importStar(require("@actions/io"));
const actionsToolcache = __importStar(require("@actions/tool-cache"));
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
const semver = __importStar(require("semver"));
const actions_util_1 = require("./actions-util");
const util_1 = require("./util");
/*
* This file acts as an interface to the functionality of the actions toolcache.
* That library is not safe to use outside of actions as it makes assumptions about
@ -36,7 +36,7 @@ const actions_util_1 = require("./actions-util");
* @returns path to the destination directory
*/
async function extractTar(file, tempDir, logger) {
if (actions_util_1.isActions()) {
if (util_1.isActions()) {
return await actionsToolcache.extractTar(file);
}
else {
@ -96,7 +96,7 @@ exports.extractTar = extractTar;
* @param logger logger to use
*/
async function cacheDir(sourceDir, tool, version, toolCacheDir, logger) {
if (actions_util_1.isActions()) {
if (util_1.isActions()) {
return await actionsToolcache.cacheDir(sourceDir, tool, version);
}
else {
@ -134,7 +134,7 @@ exports.cacheDir = cacheDir;
* @param logger logger to use
*/
function find(toolName, versionSpec, toolCacheDir, logger) {
if (actions_util_1.isActions()) {
if (util_1.isActions()) {
return actionsToolcache.find(toolName, versionSpec);
}
else {
@ -180,7 +180,7 @@ exports.find = find;
* @param logger logger to use
*/
function findAllVersions(toolName, toolCacheDir, logger) {
if (actions_util_1.isActions()) {
if (util_1.isActions()) {
return actionsToolcache.findAllVersions(toolName);
}
else {