Skip to content

Commit

Permalink
Add env var alternative to dependency-caching input
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael B. Gale committed Oct 29, 2024
1 parent f3714ae commit 1338dbc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
6 changes: 6 additions & 0 deletions lib/environment.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/environment.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init-action.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,11 @@ export enum EnvVar {
* We check this later to ensure that it hasn't been tampered with by a late e.g. `setup-go` step.
*/
GO_BINARY_LOCATION = "CODEQL_ACTION_GO_BINARY",

/**
* Used as an alternative to the `dependency-caching` input for the `init` Action.
* Useful for experiments where it is easier to set an environment variable than
* change the inputs to the Action.
*/
DEPENDENCY_CACHING = "CODEQL_ACTION_DEPENDENCY_CACHING",
}
4 changes: 3 additions & 1 deletion src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,9 @@ async function recordZstdAvailability(
/** Determines whether dependency caching is enabled. */
function getDependencyCachingEnabled(): boolean {
// If the workflow specified something always respect that
const dependencyCaching = getOptionalInput("dependency-caching");
const dependencyCaching =
getOptionalInput("dependency-caching") ||
process.env[EnvVar.DEPENDENCY_CACHING];
if (dependencyCaching !== undefined) return dependencyCaching === "true";

// On self-hosted runners which may have dependencies installed centrally, disable caching by default
Expand Down

0 comments on commit 1338dbc

Please sign in to comment.