Skip to content

Commit 9a59042

Browse files
committed
Avoid getCheckoutPath
1 parent c03fba9 commit 9a59042

16 files changed

Lines changed: 283 additions & 187 deletions

lib/entry-points.js

Lines changed: 53 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions-util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as github from "@actions/github";
77
import * as io from "@actions/io";
88

99
import type { Config } from "./config-utils";
10-
import { Env, EnvVar, ActionsEnvVars } from "./environment";
10+
import { Env, EnvVar, ActionsEnvVars, ReadOnlyEnv } from "./environment";
1111
import { Logger } from "./logging";
1212
import {
1313
doesDirectoryExist,
@@ -94,7 +94,7 @@ export function getActionVersion(): string {
9494
*
9595
* This will be "dynamic" for default setup workflow runs.
9696
*/
97-
export function getWorkflowEventName(env: Env = getEnv()) {
97+
export function getWorkflowEventName(env: ReadOnlyEnv = getEnv()) {
9898
return env.getRequired(ActionsEnvVars.GITHUB_EVENT_NAME);
9999
}
100100

@@ -121,7 +121,7 @@ function getRelativeScriptPath(env: Env): string {
121121
}
122122

123123
/** Returns the contents of `GITHUB_EVENT_PATH` as a JSON object. */
124-
export function getWorkflowEvent(env: Env = getEnv()): any {
124+
export function getWorkflowEvent(env: ReadOnlyEnv = getEnv()): any {
125125
const eventJsonFile = env.getRequired(ActionsEnvVars.GITHUB_EVENT_PATH);
126126
try {
127127
return JSON.parse(fs.readFileSync(eventJsonFile, "utf-8"));

src/analyze-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ async function run(action: ActionState<["Base", "Logger", "Env", "Actions"]>) {
406406
// Note: Take care with the ordering of this call since databases may be cleaned up
407407
// at the `overlay` or `clear` level.
408408
databaseUploadResults = await cleanupAndUploadDatabases(
409-
{ logger, features },
409+
{ ...action, features },
410410
repositoryNwo,
411411
codeql,
412412
config,

src/codeql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ export async function getTrapCachingExtractorConfigArgsForLang(
12121212
): Promise<string[]> {
12131213
const cacheDir = config.trapCaches[language];
12141214
if (cacheDir === undefined) return [];
1215-
const write = await isAnalyzingDefaultBranch();
1215+
const write = await isAnalyzingDefaultBranch(getEnv(), config.repositoryRoot);
12161216
return [
12171217
`-O=${language}.trap.cache.dir=${cacheDir}`,
12181218
`-O=${language}.trap.cache.bound=${TRAP_CACHE_SIZE_MB}`,

src/config-utils.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
makeTelemetryDiagnostic,
4747
} from "./diagnostics";
4848
import { prepareDiffInformedAnalysis } from "./diff-informed-analysis-utils";
49-
import { EnvVar } from "./environment";
49+
import { EnvVar, getEnv } from "./environment";
5050
import * as errorMessages from "./error-messages";
5151
import { Feature, FeatureEnablement, FeatureWithoutCLI } from "./feature-flags";
5252
import {
@@ -467,12 +467,18 @@ async function downloadCacheWithTime(
467467
codeQL: CodeQL,
468468
languages: Language[],
469469
logger: Logger,
470+
repositoryRoot: string | undefined,
470471
): Promise<{
471472
trapCaches: { [language: string]: string };
472473
trapCacheDownloadTime: number;
473474
}> {
474475
const start = performance.now();
475-
const trapCaches = await downloadTrapCaches(codeQL, languages, logger);
476+
const trapCaches = await downloadTrapCaches(
477+
codeQL,
478+
languages,
479+
logger,
480+
repositoryRoot,
481+
);
476482
const trapCacheDownloadTime = performance.now() - start;
477483
return { trapCaches, trapCacheDownloadTime };
478484
}
@@ -824,7 +830,7 @@ export async function checkOverlayEnablement(
824830
`Setting overlay database mode to ${overlayDatabaseMode} ` +
825831
"with caching because we are analyzing a pull request.",
826832
);
827-
} else if (await isAnalyzingDefaultBranch()) {
833+
} else if (await isAnalyzingDefaultBranch(getEnv(), repositoryRoot)) {
828834
overlayDatabaseMode = OverlayDatabaseMode.OverlayBase;
829835
logger.info(
830836
`Setting overlay database mode to ${overlayDatabaseMode} ` +
@@ -1305,6 +1311,7 @@ export async function initConfig(
13051311
inputs.codeql,
13061312
config.languages,
13071313
logger,
1314+
repositoryRoot,
13081315
);
13091316
config.trapCaches = trapCaches;
13101317
config.trapCacheDownloadTime = trapCacheDownloadTime;

0 commit comments

Comments
 (0)