mirror of
https://github.com/github/codeql-action.git
synced 2026-06-03 12:24:38 +00:00
Add logging and telemetry for mode
This commit is contained in:
Generated
+46
-10
@@ -158746,12 +158746,16 @@ var io7 = __toESM(require_io());
|
||||
var semver10 = __toESM(require_semver2());
|
||||
|
||||
// src/config/resolve-tools-input.ts
|
||||
function resolveToolsInput(toolsWorkflowInput, isDynamicWorkflow2, repositoryProperties, logger) {
|
||||
function resolveToolsInputWithMetadata(toolsWorkflowInput, isDynamicWorkflow2, repositoryProperties, logger) {
|
||||
if (toolsWorkflowInput) {
|
||||
logger.info(
|
||||
`Setting tools: ${toolsWorkflowInput} based on workflow input.`
|
||||
);
|
||||
return toolsWorkflowInput;
|
||||
return {
|
||||
effectiveToolsInput: toolsWorkflowInput,
|
||||
effectiveToolsInputSource: "workflow-input" /* WorkflowInput */,
|
||||
toolsRepoPropertyMode: void 0
|
||||
};
|
||||
}
|
||||
const toolsPropertyValue = repositoryProperties["github-codeql-tools" /* TOOLS */];
|
||||
const toolsMode = repositoryProperties["github-codeql-tools-mode" /* TOOLS_MODE */] ?? "enforce" /* Enforce */;
|
||||
@@ -158759,15 +158763,27 @@ function resolveToolsInput(toolsWorkflowInput, isDynamicWorkflow2, repositoryPro
|
||||
logger.info(
|
||||
`Ignoring '${"github-codeql-tools" /* TOOLS */}' repository property because '${"github-codeql-tools-mode" /* TOOLS_MODE */}' is set to '${toolsMode}' and this is not a dynamic workflow.`
|
||||
);
|
||||
return void 0;
|
||||
return {
|
||||
effectiveToolsInput: void 0,
|
||||
effectiveToolsInputSource: "none" /* None */,
|
||||
toolsRepoPropertyMode: toolsMode
|
||||
};
|
||||
}
|
||||
if (toolsPropertyValue) {
|
||||
logger.info(
|
||||
`Setting tools: ${toolsPropertyValue} based on the '${"github-codeql-tools" /* TOOLS */}' repository property.`
|
||||
`Setting tools: ${toolsPropertyValue} based on the '${"github-codeql-tools" /* TOOLS */}' repository property (mode: '${toolsMode}').`
|
||||
);
|
||||
return toolsPropertyValue;
|
||||
return {
|
||||
effectiveToolsInput: toolsPropertyValue,
|
||||
effectiveToolsInputSource: "repository-property" /* RepositoryProperty */,
|
||||
toolsRepoPropertyMode: toolsMode
|
||||
};
|
||||
}
|
||||
return void 0;
|
||||
return {
|
||||
effectiveToolsInput: void 0,
|
||||
effectiveToolsInputSource: "none" /* None */,
|
||||
toolsRepoPropertyMode: void 0
|
||||
};
|
||||
}
|
||||
|
||||
// src/workflow.ts
|
||||
@@ -159060,7 +159076,7 @@ async function sendStartingStatusReport(startedAt, config, logger) {
|
||||
await sendStatusReport(statusReportBase);
|
||||
}
|
||||
}
|
||||
async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, effectiveToolsInput, overlayBaseDatabaseStats, dependencyCachingResults, logger, error3) {
|
||||
async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, effectiveToolsInput, effectiveToolsInputSource, toolsRepoPropertyMode, overlayBaseDatabaseStats, dependencyCachingResults, logger, error3) {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"init" /* Init */,
|
||||
getActionsStatus(error3),
|
||||
@@ -159079,6 +159095,8 @@ async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDo
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
effective_tools_input: effectiveToolsInput || "",
|
||||
effective_tools_input_source: effectiveToolsInputSource,
|
||||
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || "UNKNOWN" /* Unknown */,
|
||||
workflow_languages: workflowLanguages || ""
|
||||
@@ -159123,6 +159141,8 @@ async function run3(startedAt) {
|
||||
let toolsVersion;
|
||||
let zstdAvailability;
|
||||
let effectiveToolsInput;
|
||||
let effectiveToolsInputSource = "none" /* None */;
|
||||
let toolsRepoPropertyMode;
|
||||
try {
|
||||
initializeEnvironment(getActionVersion());
|
||||
persistInputs();
|
||||
@@ -159172,12 +159192,15 @@ async function run3(startedAt) {
|
||||
}
|
||||
const codeQLDefaultVersionInfo = await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||
effectiveToolsInput = resolveToolsInput(
|
||||
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||
getOptionalInput("tools"),
|
||||
isDynamicWorkflow(),
|
||||
repositoryProperties,
|
||||
logger
|
||||
);
|
||||
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||
getOptionalInput("languages")
|
||||
);
|
||||
@@ -159517,6 +159540,8 @@ exec ${goBinaryPath} "$@"`
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingStatus,
|
||||
logger,
|
||||
@@ -159535,6 +159560,8 @@ exec ${goBinaryPath} "$@"`
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingStatus,
|
||||
logger
|
||||
@@ -160108,7 +160135,7 @@ async function runWrapper6() {
|
||||
|
||||
// src/setup-codeql-action.ts
|
||||
var core24 = __toESM(require_core());
|
||||
async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, effectiveToolsInput, logger, error3) {
|
||||
async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, effectiveToolsInput, effectiveToolsInputSource, toolsRepoPropertyMode, logger, error3) {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"setup-codeql" /* SetupCodeQL */,
|
||||
getActionsStatus(error3),
|
||||
@@ -160126,6 +160153,8 @@ async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport,
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
effective_tools_input: effectiveToolsInput || "",
|
||||
effective_tools_input_source: effectiveToolsInputSource,
|
||||
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || "UNKNOWN" /* Unknown */,
|
||||
workflow_languages: ""
|
||||
@@ -160147,6 +160176,8 @@ async function run6(startedAt) {
|
||||
let toolsSource;
|
||||
let toolsVersion;
|
||||
let effectiveToolsInput;
|
||||
let effectiveToolsInputSource = "none" /* None */;
|
||||
let toolsRepoPropertyMode;
|
||||
try {
|
||||
initializeEnvironment(getActionVersion());
|
||||
const apiDetails = {
|
||||
@@ -160186,12 +160217,15 @@ async function run6(startedAt) {
|
||||
logger
|
||||
);
|
||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||
effectiveToolsInput = resolveToolsInput(
|
||||
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||
getOptionalInput("tools"),
|
||||
isDynamicWorkflow(),
|
||||
repositoryProperties,
|
||||
logger
|
||||
);
|
||||
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||
getOptionalInput("languages")
|
||||
);
|
||||
@@ -160239,6 +160273,8 @@ async function run6(startedAt) {
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import test from "ava";
|
||||
|
||||
import { resolveToolsInput } from "../config/resolve-tools-input";
|
||||
import {
|
||||
EffectiveToolsInputSource,
|
||||
resolveToolsInput,
|
||||
resolveToolsInputWithMetadata,
|
||||
} from "../config/resolve-tools-input";
|
||||
import {
|
||||
RepositoryPropertyName,
|
||||
ToolsModeRepositoryPropertyValue,
|
||||
@@ -56,7 +60,7 @@ test("resolveToolsInput returns repository property when only repository propert
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property.",
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -95,7 +99,7 @@ test("resolveToolsInput treats empty string workflow input as not set", (t) => {
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property.",
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -135,7 +139,7 @@ test("resolveToolsInput returns repository property when workflow input is not s
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property.",
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -169,7 +173,7 @@ test("resolveToolsInput applies tools property in enforce mode for static workfl
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property.",
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -188,7 +192,7 @@ test("resolveToolsInput applies tools property in dynamic mode for dynamic workf
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property.",
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'dynamic').",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -215,3 +219,54 @@ test("resolveToolsInput ignores tools property in dynamic mode for static workfl
|
||||
"Ignoring 'github-codeql-tools' repository property because 'github-codeql-tools-mode' is set to 'dynamic' and this is not a dynamic workflow.",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInputWithMetadata reports workflow input source", (t) => {
|
||||
const logger = getRecordingLogger([]);
|
||||
|
||||
const result = resolveToolsInputWithMetadata("latest", false, {}, logger);
|
||||
|
||||
t.is(result.effectiveToolsInput, "latest");
|
||||
t.is(result.effectiveToolsInputSource, EffectiveToolsInputSource.WorkflowInput);
|
||||
t.is(result.toolsRepoPropertyMode, undefined);
|
||||
});
|
||||
|
||||
test("resolveToolsInputWithMetadata reports repository property source and mode", (t) => {
|
||||
const logger = getRecordingLogger([]);
|
||||
|
||||
const result = resolveToolsInputWithMetadata(
|
||||
undefined,
|
||||
false,
|
||||
{
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
[RepositoryPropertyName.TOOLS_MODE]:
|
||||
ToolsModeRepositoryPropertyValue.Enforce,
|
||||
},
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result.effectiveToolsInput, "toolcache");
|
||||
t.is(
|
||||
result.effectiveToolsInputSource,
|
||||
EffectiveToolsInputSource.RepositoryProperty,
|
||||
);
|
||||
t.is(result.toolsRepoPropertyMode, ToolsModeRepositoryPropertyValue.Enforce);
|
||||
});
|
||||
|
||||
test("resolveToolsInputWithMetadata reports dynamic-mode skip on static workflows", (t) => {
|
||||
const logger = getRecordingLogger([]);
|
||||
|
||||
const result = resolveToolsInputWithMetadata(
|
||||
undefined,
|
||||
false,
|
||||
{
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
[RepositoryPropertyName.TOOLS_MODE]:
|
||||
ToolsModeRepositoryPropertyValue.Dynamic,
|
||||
},
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result.effectiveToolsInput, undefined);
|
||||
t.is(result.effectiveToolsInputSource, EffectiveToolsInputSource.None);
|
||||
t.is(result.toolsRepoPropertyMode, ToolsModeRepositoryPropertyValue.Dynamic);
|
||||
});
|
||||
|
||||
@@ -5,6 +5,18 @@ import {
|
||||
} from "../feature-flags/properties";
|
||||
import { Logger } from "../logging";
|
||||
|
||||
export enum EffectiveToolsInputSource {
|
||||
WorkflowInput = "workflow-input",
|
||||
RepositoryProperty = "repository-property",
|
||||
None = "none",
|
||||
}
|
||||
|
||||
export type ResolvedToolsInput = {
|
||||
effectiveToolsInput: string | undefined;
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource;
|
||||
toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves the effective tools input by combining the workflow input and repository properties.
|
||||
* The explicit `tools` workflow input takes precedence. If none is provided,
|
||||
@@ -24,11 +36,29 @@ export function resolveToolsInput(
|
||||
repositoryProperties: RepositoryProperties,
|
||||
logger: Logger,
|
||||
): string | undefined {
|
||||
return resolveToolsInputWithMetadata(
|
||||
toolsWorkflowInput,
|
||||
isDynamicWorkflow,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
).effectiveToolsInput;
|
||||
}
|
||||
|
||||
export function resolveToolsInputWithMetadata(
|
||||
toolsWorkflowInput: string | undefined,
|
||||
isDynamicWorkflow: boolean,
|
||||
repositoryProperties: RepositoryProperties,
|
||||
logger: Logger,
|
||||
): ResolvedToolsInput {
|
||||
if (toolsWorkflowInput) {
|
||||
logger.info(
|
||||
`Setting tools: ${toolsWorkflowInput} based on workflow input.`,
|
||||
);
|
||||
return toolsWorkflowInput;
|
||||
return {
|
||||
effectiveToolsInput: toolsWorkflowInput,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource.WorkflowInput,
|
||||
toolsRepoPropertyMode: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
const toolsPropertyValue = repositoryProperties[RepositoryPropertyName.TOOLS];
|
||||
@@ -44,15 +74,27 @@ export function resolveToolsInput(
|
||||
logger.info(
|
||||
`Ignoring '${RepositoryPropertyName.TOOLS}' repository property because '${RepositoryPropertyName.TOOLS_MODE}' is set to '${toolsMode}' and this is not a dynamic workflow.`,
|
||||
);
|
||||
return undefined;
|
||||
return {
|
||||
effectiveToolsInput: undefined,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource.None,
|
||||
toolsRepoPropertyMode: toolsMode,
|
||||
};
|
||||
}
|
||||
|
||||
if (toolsPropertyValue) {
|
||||
logger.info(
|
||||
`Setting tools: ${toolsPropertyValue} based on the '${RepositoryPropertyName.TOOLS}' repository property.`,
|
||||
`Setting tools: ${toolsPropertyValue} based on the '${RepositoryPropertyName.TOOLS}' repository property (mode: '${toolsMode}').`,
|
||||
);
|
||||
return toolsPropertyValue;
|
||||
return {
|
||||
effectiveToolsInput: toolsPropertyValue,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource.RepositoryProperty,
|
||||
toolsRepoPropertyMode: toolsMode,
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return {
|
||||
effectiveToolsInput: undefined,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource.None,
|
||||
toolsRepoPropertyMode: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
+23
-3
@@ -24,7 +24,10 @@ import {
|
||||
shouldRestoreCache,
|
||||
} from "./caching-utils";
|
||||
import { CodeQL } from "./codeql";
|
||||
import { resolveToolsInput } from "./config/resolve-tools-input";
|
||||
import {
|
||||
EffectiveToolsInputSource,
|
||||
resolveToolsInputWithMetadata,
|
||||
} from "./config/resolve-tools-input";
|
||||
import * as configUtils from "./config-utils";
|
||||
import {
|
||||
DependencyCacheRestoreStatusReport,
|
||||
@@ -40,7 +43,10 @@ import {
|
||||
} from "./diagnostics";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||
import { loadRepositoryProperties } from "./feature-flags/properties";
|
||||
import {
|
||||
loadRepositoryProperties,
|
||||
ToolsModeRepositoryPropertyValue,
|
||||
} from "./feature-flags/properties";
|
||||
import {
|
||||
checkInstallPython311,
|
||||
checkPacksForOverlayCompatibility,
|
||||
@@ -136,6 +142,8 @@ async function sendCompletedStatusReport(
|
||||
toolsSource: ToolsSource,
|
||||
toolsVersion: string,
|
||||
effectiveToolsInput: string | undefined,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource,
|
||||
toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined,
|
||||
overlayBaseDatabaseStats: OverlayBaseDatabaseDownloadStats | undefined,
|
||||
dependencyCachingResults: DependencyCacheRestoreStatusReport | undefined,
|
||||
logger: Logger,
|
||||
@@ -162,6 +170,8 @@ async function sendCompletedStatusReport(
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
effective_tools_input: effectiveToolsInput || "",
|
||||
effective_tools_input_source: effectiveToolsInputSource,
|
||||
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || ToolsSource.Unknown,
|
||||
workflow_languages: workflowLanguages || "",
|
||||
@@ -217,6 +227,9 @@ async function run(startedAt: Date) {
|
||||
let toolsVersion: string;
|
||||
let zstdAvailability: ZstdAvailability | undefined;
|
||||
let effectiveToolsInput: string | undefined;
|
||||
let effectiveToolsInputSource: EffectiveToolsInputSource =
|
||||
EffectiveToolsInputSource.None;
|
||||
let toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined;
|
||||
|
||||
try {
|
||||
initializeEnvironment(getActionVersion());
|
||||
@@ -301,12 +314,15 @@ async function run(startedAt: Date) {
|
||||
// fall back to the 'github-codeql-tools' repository property (if set).
|
||||
// If 'github-codeql-tools-mode' is set to 'dynamic', this fallback applies
|
||||
// only to dynamic workflows. Otherwise, it applies to all workflows.
|
||||
effectiveToolsInput = resolveToolsInput(
|
||||
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||
getOptionalInput("tools"),
|
||||
isDynamicWorkflow(),
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||
const rawLanguages = configUtils.getRawLanguagesNoAutodetect(
|
||||
getOptionalInput("languages"),
|
||||
);
|
||||
@@ -780,6 +796,8 @@ async function run(startedAt: Date) {
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingStatus,
|
||||
logger,
|
||||
@@ -798,6 +816,8 @@ async function run(startedAt: Date) {
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingStatus,
|
||||
logger,
|
||||
|
||||
@@ -11,11 +11,17 @@ import {
|
||||
import { AnalysisKind, getAnalysisKinds } from "./analyses";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { CodeQL } from "./codeql";
|
||||
import { resolveToolsInput } from "./config/resolve-tools-input";
|
||||
import {
|
||||
EffectiveToolsInputSource,
|
||||
resolveToolsInputWithMetadata,
|
||||
} from "./config/resolve-tools-input";
|
||||
import { getRawLanguagesNoAutodetect } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import { loadRepositoryProperties } from "./feature-flags/properties";
|
||||
import {
|
||||
loadRepositoryProperties,
|
||||
ToolsModeRepositoryPropertyValue,
|
||||
} from "./feature-flags/properties";
|
||||
import { initCodeQL } from "./init";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
@@ -52,6 +58,8 @@ async function sendCompletedStatusReport(
|
||||
toolsSource: ToolsSource,
|
||||
toolsVersion: string,
|
||||
effectiveToolsInput: string | undefined,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource,
|
||||
toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined,
|
||||
logger: Logger,
|
||||
error?: Error,
|
||||
): Promise<void> {
|
||||
@@ -74,6 +82,8 @@ async function sendCompletedStatusReport(
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
effective_tools_input: effectiveToolsInput || "",
|
||||
effective_tools_input_source: effectiveToolsInputSource,
|
||||
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || ToolsSource.Unknown,
|
||||
workflow_languages: "",
|
||||
@@ -105,6 +115,9 @@ async function run(startedAt: Date): Promise<void> {
|
||||
let toolsSource: ToolsSource;
|
||||
let toolsVersion: string;
|
||||
let effectiveToolsInput: string | undefined;
|
||||
let effectiveToolsInputSource: EffectiveToolsInputSource =
|
||||
EffectiveToolsInputSource.None;
|
||||
let toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined;
|
||||
|
||||
try {
|
||||
initializeEnvironment(getActionVersion());
|
||||
@@ -160,12 +173,15 @@ async function run(startedAt: Date): Promise<void> {
|
||||
// fall back to the 'github-codeql-tools' repository property (if set).
|
||||
// If 'github-codeql-tools-mode' is set to 'dynamic', this fallback applies
|
||||
// only to dynamic workflows. Otherwise, it applies to all workflows.
|
||||
effectiveToolsInput = resolveToolsInput(
|
||||
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||
getOptionalInput("tools"),
|
||||
isDynamicWorkflow(),
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||
getOptionalInput("languages"),
|
||||
);
|
||||
@@ -218,6 +234,8 @@ async function run(startedAt: Date): Promise<void> {
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import test from "ava";
|
||||
import * as sinon from "sinon";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { EffectiveToolsInputSource } from "./config/resolve-tools-input";
|
||||
import { Config } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
@@ -317,6 +318,8 @@ const testCreateInitWithConfigStatusReport = makeMacro({
|
||||
...statusReportBase,
|
||||
tools_input: "",
|
||||
effective_tools_input: "",
|
||||
effective_tools_input_source: EffectiveToolsInputSource.None,
|
||||
tools_repo_property_mode: "",
|
||||
tools_resolved_version: "foo",
|
||||
tools_source: ToolsSource.Unknown,
|
||||
workflow_languages: "actions",
|
||||
@@ -348,6 +351,8 @@ testCreateInitWithConfigStatusReport.serial(
|
||||
languages: [BuiltInLanguage.java, BuiltInLanguage.swift],
|
||||
}),
|
||||
{
|
||||
effective_tools_input_source: EffectiveToolsInputSource.None,
|
||||
tools_repo_property_mode: "",
|
||||
trap_cache_download_size_bytes: 1024,
|
||||
registries: "[]",
|
||||
query_filters: "[]",
|
||||
@@ -355,6 +360,63 @@ testCreateInitWithConfigStatusReport.serial(
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"createInitWithConfigStatusReport preserves tools telemetry fields",
|
||||
async (t) => {
|
||||
await withTmpDir(async (tmpDir: string) => {
|
||||
setupEnvironmentAndStub(tmpDir);
|
||||
|
||||
const config = createTestConfig({
|
||||
buildMode: BuildMode.None,
|
||||
languages: [BuiltInLanguage.java],
|
||||
});
|
||||
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
ActionName.Init,
|
||||
"failure",
|
||||
new Date("May 19, 2023 05:19:00"),
|
||||
config,
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
);
|
||||
|
||||
if (t.truthy(statusReportBase)) {
|
||||
const initStatusReport: InitStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: "",
|
||||
effective_tools_input: "toolcache",
|
||||
effective_tools_input_source:
|
||||
EffectiveToolsInputSource.RepositoryProperty,
|
||||
tools_repo_property_mode: "dynamic",
|
||||
tools_resolved_version: "foo",
|
||||
tools_source: ToolsSource.Unknown,
|
||||
workflow_languages: "actions",
|
||||
};
|
||||
|
||||
const initWithConfigStatusReport =
|
||||
await createInitWithConfigStatusReport(
|
||||
config,
|
||||
initStatusReport,
|
||||
undefined,
|
||||
1024,
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
|
||||
if (t.truthy(initWithConfigStatusReport)) {
|
||||
t.is(
|
||||
initWithConfigStatusReport.effective_tools_input_source,
|
||||
EffectiveToolsInputSource.RepositoryProperty,
|
||||
);
|
||||
t.is(initWithConfigStatusReport.tools_repo_property_mode, "dynamic");
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testCreateInitWithConfigStatusReport.serial(
|
||||
"includes packs for a single language",
|
||||
createTestConfig({
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
isSelfHostedRunner,
|
||||
} from "./actions-util";
|
||||
import { getAnalysisKey, getApiClient } from "./api-client";
|
||||
import { EffectiveToolsInputSource } from "./config/resolve-tools-input";
|
||||
import { parseRegistriesWithoutCredentials, type Config } from "./config-utils";
|
||||
import { DependencyCacheRestoreStatusReport } from "./dependency-caching";
|
||||
import { DocUrl } from "./doc-url";
|
||||
@@ -484,6 +485,10 @@ export interface InitStatusReport extends StatusReportBase {
|
||||
tools_input: string;
|
||||
/** The effective tools input that was used, after applying defaults and repository properties. */
|
||||
effective_tools_input: string;
|
||||
/** Indicates where the effective tools input was resolved from. */
|
||||
effective_tools_input_source: EffectiveToolsInputSource;
|
||||
/** The value of the tools repository property mode, if relevant. */
|
||||
tools_repo_property_mode: string;
|
||||
/** Version of the bundle used. */
|
||||
tools_resolved_version: string;
|
||||
/** Where the bundle originated from. */
|
||||
|
||||
Reference in New Issue
Block a user