Skip to content

Commit 17cd475

Browse files
committed
Move to separate function
1 parent 18c2cfc commit 17cd475

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

lib/init-action.js

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

src/init-action.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
makeTelemetryDiagnostic,
3838
} from "./diagnostics";
3939
import { EnvVar } from "./environment";
40-
import { Feature, Features } from "./feature-flags";
40+
import { Feature, FeatureEnablement, Features } from "./feature-flags";
4141
import { loadPropertiesFromApi } from "./feature-flags/properties";
4242
import {
4343
checkInstallPython311,
@@ -54,7 +54,7 @@ import {
5454
OverlayBaseDatabaseDownloadStats,
5555
OverlayDatabaseMode,
5656
} from "./overlay-database-utils";
57-
import { getRepositoryNwo } from "./repository";
57+
import { getRepositoryNwo, RepositoryNwo } from "./repository";
5858
import { ToolsSource } from "./setup-codeql";
5959
import {
6060
ActionName,
@@ -366,16 +366,11 @@ async function run(startedAt: Date) {
366366
apiDetails,
367367
features,
368368
repositoryProperties,
369-
enableFileCoverageInformation:
370-
// Always enable file coverage information in debug mode
371-
debugMode ||
372-
// We're most interested in speeding up PRs, and we want to keep
373-
// submitting file coverage information for the default branch since
374-
// it is used to populate the status page.
375-
!isAnalyzingPullRequest() ||
376-
// For now, restrict this feature to the GitHub org
377-
repositoryNwo.owner !== "github" ||
378-
!(await features.getValue(Feature.SkipFileCoverageOnPrs)),
369+
enableFileCoverageInformation: await getFileCoverageInformationEnabled(
370+
debugMode,
371+
repositoryNwo,
372+
features,
373+
),
379374
logger,
380375
});
381376

@@ -799,6 +794,24 @@ function getTrapCachingEnabled(): boolean {
799794
return true;
800795
}
801796

797+
async function getFileCoverageInformationEnabled(
798+
debugMode: boolean,
799+
repositoryNwo: RepositoryNwo,
800+
features: FeatureEnablement,
801+
): Promise<boolean> {
802+
return (
803+
// Always enable file coverage information in debug mode
804+
debugMode ||
805+
// We're most interested in speeding up PRs, and we want to keep
806+
// submitting file coverage information for the default branch since
807+
// it is used to populate the status page.
808+
!isAnalyzingPullRequest() ||
809+
// For now, restrict this feature to the GitHub org
810+
repositoryNwo.owner !== "github" ||
811+
!(await features.getValue(Feature.SkipFileCoverageOnPrs))
812+
);
813+
}
814+
802815
async function recordZstdAvailability(
803816
config: configUtils.Config,
804817
zstdAvailability: ZstdAvailability,

0 commit comments

Comments
 (0)