Move isDefaultSetup to actions-util.ts and change implementation
This commit is contained in:
parent
259cc5a39c
commit
471ed9f4c5
6 changed files with 14 additions and 16 deletions
5
lib/actions-util.js
generated
5
lib/actions-util.js
generated
|
|
@ -37,6 +37,7 @@ exports.getUploadValue = getUploadValue;
|
||||||
exports.getWorkflowRunID = getWorkflowRunID;
|
exports.getWorkflowRunID = getWorkflowRunID;
|
||||||
exports.getWorkflowRunAttempt = getWorkflowRunAttempt;
|
exports.getWorkflowRunAttempt = getWorkflowRunAttempt;
|
||||||
exports.isSelfHostedRunner = isSelfHostedRunner;
|
exports.isSelfHostedRunner = isSelfHostedRunner;
|
||||||
|
exports.isDefaultSetup = isDefaultSetup;
|
||||||
exports.prettyPrintInvocation = prettyPrintInvocation;
|
exports.prettyPrintInvocation = prettyPrintInvocation;
|
||||||
exports.ensureEndsInPeriod = ensureEndsInPeriod;
|
exports.ensureEndsInPeriod = ensureEndsInPeriod;
|
||||||
exports.runTool = runTool;
|
exports.runTool = runTool;
|
||||||
|
|
@ -425,6 +426,10 @@ exports.getFileType = getFileType;
|
||||||
function isSelfHostedRunner() {
|
function isSelfHostedRunner() {
|
||||||
return process.env.RUNNER_ENVIRONMENT === "self-hosted";
|
return process.env.RUNNER_ENVIRONMENT === "self-hosted";
|
||||||
}
|
}
|
||||||
|
/** Determines whether we are running in default setup. */
|
||||||
|
function isDefaultSetup() {
|
||||||
|
return getWorkflowEventName() === "dynamic";
|
||||||
|
}
|
||||||
function prettyPrintInvocation(cmd, args) {
|
function prettyPrintInvocation(cmd, args) {
|
||||||
return [cmd, ...args].map((x) => (x.includes(" ") ? `'${x}'` : x)).join(" ");
|
return [cmd, ...args].map((x) => (x.includes(" ") ? `'${x}'` : x)).join(" ");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
8
lib/init-action.js
generated
8
lib/init-action.js
generated
|
|
@ -417,12 +417,6 @@ async function recordZstdAvailability(config, zstdAvailability) {
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
/** Determines whether we are running in default setup. */
|
|
||||||
function isDefaultSetup() {
|
|
||||||
// This is set to something in default setup runs.
|
|
||||||
// TODO: replace with something better, if there's something.
|
|
||||||
return process.env["CODE_SCANNING_WORKFLOW_FILE"] !== undefined;
|
|
||||||
}
|
|
||||||
/** Determines whether dependency caching is enabled. */
|
/** Determines whether dependency caching is enabled. */
|
||||||
function getDependencyCachingEnabled() {
|
function getDependencyCachingEnabled() {
|
||||||
// If the workflow specified something always respect that
|
// If the workflow specified something always respect that
|
||||||
|
|
@ -433,7 +427,7 @@ function getDependencyCachingEnabled() {
|
||||||
if (!(0, util_1.isHostedRunner)())
|
if (!(0, util_1.isHostedRunner)())
|
||||||
return false;
|
return false;
|
||||||
// Disable in advanced workflows by default.
|
// Disable in advanced workflows by default.
|
||||||
if (!isDefaultSetup())
|
if (!(0, actions_util_1.isDefaultSetup)())
|
||||||
return false;
|
return false;
|
||||||
// On hosted runners, enable dependency caching by default
|
// On hosted runners, enable dependency caching by default
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -472,6 +472,11 @@ export function isSelfHostedRunner() {
|
||||||
return process.env.RUNNER_ENVIRONMENT === "self-hosted";
|
return process.env.RUNNER_ENVIRONMENT === "self-hosted";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Determines whether we are running in default setup. */
|
||||||
|
export function isDefaultSetup(): boolean {
|
||||||
|
return getWorkflowEventName() === "dynamic";
|
||||||
|
}
|
||||||
|
|
||||||
export function prettyPrintInvocation(cmd: string, args: string[]): string {
|
export function prettyPrintInvocation(cmd: string, args: string[]): string {
|
||||||
return [cmd, ...args].map((x) => (x.includes(" ") ? `'${x}'` : x)).join(" ");
|
return [cmd, ...args].map((x) => (x.includes(" ") ? `'${x}'` : x)).join(" ");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import {
|
||||||
getRequiredInput,
|
getRequiredInput,
|
||||||
getTemporaryDirectory,
|
getTemporaryDirectory,
|
||||||
persistInputs,
|
persistInputs,
|
||||||
|
isDefaultSetup,
|
||||||
} from "./actions-util";
|
} from "./actions-util";
|
||||||
import { getGitHubVersion } from "./api-client";
|
import { getGitHubVersion } from "./api-client";
|
||||||
import { CodeQL } from "./codeql";
|
import { CodeQL } from "./codeql";
|
||||||
|
|
@ -723,13 +724,6 @@ async function recordZstdAvailability(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Determines whether we are running in default setup. */
|
|
||||||
function isDefaultSetup(): boolean {
|
|
||||||
// This is set to something in default setup runs.
|
|
||||||
// TODO: replace with something better, if there's something.
|
|
||||||
return process.env["CODE_SCANNING_WORKFLOW_FILE"] !== undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Determines whether dependency caching is enabled. */
|
/** Determines whether dependency caching is enabled. */
|
||||||
function getDependencyCachingEnabled(): boolean {
|
function getDependencyCachingEnabled(): boolean {
|
||||||
// If the workflow specified something always respect that
|
// If the workflow specified something always respect that
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue