mirror of
https://github.com/github/codeql-action.git
synced 2026-08-05 21:06:13 -05:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d1418f9e47 | |||
| 21066c2326 | |||
| 8c6a2b4d4b | |||
| 57b3666b1d | |||
| 1251f87758 | |||
| 6963dfbbc5 | |||
| d426d33115 | |||
| f22e7a29ce | |||
| d8e5e3dbab | |||
| 9b49e27edb | |||
| aeb3e20ace | |||
| d622e410d6 | |||
| fb605661cd | |||
| 063bb8b614 | |||
| 3d8236de69 | |||
| b1eeb13c4c | |||
| 964d328667 | |||
| f9b6569832 | |||
| 3782e65e9f | |||
| dafa67e1d3 | |||
| 0d5f0f55c2 | |||
| 7c7926f8df | |||
| 838486a3c3 | |||
| 09a0f62a7a | |||
| 652e91defb |
+1
-1
@@ -4,7 +4,7 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
|
|||||||
|
|
||||||
## [UNRELEASED]
|
## [UNRELEASED]
|
||||||
|
|
||||||
No user facing changes.
|
- Organizations can create a custom repository property named `github-codeql-tools` to set a default CodeQL CLI tools value. You can optionally set `github-codeql-tools-mode` to control scope: use `enforce` (default) to apply to all workflows, or `dynamic` to apply only to dynamic workflows. If a workflow provides an explicit `tools:` input, that input takes precedence. For more information, see [Managing custom properties for repositories in your organization](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization), [Repository properties for Code Scanning](https://docs.github.com/en/code-security/concepts/code-scanning/repository-properties) and [Customizing your advanced setup for code scanning](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning).
|
||||||
|
|
||||||
## 4.36.2 - 04 Jun 2026
|
## 4.36.2 - 04 Jun 2026
|
||||||
|
|
||||||
|
|||||||
Generated
+131
-30
@@ -150447,11 +150447,14 @@ function getUnknownLanguagesError(languages) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/feature-flags/properties.ts
|
// src/feature-flags/properties.ts
|
||||||
|
var github2 = __toESM(require_github());
|
||||||
var GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-";
|
var GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-";
|
||||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||||
|
RepositoryPropertyName2["TOOLS"] = "github-codeql-tools";
|
||||||
|
RepositoryPropertyName2["TOOLS_MODE"] = "github-codeql-tools-mode";
|
||||||
return RepositoryPropertyName2;
|
return RepositoryPropertyName2;
|
||||||
})(RepositoryPropertyName || {});
|
})(RepositoryPropertyName || {});
|
||||||
function isString2(value) {
|
function isString2(value) {
|
||||||
@@ -150469,7 +150472,12 @@ var booleanProperty = {
|
|||||||
var repositoryPropertyParsers = {
|
var repositoryPropertyParsers = {
|
||||||
["github-codeql-disable-overlay" /* DISABLE_OVERLAY */]: booleanProperty,
|
["github-codeql-disable-overlay" /* DISABLE_OVERLAY */]: booleanProperty,
|
||||||
["github-codeql-extra-queries" /* EXTRA_QUERIES */]: stringProperty,
|
["github-codeql-extra-queries" /* EXTRA_QUERIES */]: stringProperty,
|
||||||
["github-codeql-file-coverage-on-prs" /* FILE_COVERAGE_ON_PRS */]: booleanProperty
|
["github-codeql-file-coverage-on-prs" /* FILE_COVERAGE_ON_PRS */]: booleanProperty,
|
||||||
|
["github-codeql-tools" /* TOOLS */]: stringProperty,
|
||||||
|
["github-codeql-tools-mode" /* TOOLS_MODE */]: {
|
||||||
|
validate: isString2,
|
||||||
|
parse: parseToolsModeRepositoryProperty
|
||||||
|
}
|
||||||
};
|
};
|
||||||
async function loadPropertiesFromApi(logger, repositoryNwo) {
|
async function loadPropertiesFromApi(logger, repositoryNwo) {
|
||||||
try {
|
try {
|
||||||
@@ -150522,6 +150530,26 @@ async function loadPropertiesFromApi(logger, repositoryNwo) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async function loadRepositoryProperties(repositoryNwo, logger) {
|
||||||
|
const repositoryOwnerType = github2.context.payload.repository?.owner.type;
|
||||||
|
logger.debug(
|
||||||
|
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`
|
||||||
|
);
|
||||||
|
if (repositoryOwnerType === "User") {
|
||||||
|
logger.debug(
|
||||||
|
"Skipping loading repository properties because the repository is owned by a user and therefore cannot have repository properties."
|
||||||
|
);
|
||||||
|
return new Success({});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
||||||
|
} catch (error3) {
|
||||||
|
logger.info(
|
||||||
|
`Failed to load repository properties: ${getErrorMessage(error3)}`
|
||||||
|
);
|
||||||
|
return new Failure(error3);
|
||||||
|
}
|
||||||
|
}
|
||||||
function setProperty2(properties, name, value, logger) {
|
function setProperty2(properties, name, value, logger) {
|
||||||
const propertyOptions = repositoryPropertyParsers[name];
|
const propertyOptions = repositoryPropertyParsers[name];
|
||||||
if (propertyOptions.validate(value)) {
|
if (propertyOptions.validate(value)) {
|
||||||
@@ -150543,6 +150571,15 @@ function parseBooleanRepositoryProperty(name, value, logger) {
|
|||||||
function parseStringRepositoryProperty(_name, value) {
|
function parseStringRepositoryProperty(_name, value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
function parseToolsModeRepositoryProperty(name, value, logger) {
|
||||||
|
if (value !== "dynamic" /* Dynamic */ && value !== "enforce" /* Enforce */) {
|
||||||
|
logger.warning(
|
||||||
|
`Repository property '${name}' has unexpected value '${value}'. Expected 'dynamic' or 'enforce'. Defaulting to 'enforce'.`
|
||||||
|
);
|
||||||
|
return "enforce" /* Enforce */;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||||
Object.values(RepositoryPropertyName)
|
Object.values(RepositoryPropertyName)
|
||||||
);
|
);
|
||||||
@@ -153421,7 +153458,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, useO
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (allowToolcacheValueFF) {
|
if (allowToolcacheValueFF) {
|
||||||
logger.warning(
|
logger.info(
|
||||||
`Ignoring 'tools: ${toolsInput}' because the workflow was not triggered dynamically.`
|
`Ignoring 'tools: ${toolsInput}' because the workflow was not triggered dynamically.`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -156746,7 +156783,7 @@ var fs19 = __toESM(require("fs"));
|
|||||||
var path17 = __toESM(require("path"));
|
var path17 = __toESM(require("path"));
|
||||||
var core14 = __toESM(require_core());
|
var core14 = __toESM(require_core());
|
||||||
var toolrunner4 = __toESM(require_toolrunner());
|
var toolrunner4 = __toESM(require_toolrunner());
|
||||||
var github2 = __toESM(require_github());
|
var github3 = __toESM(require_github());
|
||||||
var io6 = __toESM(require_io());
|
var io6 = __toESM(require_io());
|
||||||
async function initCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, rawLanguages, useOverlayAwareDefaultCliVersion, features, logger) {
|
async function initCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, rawLanguages, useOverlayAwareDefaultCliVersion, features, logger) {
|
||||||
logger.startGroup("Setup CodeQL tools");
|
logger.startGroup("Setup CodeQL tools");
|
||||||
@@ -156950,7 +156987,7 @@ function logFileCoverageOnPrsDeprecationWarning(logger) {
|
|||||||
if (process.env["CODEQL_ACTION_DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION" /* DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION */]) {
|
if (process.env["CODEQL_ACTION_DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION" /* DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION */]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const repositoryOwnerType = github2.context.payload.repository?.owner.type;
|
const repositoryOwnerType = github3.context.payload.repository?.owner.type;
|
||||||
let message = "Starting April 2026, the CodeQL Action will skip computing file coverage information on pull requests to improve analysis performance. File coverage information will still be computed on non-PR analyses.";
|
let message = "Starting April 2026, the CodeQL Action will skip computing file coverage information on pull requests to improve analysis performance. File coverage information will still be computed on non-PR analyses.";
|
||||||
const envVarOptOut = "set the `CODEQL_ACTION_FILE_COVERAGE_ON_PRS` environment variable to `true`.";
|
const envVarOptOut = "set the `CODEQL_ACTION_FILE_COVERAGE_ON_PRS` environment variable to `true`.";
|
||||||
const repoPropertyOptOut = 'create a custom repository property with the name `github-codeql-file-coverage-on-prs` and the type "True/false", then set this property to `true` in the repository\'s settings.';
|
const repoPropertyOptOut = 'create a custom repository property with the name `github-codeql-file-coverage-on-prs` and the type "True/false", then set this property to `true` in the repository\'s settings.';
|
||||||
@@ -158738,10 +158775,50 @@ async function runWrapper3() {
|
|||||||
var fs27 = __toESM(require("fs"));
|
var fs27 = __toESM(require("fs"));
|
||||||
var path23 = __toESM(require("path"));
|
var path23 = __toESM(require("path"));
|
||||||
var core21 = __toESM(require_core());
|
var core21 = __toESM(require_core());
|
||||||
var github3 = __toESM(require_github());
|
|
||||||
var io7 = __toESM(require_io());
|
var io7 = __toESM(require_io());
|
||||||
var semver10 = __toESM(require_semver2());
|
var semver10 = __toESM(require_semver2());
|
||||||
|
|
||||||
|
// src/config/resolve-tools-input.ts
|
||||||
|
function resolveToolsInputWithMetadata(toolsWorkflowInput, isDynamicWorkflow2, repositoryProperties, logger) {
|
||||||
|
if (toolsWorkflowInput) {
|
||||||
|
logger.info(
|
||||||
|
`Setting tools: ${toolsWorkflowInput} based on workflow input.`
|
||||||
|
);
|
||||||
|
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 */;
|
||||||
|
if (toolsPropertyValue && toolsMode === "dynamic" /* Dynamic */ && !isDynamicWorkflow2) {
|
||||||
|
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 {
|
||||||
|
effectiveToolsInput: void 0,
|
||||||
|
effectiveToolsInputSource: "none" /* None */,
|
||||||
|
toolsRepoPropertyMode: toolsMode
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (toolsPropertyValue) {
|
||||||
|
logger.info(
|
||||||
|
`Setting tools: ${toolsPropertyValue} based on the '${"github-codeql-tools" /* TOOLS */}' repository property (mode: '${toolsMode}').`
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
effectiveToolsInput: toolsPropertyValue,
|
||||||
|
effectiveToolsInputSource: "repository-property" /* RepositoryProperty */,
|
||||||
|
toolsRepoPropertyMode: toolsMode
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
effectiveToolsInput: void 0,
|
||||||
|
effectiveToolsInputSource: "none" /* None */,
|
||||||
|
toolsRepoPropertyMode: void 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// src/workflow.ts
|
// src/workflow.ts
|
||||||
var fs26 = __toESM(require("fs"));
|
var fs26 = __toESM(require("fs"));
|
||||||
var path22 = __toESM(require("path"));
|
var path22 = __toESM(require("path"));
|
||||||
@@ -159032,7 +159109,7 @@ async function sendStartingStatusReport(startedAt, config, logger) {
|
|||||||
await sendStatusReport(statusReportBase);
|
await sendStatusReport(statusReportBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, 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(
|
const statusReportBase = await createStatusReportBase(
|
||||||
"init" /* Init */,
|
"init" /* Init */,
|
||||||
getActionsStatus(error3),
|
getActionsStatus(error3),
|
||||||
@@ -159050,6 +159127,9 @@ async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDo
|
|||||||
const initStatusReport = {
|
const initStatusReport = {
|
||||||
...statusReportBase,
|
...statusReportBase,
|
||||||
tools_input: getOptionalInput("tools") || "",
|
tools_input: getOptionalInput("tools") || "",
|
||||||
|
effective_tools_input: effectiveToolsInput || "",
|
||||||
|
effective_tools_input_source: effectiveToolsInputSource,
|
||||||
|
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||||
tools_resolved_version: toolsVersion,
|
tools_resolved_version: toolsVersion,
|
||||||
tools_source: toolsSource || "UNKNOWN" /* Unknown */,
|
tools_source: toolsSource || "UNKNOWN" /* Unknown */,
|
||||||
workflow_languages: workflowLanguages || ""
|
workflow_languages: workflowLanguages || ""
|
||||||
@@ -159093,6 +159173,9 @@ async function run3(startedAt) {
|
|||||||
let toolsSource;
|
let toolsSource;
|
||||||
let toolsVersion;
|
let toolsVersion;
|
||||||
let zstdAvailability;
|
let zstdAvailability;
|
||||||
|
let effectiveToolsInput;
|
||||||
|
let effectiveToolsInputSource;
|
||||||
|
let toolsRepoPropertyMode;
|
||||||
try {
|
try {
|
||||||
initializeEnvironment(getActionVersion());
|
initializeEnvironment(getActionVersion());
|
||||||
persistInputs();
|
persistInputs();
|
||||||
@@ -159116,6 +159199,7 @@ async function run3(startedAt) {
|
|||||||
repositoryNwo,
|
repositoryNwo,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||||
const jobRunUuid = v4_default();
|
const jobRunUuid = v4_default();
|
||||||
logger.info(`Job run UUID is ${jobRunUuid}.`);
|
logger.info(`Job run UUID is ${jobRunUuid}.`);
|
||||||
core21.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid);
|
core21.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid);
|
||||||
@@ -159141,12 +159225,21 @@ async function run3(startedAt) {
|
|||||||
}
|
}
|
||||||
const codeQLDefaultVersionInfo = await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
const codeQLDefaultVersionInfo = await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||||
|
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||||
|
getOptionalInput("tools"),
|
||||||
|
isDynamicWorkflow(),
|
||||||
|
repositoryProperties,
|
||||||
|
logger
|
||||||
|
);
|
||||||
|
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||||
|
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||||
|
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||||
getOptionalInput("languages")
|
getOptionalInput("languages")
|
||||||
);
|
);
|
||||||
const useOverlayAwareDefaultCliVersion = analysisKinds?.length === 1 && analysisKinds[0] === "code-scanning" /* CodeScanning */;
|
const useOverlayAwareDefaultCliVersion = analysisKinds?.length === 1 && analysisKinds[0] === "code-scanning" /* CodeScanning */;
|
||||||
const initCodeQLResult = await initCodeQL(
|
const initCodeQLResult = await initCodeQL(
|
||||||
getOptionalInput("tools"),
|
effectiveToolsInput,
|
||||||
apiDetails,
|
apiDetails,
|
||||||
getTemporaryDirectory(),
|
getTemporaryDirectory(),
|
||||||
gitHubVersion.type,
|
gitHubVersion.type,
|
||||||
@@ -159182,7 +159275,6 @@ async function run3(startedAt) {
|
|||||||
}
|
}
|
||||||
analysisKinds = await getAnalysisKinds(logger, features);
|
analysisKinds = await getAnalysisKinds(logger, features);
|
||||||
const debugMode = getOptionalInput("debug") === "true" || core21.isDebug();
|
const debugMode = getOptionalInput("debug") === "true" || core21.isDebug();
|
||||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
|
||||||
const fileCoverageResult = await getFileCoverageInformationEnabled(
|
const fileCoverageResult = await getFileCoverageInformationEnabled(
|
||||||
debugMode,
|
debugMode,
|
||||||
codeql,
|
codeql,
|
||||||
@@ -159483,6 +159575,9 @@ exec ${goBinaryPath} "$@"`
|
|||||||
toolsFeatureFlagsValid,
|
toolsFeatureFlagsValid,
|
||||||
toolsSource,
|
toolsSource,
|
||||||
toolsVersion,
|
toolsVersion,
|
||||||
|
effectiveToolsInput,
|
||||||
|
effectiveToolsInputSource,
|
||||||
|
toolsRepoPropertyMode,
|
||||||
overlayBaseDatabaseStats,
|
overlayBaseDatabaseStats,
|
||||||
dependencyCachingStatus,
|
dependencyCachingStatus,
|
||||||
logger,
|
logger,
|
||||||
@@ -159500,31 +159595,14 @@ exec ${goBinaryPath} "$@"`
|
|||||||
toolsFeatureFlagsValid,
|
toolsFeatureFlagsValid,
|
||||||
toolsSource,
|
toolsSource,
|
||||||
toolsVersion,
|
toolsVersion,
|
||||||
|
effectiveToolsInput,
|
||||||
|
effectiveToolsInputSource,
|
||||||
|
toolsRepoPropertyMode,
|
||||||
overlayBaseDatabaseStats,
|
overlayBaseDatabaseStats,
|
||||||
dependencyCachingStatus,
|
dependencyCachingStatus,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
async function loadRepositoryProperties(repositoryNwo, logger) {
|
|
||||||
const repositoryOwnerType = github3.context.payload.repository?.owner.type;
|
|
||||||
logger.debug(
|
|
||||||
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`
|
|
||||||
);
|
|
||||||
if (repositoryOwnerType === "User") {
|
|
||||||
logger.debug(
|
|
||||||
"Skipping loading repository properties because the repository is owned by a user and therefore cannot have repository properties."
|
|
||||||
);
|
|
||||||
return new Success({});
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
|
||||||
} catch (error3) {
|
|
||||||
logger.warning(
|
|
||||||
`Failed to load repository properties: ${getErrorMessage(error3)}`
|
|
||||||
);
|
|
||||||
return new Failure(error3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function recordZstdAvailability(config, zstdAvailability) {
|
async function recordZstdAvailability(config, zstdAvailability) {
|
||||||
addNoLanguageDiagnostic(
|
addNoLanguageDiagnostic(
|
||||||
config,
|
config,
|
||||||
@@ -160093,7 +160171,7 @@ async function runWrapper6() {
|
|||||||
|
|
||||||
// src/setup-codeql-action.ts
|
// src/setup-codeql-action.ts
|
||||||
var core24 = __toESM(require_core());
|
var core24 = __toESM(require_core());
|
||||||
async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error3) {
|
async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, effectiveToolsInput, effectiveToolsInputSource, toolsRepoPropertyMode, logger, error3) {
|
||||||
const statusReportBase = await createStatusReportBase(
|
const statusReportBase = await createStatusReportBase(
|
||||||
"setup-codeql" /* SetupCodeQL */,
|
"setup-codeql" /* SetupCodeQL */,
|
||||||
getActionsStatus(error3),
|
getActionsStatus(error3),
|
||||||
@@ -160110,6 +160188,9 @@ async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport,
|
|||||||
const initStatusReport = {
|
const initStatusReport = {
|
||||||
...statusReportBase,
|
...statusReportBase,
|
||||||
tools_input: getOptionalInput("tools") || "",
|
tools_input: getOptionalInput("tools") || "",
|
||||||
|
effective_tools_input: effectiveToolsInput || "",
|
||||||
|
effective_tools_input_source: effectiveToolsInputSource,
|
||||||
|
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||||
tools_resolved_version: toolsVersion,
|
tools_resolved_version: toolsVersion,
|
||||||
tools_source: toolsSource || "UNKNOWN" /* Unknown */,
|
tools_source: toolsSource || "UNKNOWN" /* Unknown */,
|
||||||
workflow_languages: ""
|
workflow_languages: ""
|
||||||
@@ -160130,6 +160211,9 @@ async function run6(startedAt) {
|
|||||||
let toolsFeatureFlagsValid;
|
let toolsFeatureFlagsValid;
|
||||||
let toolsSource;
|
let toolsSource;
|
||||||
let toolsVersion;
|
let toolsVersion;
|
||||||
|
let effectiveToolsInput;
|
||||||
|
let effectiveToolsInputSource;
|
||||||
|
let toolsRepoPropertyMode;
|
||||||
try {
|
try {
|
||||||
initializeEnvironment(getActionVersion());
|
initializeEnvironment(getActionVersion());
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
@@ -160164,12 +160248,26 @@ async function run6(startedAt) {
|
|||||||
}
|
}
|
||||||
const codeQLDefaultVersionInfo = await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
const codeQLDefaultVersionInfo = await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||||
|
const repositoryPropertiesResult = await loadRepositoryProperties(
|
||||||
|
repositoryNwo,
|
||||||
|
logger
|
||||||
|
);
|
||||||
|
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||||
|
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||||
|
getOptionalInput("tools"),
|
||||||
|
isDynamicWorkflow(),
|
||||||
|
repositoryProperties,
|
||||||
|
logger
|
||||||
|
);
|
||||||
|
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||||
|
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||||
|
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||||
getOptionalInput("languages")
|
getOptionalInput("languages")
|
||||||
);
|
);
|
||||||
const analysisKinds = await getAnalysisKinds(logger, features);
|
const analysisKinds = await getAnalysisKinds(logger, features);
|
||||||
const initCodeQLResult = await initCodeQL(
|
const initCodeQLResult = await initCodeQL(
|
||||||
getOptionalInput("tools"),
|
effectiveToolsInput,
|
||||||
apiDetails,
|
apiDetails,
|
||||||
getTemporaryDirectory(),
|
getTemporaryDirectory(),
|
||||||
gitHubVersion.type,
|
gitHubVersion.type,
|
||||||
@@ -160210,6 +160308,9 @@ async function run6(startedAt) {
|
|||||||
toolsFeatureFlagsValid,
|
toolsFeatureFlagsValid,
|
||||||
toolsSource,
|
toolsSource,
|
||||||
toolsVersion,
|
toolsVersion,
|
||||||
|
effectiveToolsInput,
|
||||||
|
effectiveToolsInputSource,
|
||||||
|
toolsRepoPropertyMode,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import {
|
|||||||
} from "./dependency-caching";
|
} from "./dependency-caching";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { initFeatures } from "./feature-flags";
|
import { initFeatures } from "./feature-flags";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { getActionsLogger, Logger } from "./logging";
|
import { getActionsLogger, Logger } from "./logging";
|
||||||
import { cleanupAndUploadOverlayBaseDatabaseToCache } from "./overlay/caching";
|
import { cleanupAndUploadOverlayBaseDatabaseToCache } from "./overlay/caching";
|
||||||
import { getRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import {
|
|||||||
} from "./analyze";
|
} from "./analyze";
|
||||||
import { createStubCodeQL } from "./codeql";
|
import { createStubCodeQL } from "./codeql";
|
||||||
import { Feature } from "./feature-flags";
|
import { Feature } from "./feature-flags";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import {
|
import {
|
||||||
setupTests,
|
setupTests,
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ import {
|
|||||||
} from "./diff-informed-analysis-utils";
|
} from "./diff-informed-analysis-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { FeatureEnablement, Feature } from "./feature-flags";
|
import { FeatureEnablement, Feature } from "./feature-flags";
|
||||||
import { BuiltInLanguage, Language } from "./languages";
|
import { BuiltInLanguage, Language } from "./languages/index";
|
||||||
import { Logger, withGroupAsync } from "./logging";
|
import { Logger, withGroupAsync } from "./logging";
|
||||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||||
import type * as sarif from "./sarif";
|
import type * as sarif from "./sarif";
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { determineAutobuildLanguages, runAutobuild } from "./autobuild";
|
|||||||
import { getCodeQL } from "./codeql";
|
import { getCodeQL } from "./codeql";
|
||||||
import { Config, getConfig } from "./config-utils";
|
import { Config, getConfig } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages/index";
|
||||||
import { Logger, getActionsLogger } from "./logging";
|
import { Logger, getActionsLogger } from "./logging";
|
||||||
import {
|
import {
|
||||||
StatusReportBase,
|
StatusReportBase,
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import * as configUtils from "./config-utils";
|
|||||||
import { DocUrl } from "./doc-url";
|
import { DocUrl } from "./doc-url";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Feature, featureConfig, initFeatures } from "./feature-flags";
|
import { Feature, featureConfig, initFeatures } from "./feature-flags";
|
||||||
import { BuiltInLanguage, Language } from "./languages";
|
import { BuiltInLanguage, Language } from "./languages/index";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { getRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import { asyncFilter, BuildMode } from "./util";
|
import { asyncFilter, BuildMode } from "./util";
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ import {
|
|||||||
import type { Config } from "./config-utils";
|
import type { Config } from "./config-utils";
|
||||||
import * as defaults from "./defaults.json";
|
import * as defaults from "./defaults.json";
|
||||||
import { DocUrl } from "./doc-url";
|
import { DocUrl } from "./doc-url";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import { ToolsSource } from "./setup-codeql";
|
import { ToolsSource } from "./setup-codeql";
|
||||||
import {
|
import {
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ import {
|
|||||||
FeatureEnablement,
|
FeatureEnablement,
|
||||||
} from "./feature-flags";
|
} from "./feature-flags";
|
||||||
import { isAnalyzingDefaultBranch } from "./git-utils";
|
import { isAnalyzingDefaultBranch } from "./git-utils";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages/index";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { writeBaseDatabaseOidsFile, writeOverlayChangesFile } from "./overlay";
|
import { writeBaseDatabaseOidsFile, writeOverlayChangesFile } from "./overlay";
|
||||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { Feature } from "./feature-flags";
|
|||||||
import { RepositoryProperties } from "./feature-flags/properties";
|
import { RepositoryProperties } from "./feature-flags/properties";
|
||||||
import * as gitUtils from "./git-utils";
|
import * as gitUtils from "./git-utils";
|
||||||
import { GitVersionInfo } from "./git-utils";
|
import { GitVersionInfo } from "./git-utils";
|
||||||
import { BuiltInLanguage, Language } from "./languages";
|
import { BuiltInLanguage, Language } from "./languages/index";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay";
|
import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay";
|
||||||
import * as overlayDiagnostics from "./overlay/diagnostics";
|
import * as overlayDiagnostics from "./overlay/diagnostics";
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ import {
|
|||||||
hasSubmodules,
|
hasSubmodules,
|
||||||
isAnalyzingDefaultBranch,
|
isAnalyzingDefaultBranch,
|
||||||
} from "./git-utils";
|
} from "./git-utils";
|
||||||
import { BuiltInLanguage, Language } from "./languages";
|
import { BuiltInLanguage, Language } from "./languages/index";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay";
|
import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -0,0 +1,280 @@
|
|||||||
|
import test from "ava";
|
||||||
|
|
||||||
|
import {
|
||||||
|
EffectiveToolsInputSource,
|
||||||
|
resolveToolsInput,
|
||||||
|
resolveToolsInputWithMetadata,
|
||||||
|
} from "../config/resolve-tools-input";
|
||||||
|
import {
|
||||||
|
RepositoryPropertyName,
|
||||||
|
ToolsModeRepositoryPropertyValue,
|
||||||
|
} from "../feature-flags/properties";
|
||||||
|
import type { RepositoryProperties } from "../feature-flags/properties";
|
||||||
|
import {
|
||||||
|
getRecordingLogger,
|
||||||
|
LoggedMessage,
|
||||||
|
setupTests,
|
||||||
|
} from "../testing-utils";
|
||||||
|
|
||||||
|
setupTests(test);
|
||||||
|
|
||||||
|
test("resolveToolsInput returns undefined when no tools input or repository property is set", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const result = resolveToolsInput(undefined, false, {}, logger);
|
||||||
|
|
||||||
|
t.is(result, undefined);
|
||||||
|
t.is(loggedMessages.length, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput returns workflow input when only workflow input is provided", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const result = resolveToolsInput("latest", false, {}, logger);
|
||||||
|
|
||||||
|
t.is(result, "latest");
|
||||||
|
t.is(loggedMessages.length, 1);
|
||||||
|
t.is(
|
||||||
|
loggedMessages[0].message,
|
||||||
|
"Setting tools: latest based on workflow input.",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput returns repository property when only repository property is provided", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const repositoryProperties: RepositoryProperties = {
|
||||||
|
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||||
|
};
|
||||||
|
const result = resolveToolsInput(
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(result, "toolcache");
|
||||||
|
t.is(loggedMessages.length, 1);
|
||||||
|
t.is(
|
||||||
|
loggedMessages[0].message,
|
||||||
|
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput prioritizes workflow input over repository property", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const repositoryProperties: RepositoryProperties = {
|
||||||
|
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||||
|
};
|
||||||
|
const result = resolveToolsInput(
|
||||||
|
"nightly",
|
||||||
|
false,
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(result, "nightly");
|
||||||
|
t.is(loggedMessages.length, 1);
|
||||||
|
t.is(
|
||||||
|
loggedMessages[0].message,
|
||||||
|
"Setting tools: nightly based on workflow input.",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput treats empty string workflow input as not set", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const repositoryProperties: RepositoryProperties = {
|
||||||
|
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||||
|
};
|
||||||
|
const result = resolveToolsInput("", false, repositoryProperties, logger);
|
||||||
|
|
||||||
|
t.is(result, "toolcache");
|
||||||
|
t.is(loggedMessages.length, 1);
|
||||||
|
t.is(
|
||||||
|
loggedMessages[0].message,
|
||||||
|
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput returns undefined when repository property is undefined", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const repositoryProperties: RepositoryProperties = {
|
||||||
|
[RepositoryPropertyName.TOOLS]: undefined,
|
||||||
|
};
|
||||||
|
const result = resolveToolsInput(
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(result, undefined);
|
||||||
|
t.is(loggedMessages.length, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput returns repository property when workflow input is not set", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const repositoryProperties: RepositoryProperties = {
|
||||||
|
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||||
|
};
|
||||||
|
const result = resolveToolsInput(
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(result, "toolcache");
|
||||||
|
t.is(loggedMessages.length, 1);
|
||||||
|
t.is(
|
||||||
|
loggedMessages[0].message,
|
||||||
|
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput does not log when workflow input and repository property are not set", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const result = resolveToolsInput(undefined, false, {}, logger);
|
||||||
|
|
||||||
|
t.is(result, undefined);
|
||||||
|
t.is(loggedMessages.length, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput applies tools property in enforce mode for static workflows", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const repositoryProperties: RepositoryProperties = {
|
||||||
|
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||||
|
[RepositoryPropertyName.TOOLS_MODE]:
|
||||||
|
ToolsModeRepositoryPropertyValue.Enforce,
|
||||||
|
};
|
||||||
|
const result = resolveToolsInput(
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(result, "toolcache");
|
||||||
|
t.is(loggedMessages.length, 1);
|
||||||
|
t.is(
|
||||||
|
loggedMessages[0].message,
|
||||||
|
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput applies tools property in dynamic mode for dynamic workflows", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const repositoryProperties: RepositoryProperties = {
|
||||||
|
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||||
|
[RepositoryPropertyName.TOOLS_MODE]:
|
||||||
|
ToolsModeRepositoryPropertyValue.Dynamic,
|
||||||
|
};
|
||||||
|
const result = resolveToolsInput(
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(result, "toolcache");
|
||||||
|
t.is(loggedMessages.length, 1);
|
||||||
|
t.is(
|
||||||
|
loggedMessages[0].message,
|
||||||
|
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'dynamic').",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolveToolsInput ignores tools property in dynamic mode for static workflows", (t) => {
|
||||||
|
const loggedMessages: LoggedMessage[] = [];
|
||||||
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
|
|
||||||
|
const repositoryProperties: RepositoryProperties = {
|
||||||
|
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||||
|
[RepositoryPropertyName.TOOLS_MODE]:
|
||||||
|
ToolsModeRepositoryPropertyValue.Dynamic,
|
||||||
|
};
|
||||||
|
const result = resolveToolsInput(
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
|
||||||
|
t.is(result, undefined);
|
||||||
|
t.is(loggedMessages.length, 1);
|
||||||
|
t.is(
|
||||||
|
loggedMessages[0].message,
|
||||||
|
"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);
|
||||||
|
});
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import {
|
||||||
|
RepositoryProperties,
|
||||||
|
RepositoryPropertyName,
|
||||||
|
ToolsModeRepositoryPropertyValue,
|
||||||
|
} 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,
|
||||||
|
* falls back to the repository property (if set). The optional
|
||||||
|
* `github-codeql-tools-mode` repository property controls whether this fallback
|
||||||
|
* applies to all workflows (`enforce`) or only dynamic workflows (`dynamic`).
|
||||||
|
*
|
||||||
|
* @param toolsWorkflowInput - The value of the `tools` workflow input, if provided.
|
||||||
|
* @param isDynamicWorkflow - Whether the current workflow is dynamic.
|
||||||
|
* @param repositoryProperties - The parsed repository properties.
|
||||||
|
* @param logger - Logger for outputting resolution messages.
|
||||||
|
* @returns The effective tools input value.
|
||||||
|
*/
|
||||||
|
export function resolveToolsInput(
|
||||||
|
toolsWorkflowInput: string | undefined,
|
||||||
|
isDynamicWorkflow: boolean,
|
||||||
|
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 {
|
||||||
|
effectiveToolsInput: toolsWorkflowInput,
|
||||||
|
effectiveToolsInputSource: EffectiveToolsInputSource.WorkflowInput,
|
||||||
|
toolsRepoPropertyMode: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const toolsPropertyValue = repositoryProperties[RepositoryPropertyName.TOOLS];
|
||||||
|
const toolsMode =
|
||||||
|
repositoryProperties[RepositoryPropertyName.TOOLS_MODE] ??
|
||||||
|
ToolsModeRepositoryPropertyValue.Enforce;
|
||||||
|
|
||||||
|
if (
|
||||||
|
toolsPropertyValue &&
|
||||||
|
toolsMode === ToolsModeRepositoryPropertyValue.Dynamic &&
|
||||||
|
!isDynamicWorkflow
|
||||||
|
) {
|
||||||
|
logger.info(
|
||||||
|
`Ignoring '${RepositoryPropertyName.TOOLS}' repository property because '${RepositoryPropertyName.TOOLS_MODE}' is set to '${toolsMode}' and this is not a dynamic workflow.`,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
effectiveToolsInput: undefined,
|
||||||
|
effectiveToolsInputSource: EffectiveToolsInputSource.None,
|
||||||
|
toolsRepoPropertyMode: toolsMode,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toolsPropertyValue) {
|
||||||
|
logger.info(
|
||||||
|
`Setting tools: ${toolsPropertyValue} based on the '${RepositoryPropertyName.TOOLS}' repository property (mode: '${toolsMode}').`,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
effectiveToolsInput: toolsPropertyValue,
|
||||||
|
effectiveToolsInputSource: EffectiveToolsInputSource.RepositoryProperty,
|
||||||
|
toolsRepoPropertyMode: toolsMode,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
effectiveToolsInput: undefined,
|
||||||
|
effectiveToolsInputSource: EffectiveToolsInputSource.None,
|
||||||
|
toolsRepoPropertyMode: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import { createStubCodeQL } from "./codeql";
|
|||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import { cleanupAndUploadDatabases } from "./database-upload";
|
import { cleanupAndUploadDatabases } from "./database-upload";
|
||||||
import * as gitUtils from "./git-utils";
|
import * as gitUtils from "./git-utils";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { RepositoryNwo } from "./repository";
|
import { RepositoryNwo } from "./repository";
|
||||||
import {
|
import {
|
||||||
checkExpectedLogMessages,
|
checkExpectedLogMessages,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { type CodeQL } from "./codeql";
|
|||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import * as json from "./json";
|
import * as json from "./json";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages/index";
|
||||||
import { Logger, withGroup } from "./logging";
|
import { Logger, withGroup } from "./logging";
|
||||||
import {
|
import {
|
||||||
isSafeArtifactUpload,
|
isSafeArtifactUpload,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import {
|
|||||||
CacheStoreResult,
|
CacheStoreResult,
|
||||||
} from "./dependency-caching";
|
} from "./dependency-caching";
|
||||||
import { Feature } from "./feature-flags";
|
import { Feature } from "./feature-flags";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import {
|
import {
|
||||||
setupTests,
|
setupTests,
|
||||||
createFeatures,
|
createFeatures,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { CodeQL } from "./codeql";
|
|||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
import { BuiltInLanguage, Language } from "./languages";
|
import { BuiltInLanguage, Language } from "./languages/index";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { getErrorMessage, getRequiredEnvParam } from "./util";
|
import { getErrorMessage, getRequiredEnvParam } from "./util";
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
import type { Config } from "./config-utils";
|
import type { Config } from "./config-utils";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages/index";
|
||||||
import { getActionsLogger } from "./logging";
|
import { getActionsLogger } from "./logging";
|
||||||
import { getCodeQLDatabasePath } from "./util";
|
import { getCodeQLDatabasePath } from "./util";
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ test.serial("loadPropertiesFromApi loads known properties", async (t) => {
|
|||||||
url: "",
|
url: "",
|
||||||
data: [
|
data: [
|
||||||
{ property_name: "github-codeql-extra-queries", value: "+queries" },
|
{ property_name: "github-codeql-extra-queries", value: "+queries" },
|
||||||
|
{ property_name: "github-codeql-tools", value: "toolcache" },
|
||||||
|
{ property_name: "github-codeql-tools-mode", value: "dynamic" },
|
||||||
{ property_name: "unknown-property", value: "something" },
|
{ property_name: "unknown-property", value: "something" },
|
||||||
] satisfies properties.GitHubPropertiesResponse,
|
] satisfies properties.GitHubPropertiesResponse,
|
||||||
});
|
});
|
||||||
@@ -87,9 +89,45 @@ test.serial("loadPropertiesFromApi loads known properties", async (t) => {
|
|||||||
logger,
|
logger,
|
||||||
mockRepositoryNwo,
|
mockRepositoryNwo,
|
||||||
);
|
);
|
||||||
t.deepEqual(response, { "github-codeql-extra-queries": "+queries" });
|
t.deepEqual(response, {
|
||||||
|
"github-codeql-extra-queries": "+queries",
|
||||||
|
"github-codeql-tools": "toolcache",
|
||||||
|
"github-codeql-tools-mode": "dynamic",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.serial(
|
||||||
|
"loadPropertiesFromApi warns if tools mode property has unexpected value",
|
||||||
|
async (t) => {
|
||||||
|
sinon.stub(api, "getRepositoryProperties").resolves({
|
||||||
|
headers: {},
|
||||||
|
status: 200,
|
||||||
|
url: "",
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
property_name: "github-codeql-tools-mode",
|
||||||
|
value: "all",
|
||||||
|
},
|
||||||
|
] satisfies properties.GitHubPropertiesResponse,
|
||||||
|
});
|
||||||
|
const logger = getRunnerLogger(true);
|
||||||
|
const warningSpy = sinon.spy(logger, "warning");
|
||||||
|
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||||
|
const response = await properties.loadPropertiesFromApi(
|
||||||
|
logger,
|
||||||
|
mockRepositoryNwo,
|
||||||
|
);
|
||||||
|
t.deepEqual(response, {
|
||||||
|
"github-codeql-tools-mode": "enforce",
|
||||||
|
});
|
||||||
|
t.true(warningSpy.calledOnce);
|
||||||
|
t.is(
|
||||||
|
warningSpy.firstCall.args[0],
|
||||||
|
"Repository property 'github-codeql-tools-mode' has unexpected value 'all'. Expected 'dynamic' or 'enforce'. Defaulting to 'enforce'.",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test.serial("loadPropertiesFromApi parses true boolean property", async (t) => {
|
test.serial("loadPropertiesFromApi parses true boolean property", async (t) => {
|
||||||
sinon.stub(api, "getRepositoryProperties").resolves({
|
sinon.stub(api, "getRepositoryProperties").resolves({
|
||||||
headers: {},
|
headers: {},
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import * as github from "@actions/github";
|
||||||
|
|
||||||
import { isDynamicWorkflow } from "../actions-util";
|
import { isDynamicWorkflow } from "../actions-util";
|
||||||
import { getRepositoryProperties } from "../api-client";
|
import { getRepositoryProperties } from "../api-client";
|
||||||
import { Logger } from "../logging";
|
import { Logger } from "../logging";
|
||||||
import { RepositoryNwo } from "../repository";
|
import { RepositoryNwo } from "../repository";
|
||||||
|
import { getErrorMessage, Result, Success, Failure } from "../util";
|
||||||
|
|
||||||
/** The common prefix that we expect all of our repository properties to have. */
|
/** The common prefix that we expect all of our repository properties to have. */
|
||||||
export const GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-";
|
export const GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-";
|
||||||
@@ -13,6 +16,13 @@ export enum RepositoryPropertyName {
|
|||||||
DISABLE_OVERLAY = "github-codeql-disable-overlay",
|
DISABLE_OVERLAY = "github-codeql-disable-overlay",
|
||||||
EXTRA_QUERIES = "github-codeql-extra-queries",
|
EXTRA_QUERIES = "github-codeql-extra-queries",
|
||||||
FILE_COVERAGE_ON_PRS = "github-codeql-file-coverage-on-prs",
|
FILE_COVERAGE_ON_PRS = "github-codeql-file-coverage-on-prs",
|
||||||
|
TOOLS = "github-codeql-tools",
|
||||||
|
TOOLS_MODE = "github-codeql-tools-mode",
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ToolsModeRepositoryPropertyValue {
|
||||||
|
Dynamic = "dynamic",
|
||||||
|
Enforce = "enforce",
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parsed types of the known repository properties. */
|
/** Parsed types of the known repository properties. */
|
||||||
@@ -20,6 +30,8 @@ export type AllRepositoryProperties = {
|
|||||||
[RepositoryPropertyName.DISABLE_OVERLAY]: boolean;
|
[RepositoryPropertyName.DISABLE_OVERLAY]: boolean;
|
||||||
[RepositoryPropertyName.EXTRA_QUERIES]: string;
|
[RepositoryPropertyName.EXTRA_QUERIES]: string;
|
||||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: boolean;
|
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: boolean;
|
||||||
|
[RepositoryPropertyName.TOOLS]: string;
|
||||||
|
[RepositoryPropertyName.TOOLS_MODE]: ToolsModeRepositoryPropertyValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Parsed repository properties. */
|
/** Parsed repository properties. */
|
||||||
@@ -30,6 +42,8 @@ export type RepositoryPropertyApiType = {
|
|||||||
[RepositoryPropertyName.DISABLE_OVERLAY]: string;
|
[RepositoryPropertyName.DISABLE_OVERLAY]: string;
|
||||||
[RepositoryPropertyName.EXTRA_QUERIES]: string;
|
[RepositoryPropertyName.EXTRA_QUERIES]: string;
|
||||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: string;
|
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: string;
|
||||||
|
[RepositoryPropertyName.TOOLS]: string;
|
||||||
|
[RepositoryPropertyName.TOOLS_MODE]: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The type of functions which take the `value` from the API and try to convert it to the type we want. */
|
/** The type of functions which take the `value` from the API and try to convert it to the type we want. */
|
||||||
@@ -77,6 +91,11 @@ const repositoryPropertyParsers: {
|
|||||||
[RepositoryPropertyName.DISABLE_OVERLAY]: booleanProperty,
|
[RepositoryPropertyName.DISABLE_OVERLAY]: booleanProperty,
|
||||||
[RepositoryPropertyName.EXTRA_QUERIES]: stringProperty,
|
[RepositoryPropertyName.EXTRA_QUERIES]: stringProperty,
|
||||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: booleanProperty,
|
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: booleanProperty,
|
||||||
|
[RepositoryPropertyName.TOOLS]: stringProperty,
|
||||||
|
[RepositoryPropertyName.TOOLS_MODE]: {
|
||||||
|
validate: isString,
|
||||||
|
parse: parseToolsModeRepositoryProperty,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,6 +191,38 @@ export async function loadPropertiesFromApi(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads [repository properties](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization) if applicable.
|
||||||
|
*/
|
||||||
|
export async function loadRepositoryProperties(
|
||||||
|
repositoryNwo: RepositoryNwo,
|
||||||
|
logger: Logger,
|
||||||
|
): Promise<Result<RepositoryProperties, unknown>> {
|
||||||
|
// See if we can skip loading repository properties early. In particular,
|
||||||
|
// repositories owned by users cannot have repository properties, so we can
|
||||||
|
// skip the API call entirely in that case.
|
||||||
|
const repositoryOwnerType = github.context.payload.repository?.owner.type;
|
||||||
|
logger.debug(
|
||||||
|
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`,
|
||||||
|
);
|
||||||
|
if (repositoryOwnerType === "User") {
|
||||||
|
logger.debug(
|
||||||
|
"Skipping loading repository properties because the repository is owned by a user and " +
|
||||||
|
"therefore cannot have repository properties.",
|
||||||
|
);
|
||||||
|
return new Success({});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
||||||
|
} catch (error) {
|
||||||
|
logger.info(
|
||||||
|
`Failed to load repository properties: ${getErrorMessage(error)}`,
|
||||||
|
);
|
||||||
|
return new Failure(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that `value` has the correct type for `K` and, if so, update the partial set of repository
|
* Validate that `value` has the correct type for `K` and, if so, update the partial set of repository
|
||||||
* properties with the parsed value of the specified property.
|
* properties with the parsed value of the specified property.
|
||||||
@@ -217,6 +268,25 @@ function parseStringRepositoryProperty(_name: string, value: string): string {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Parse the tools mode repository property. */
|
||||||
|
function parseToolsModeRepositoryProperty(
|
||||||
|
name: string,
|
||||||
|
value: string,
|
||||||
|
logger: Logger,
|
||||||
|
): ToolsModeRepositoryPropertyValue {
|
||||||
|
if (
|
||||||
|
value !== ToolsModeRepositoryPropertyValue.Dynamic &&
|
||||||
|
value !== ToolsModeRepositoryPropertyValue.Enforce
|
||||||
|
) {
|
||||||
|
logger.warning(
|
||||||
|
`Repository property '${name}' has unexpected value '${value}'. Expected 'dynamic' or 'enforce'. Defaulting to 'enforce'.`,
|
||||||
|
);
|
||||||
|
return ToolsModeRepositoryPropertyValue.Enforce;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/** Set of known repository property names, for fast lookups. */
|
/** Set of known repository property names, for fast lookups. */
|
||||||
const KNOWN_REPOSITORY_PROPERTY_NAMES = new Set<string>(
|
const KNOWN_REPOSITORY_PROPERTY_NAMES = new Set<string>(
|
||||||
Object.values(RepositoryPropertyName),
|
Object.values(RepositoryPropertyName),
|
||||||
|
|||||||
+41
-42
@@ -2,12 +2,12 @@ import * as fs from "fs";
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import * as github from "@actions/github";
|
|
||||||
import * as io from "@actions/io";
|
import * as io from "@actions/io";
|
||||||
import * as semver from "semver";
|
import * as semver from "semver";
|
||||||
import { v4 as uuidV4 } from "uuid";
|
import { v4 as uuidV4 } from "uuid";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
isDynamicWorkflow,
|
||||||
FileCmdNotFoundError,
|
FileCmdNotFoundError,
|
||||||
getActionVersion,
|
getActionVersion,
|
||||||
getFileType,
|
getFileType,
|
||||||
@@ -24,6 +24,10 @@ import {
|
|||||||
shouldRestoreCache,
|
shouldRestoreCache,
|
||||||
} from "./caching-utils";
|
} from "./caching-utils";
|
||||||
import { CodeQL } from "./codeql";
|
import { CodeQL } from "./codeql";
|
||||||
|
import {
|
||||||
|
EffectiveToolsInputSource,
|
||||||
|
resolveToolsInputWithMetadata,
|
||||||
|
} from "./config/resolve-tools-input";
|
||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
import {
|
import {
|
||||||
DependencyCacheRestoreStatusReport,
|
DependencyCacheRestoreStatusReport,
|
||||||
@@ -40,8 +44,8 @@ import {
|
|||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||||
import {
|
import {
|
||||||
loadPropertiesFromApi,
|
loadRepositoryProperties,
|
||||||
RepositoryProperties,
|
ToolsModeRepositoryPropertyValue,
|
||||||
} from "./feature-flags/properties";
|
} from "./feature-flags/properties";
|
||||||
import {
|
import {
|
||||||
checkInstallPython311,
|
checkInstallPython311,
|
||||||
@@ -53,14 +57,14 @@ import {
|
|||||||
initConfig,
|
initConfig,
|
||||||
runDatabaseInitCluster,
|
runDatabaseInitCluster,
|
||||||
} from "./init";
|
} from "./init";
|
||||||
import { JavaEnvVars, BuiltInLanguage } from "./languages";
|
import { JavaEnvVars, BuiltInLanguage } from "./languages/index";
|
||||||
import { getActionsLogger, Logger, withGroupAsync } from "./logging";
|
import { getActionsLogger, Logger, withGroupAsync } from "./logging";
|
||||||
import {
|
import {
|
||||||
downloadOverlayBaseDatabaseFromCache,
|
downloadOverlayBaseDatabaseFromCache,
|
||||||
OverlayBaseDatabaseDownloadStats,
|
OverlayBaseDatabaseDownloadStats,
|
||||||
} from "./overlay/caching";
|
} from "./overlay/caching";
|
||||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||||
import { getRepositoryNwo, RepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import { ToolsSource } from "./setup-codeql";
|
import { ToolsSource } from "./setup-codeql";
|
||||||
import {
|
import {
|
||||||
ActionName,
|
ActionName,
|
||||||
@@ -93,10 +97,7 @@ import {
|
|||||||
checkActionVersion,
|
checkActionVersion,
|
||||||
getErrorMessage,
|
getErrorMessage,
|
||||||
BuildMode,
|
BuildMode,
|
||||||
Result,
|
|
||||||
getOptionalEnvVar,
|
getOptionalEnvVar,
|
||||||
Success,
|
|
||||||
Failure,
|
|
||||||
} from "./util";
|
} from "./util";
|
||||||
import { checkWorkflow } from "./workflow";
|
import { checkWorkflow } from "./workflow";
|
||||||
|
|
||||||
@@ -140,6 +141,9 @@ async function sendCompletedStatusReport(
|
|||||||
toolsFeatureFlagsValid: boolean | undefined,
|
toolsFeatureFlagsValid: boolean | undefined,
|
||||||
toolsSource: ToolsSource,
|
toolsSource: ToolsSource,
|
||||||
toolsVersion: string,
|
toolsVersion: string,
|
||||||
|
effectiveToolsInput: string | undefined,
|
||||||
|
effectiveToolsInputSource: EffectiveToolsInputSource,
|
||||||
|
toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined,
|
||||||
overlayBaseDatabaseStats: OverlayBaseDatabaseDownloadStats | undefined,
|
overlayBaseDatabaseStats: OverlayBaseDatabaseDownloadStats | undefined,
|
||||||
dependencyCachingResults: DependencyCacheRestoreStatusReport | undefined,
|
dependencyCachingResults: DependencyCacheRestoreStatusReport | undefined,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
@@ -165,6 +169,9 @@ async function sendCompletedStatusReport(
|
|||||||
const initStatusReport: InitStatusReport = {
|
const initStatusReport: InitStatusReport = {
|
||||||
...statusReportBase,
|
...statusReportBase,
|
||||||
tools_input: getOptionalInput("tools") || "",
|
tools_input: getOptionalInput("tools") || "",
|
||||||
|
effective_tools_input: effectiveToolsInput || "",
|
||||||
|
effective_tools_input_source: effectiveToolsInputSource,
|
||||||
|
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||||
tools_resolved_version: toolsVersion,
|
tools_resolved_version: toolsVersion,
|
||||||
tools_source: toolsSource || ToolsSource.Unknown,
|
tools_source: toolsSource || ToolsSource.Unknown,
|
||||||
workflow_languages: workflowLanguages || "",
|
workflow_languages: workflowLanguages || "",
|
||||||
@@ -219,6 +226,9 @@ async function run(startedAt: Date) {
|
|||||||
let toolsSource: ToolsSource;
|
let toolsSource: ToolsSource;
|
||||||
let toolsVersion: string;
|
let toolsVersion: string;
|
||||||
let zstdAvailability: ZstdAvailability | undefined;
|
let zstdAvailability: ZstdAvailability | undefined;
|
||||||
|
let effectiveToolsInput: string | undefined;
|
||||||
|
let effectiveToolsInputSource: EffectiveToolsInputSource;
|
||||||
|
let toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
initializeEnvironment(getActionVersion());
|
initializeEnvironment(getActionVersion());
|
||||||
@@ -251,6 +261,7 @@ async function run(startedAt: Date) {
|
|||||||
repositoryNwo,
|
repositoryNwo,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
|
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||||
|
|
||||||
// Create a unique identifier for this run.
|
// Create a unique identifier for this run.
|
||||||
const jobRunUuid = uuidV4();
|
const jobRunUuid = uuidV4();
|
||||||
@@ -296,6 +307,21 @@ async function run(startedAt: Date) {
|
|||||||
const codeQLDefaultVersionInfo =
|
const codeQLDefaultVersionInfo =
|
||||||
await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||||
|
|
||||||
|
// Determine the effective tools input.
|
||||||
|
// The explicit `tools` workflow input takes precedence. If none is provided,
|
||||||
|
// 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.
|
||||||
|
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||||
|
getOptionalInput("tools"),
|
||||||
|
isDynamicWorkflow(),
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||||
|
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||||
|
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||||
const rawLanguages = configUtils.getRawLanguagesNoAutodetect(
|
const rawLanguages = configUtils.getRawLanguagesNoAutodetect(
|
||||||
getOptionalInput("languages"),
|
getOptionalInput("languages"),
|
||||||
);
|
);
|
||||||
@@ -303,7 +329,7 @@ async function run(startedAt: Date) {
|
|||||||
analysisKinds?.length === 1 &&
|
analysisKinds?.length === 1 &&
|
||||||
analysisKinds[0] === AnalysisKind.CodeScanning;
|
analysisKinds[0] === AnalysisKind.CodeScanning;
|
||||||
const initCodeQLResult = await initCodeQL(
|
const initCodeQLResult = await initCodeQL(
|
||||||
getOptionalInput("tools"),
|
effectiveToolsInput,
|
||||||
apiDetails,
|
apiDetails,
|
||||||
getTemporaryDirectory(),
|
getTemporaryDirectory(),
|
||||||
gitHubVersion.type,
|
gitHubVersion.type,
|
||||||
@@ -350,7 +376,6 @@ async function run(startedAt: Date) {
|
|||||||
|
|
||||||
analysisKinds = await getAnalysisKinds(logger, features);
|
analysisKinds = await getAnalysisKinds(logger, features);
|
||||||
const debugMode = getOptionalInput("debug") === "true" || core.isDebug();
|
const debugMode = getOptionalInput("debug") === "true" || core.isDebug();
|
||||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
|
||||||
const fileCoverageResult = await getFileCoverageInformationEnabled(
|
const fileCoverageResult = await getFileCoverageInformationEnabled(
|
||||||
debugMode,
|
debugMode,
|
||||||
codeql,
|
codeql,
|
||||||
@@ -774,6 +799,9 @@ async function run(startedAt: Date) {
|
|||||||
toolsFeatureFlagsValid,
|
toolsFeatureFlagsValid,
|
||||||
toolsSource,
|
toolsSource,
|
||||||
toolsVersion,
|
toolsVersion,
|
||||||
|
effectiveToolsInput,
|
||||||
|
effectiveToolsInputSource,
|
||||||
|
toolsRepoPropertyMode,
|
||||||
overlayBaseDatabaseStats,
|
overlayBaseDatabaseStats,
|
||||||
dependencyCachingStatus,
|
dependencyCachingStatus,
|
||||||
logger,
|
logger,
|
||||||
@@ -791,44 +819,15 @@ async function run(startedAt: Date) {
|
|||||||
toolsFeatureFlagsValid,
|
toolsFeatureFlagsValid,
|
||||||
toolsSource,
|
toolsSource,
|
||||||
toolsVersion,
|
toolsVersion,
|
||||||
|
effectiveToolsInput,
|
||||||
|
effectiveToolsInputSource,
|
||||||
|
toolsRepoPropertyMode,
|
||||||
overlayBaseDatabaseStats,
|
overlayBaseDatabaseStats,
|
||||||
dependencyCachingStatus,
|
dependencyCachingStatus,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads [repository properties](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization) if applicable.
|
|
||||||
*/
|
|
||||||
async function loadRepositoryProperties(
|
|
||||||
repositoryNwo: RepositoryNwo,
|
|
||||||
logger: Logger,
|
|
||||||
): Promise<Result<RepositoryProperties, unknown>> {
|
|
||||||
// See if we can skip loading repository properties early. In particular,
|
|
||||||
// repositories owned by users cannot have repository properties, so we can
|
|
||||||
// skip the API call entirely in that case.
|
|
||||||
const repositoryOwnerType = github.context.payload.repository?.owner.type;
|
|
||||||
logger.debug(
|
|
||||||
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`,
|
|
||||||
);
|
|
||||||
if (repositoryOwnerType === "User") {
|
|
||||||
logger.debug(
|
|
||||||
"Skipping loading repository properties because the repository is owned by a user and " +
|
|
||||||
"therefore cannot have repository properties.",
|
|
||||||
);
|
|
||||||
return new Success({});
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
|
||||||
} catch (error) {
|
|
||||||
logger.warning(
|
|
||||||
`Failed to load repository properties: ${getErrorMessage(error)}`,
|
|
||||||
);
|
|
||||||
return new Failure(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function recordZstdAvailability(
|
async function recordZstdAvailability(
|
||||||
config: configUtils.Config,
|
config: configUtils.Config,
|
||||||
zstdAvailability: ZstdAvailability,
|
zstdAvailability: ZstdAvailability,
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import {
|
|||||||
getFileCoverageInformationEnabled,
|
getFileCoverageInformationEnabled,
|
||||||
logFileCoverageOnPrsDeprecationWarning,
|
logFileCoverageOnPrsDeprecationWarning,
|
||||||
} from "./init";
|
} from "./init";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import {
|
import {
|
||||||
createFeatures,
|
createFeatures,
|
||||||
LoggedMessage,
|
LoggedMessage,
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ import {
|
|||||||
RepositoryProperties,
|
RepositoryProperties,
|
||||||
RepositoryPropertyName,
|
RepositoryPropertyName,
|
||||||
} from "./feature-flags/properties";
|
} from "./feature-flags/properties";
|
||||||
import { BuiltInLanguage, Language } from "./languages";
|
import { BuiltInLanguage, Language } from "./languages/index";
|
||||||
import { Logger, withGroupAsync } from "./logging";
|
import { Logger, withGroupAsync } from "./logging";
|
||||||
import { ToolsSource } from "./setup-codeql";
|
import { ToolsSource } from "./setup-codeql";
|
||||||
import { ZstdAvailability } from "./tar";
|
import { ZstdAvailability } from "./tar";
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as core from "@actions/core";
|
|||||||
import { v4 as uuidV4 } from "uuid";
|
import { v4 as uuidV4 } from "uuid";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
isDynamicWorkflow,
|
||||||
getActionVersion,
|
getActionVersion,
|
||||||
getOptionalInput,
|
getOptionalInput,
|
||||||
getRequiredInput,
|
getRequiredInput,
|
||||||
@@ -10,9 +11,17 @@ import {
|
|||||||
import { AnalysisKind, getAnalysisKinds } from "./analyses";
|
import { AnalysisKind, getAnalysisKinds } from "./analyses";
|
||||||
import { getGitHubVersion } from "./api-client";
|
import { getGitHubVersion } from "./api-client";
|
||||||
import { CodeQL } from "./codeql";
|
import { CodeQL } from "./codeql";
|
||||||
|
import {
|
||||||
|
EffectiveToolsInputSource,
|
||||||
|
resolveToolsInputWithMetadata,
|
||||||
|
} from "./config/resolve-tools-input";
|
||||||
import { getRawLanguagesNoAutodetect } from "./config-utils";
|
import { getRawLanguagesNoAutodetect } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { initFeatures } from "./feature-flags";
|
import { initFeatures } from "./feature-flags";
|
||||||
|
import {
|
||||||
|
loadRepositoryProperties,
|
||||||
|
ToolsModeRepositoryPropertyValue,
|
||||||
|
} from "./feature-flags/properties";
|
||||||
import { initCodeQL } from "./init";
|
import { initCodeQL } from "./init";
|
||||||
import { getActionsLogger, Logger } from "./logging";
|
import { getActionsLogger, Logger } from "./logging";
|
||||||
import { getRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
@@ -48,6 +57,9 @@ async function sendCompletedStatusReport(
|
|||||||
toolsFeatureFlagsValid: boolean | undefined,
|
toolsFeatureFlagsValid: boolean | undefined,
|
||||||
toolsSource: ToolsSource,
|
toolsSource: ToolsSource,
|
||||||
toolsVersion: string,
|
toolsVersion: string,
|
||||||
|
effectiveToolsInput: string | undefined,
|
||||||
|
effectiveToolsInputSource: EffectiveToolsInputSource,
|
||||||
|
toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
error?: Error,
|
error?: Error,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
@@ -69,6 +81,9 @@ async function sendCompletedStatusReport(
|
|||||||
const initStatusReport: InitStatusReport = {
|
const initStatusReport: InitStatusReport = {
|
||||||
...statusReportBase,
|
...statusReportBase,
|
||||||
tools_input: getOptionalInput("tools") || "",
|
tools_input: getOptionalInput("tools") || "",
|
||||||
|
effective_tools_input: effectiveToolsInput || "",
|
||||||
|
effective_tools_input_source: effectiveToolsInputSource,
|
||||||
|
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||||
tools_resolved_version: toolsVersion,
|
tools_resolved_version: toolsVersion,
|
||||||
tools_source: toolsSource || ToolsSource.Unknown,
|
tools_source: toolsSource || ToolsSource.Unknown,
|
||||||
workflow_languages: "",
|
workflow_languages: "",
|
||||||
@@ -99,6 +114,9 @@ async function run(startedAt: Date): Promise<void> {
|
|||||||
let toolsFeatureFlagsValid: boolean | undefined;
|
let toolsFeatureFlagsValid: boolean | undefined;
|
||||||
let toolsSource: ToolsSource;
|
let toolsSource: ToolsSource;
|
||||||
let toolsVersion: string;
|
let toolsVersion: string;
|
||||||
|
let effectiveToolsInput: string | undefined;
|
||||||
|
let effectiveToolsInputSource: EffectiveToolsInputSource;
|
||||||
|
let toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
initializeEnvironment(getActionVersion());
|
initializeEnvironment(getActionVersion());
|
||||||
@@ -141,12 +159,35 @@ async function run(startedAt: Date): Promise<void> {
|
|||||||
const codeQLDefaultVersionInfo =
|
const codeQLDefaultVersionInfo =
|
||||||
await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||||
|
|
||||||
|
// Fetch the values of known repository properties that affect us.
|
||||||
|
const repositoryPropertiesResult = await loadRepositoryProperties(
|
||||||
|
repositoryNwo,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||||
|
|
||||||
|
// Determine the effective tools input.
|
||||||
|
// The explicit `tools` workflow input takes precedence. If none is provided,
|
||||||
|
// 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.
|
||||||
|
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||||
|
getOptionalInput("tools"),
|
||||||
|
isDynamicWorkflow(),
|
||||||
|
repositoryProperties,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
|
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||||
|
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||||
|
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||||
getOptionalInput("languages"),
|
getOptionalInput("languages"),
|
||||||
);
|
);
|
||||||
const analysisKinds = await getAnalysisKinds(logger, features);
|
const analysisKinds = await getAnalysisKinds(logger, features);
|
||||||
|
|
||||||
const initCodeQLResult = await initCodeQL(
|
const initCodeQLResult = await initCodeQL(
|
||||||
getOptionalInput("tools"),
|
effectiveToolsInput,
|
||||||
apiDetails,
|
apiDetails,
|
||||||
getTemporaryDirectory(),
|
getTemporaryDirectory(),
|
||||||
gitHubVersion.type,
|
gitHubVersion.type,
|
||||||
@@ -191,6 +232,9 @@ async function run(startedAt: Date): Promise<void> {
|
|||||||
toolsFeatureFlagsValid,
|
toolsFeatureFlagsValid,
|
||||||
toolsSource,
|
toolsSource,
|
||||||
toolsVersion,
|
toolsVersion,
|
||||||
|
effectiveToolsInput,
|
||||||
|
effectiveToolsInputSource,
|
||||||
|
toolsRepoPropertyMode,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -559,7 +559,7 @@ export async function getCodeQLSource(
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (allowToolcacheValueFF) {
|
if (allowToolcacheValueFF) {
|
||||||
logger.warning(
|
logger.info(
|
||||||
`Ignoring 'tools: ${toolsInput}' because the workflow was not triggered dynamically.`,
|
`Ignoring 'tools: ${toolsInput}' because the workflow was not triggered dynamically.`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import * as core from "@actions/core";
|
|||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
import { getGitHubVersion } from "./api-client";
|
import { getGitHubVersion } from "./api-client";
|
||||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||||
import { BuiltInLanguage, parseBuiltInLanguage } from "./languages";
|
import { BuiltInLanguage, parseBuiltInLanguage } from "./languages/index";
|
||||||
import { getActionsLogger, Logger } from "./logging";
|
import { getActionsLogger, Logger } from "./logging";
|
||||||
import { getRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import * as defaults from "./defaults.json";
|
|||||||
import { setUpFeatureFlagTests } from "./feature-flags/testing-util";
|
import { setUpFeatureFlagTests } from "./feature-flags/testing-util";
|
||||||
import { UnvalidatedObject, validateSchema } from "./json";
|
import { UnvalidatedObject, validateSchema } from "./json";
|
||||||
import { makeFromSchema } from "./json/testing-util";
|
import { makeFromSchema } from "./json/testing-util";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { getRunnerLogger, Logger } from "./logging";
|
import { getRunnerLogger, Logger } from "./logging";
|
||||||
import * as startProxyExports from "./start-proxy";
|
import * as startProxyExports from "./start-proxy";
|
||||||
import * as statusReport from "./status-report";
|
import * as statusReport from "./status-report";
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ import {
|
|||||||
FeatureEnablement,
|
FeatureEnablement,
|
||||||
} from "./feature-flags";
|
} from "./feature-flags";
|
||||||
import * as json from "./json";
|
import * as json from "./json";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import {
|
import {
|
||||||
Address,
|
Address,
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ import test from "ava";
|
|||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
|
import { EffectiveToolsInputSource } from "./config/resolve-tools-input";
|
||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import { ToolsSource } from "./setup-codeql";
|
import { ToolsSource } from "./setup-codeql";
|
||||||
import {
|
import {
|
||||||
@@ -316,6 +317,9 @@ const testCreateInitWithConfigStatusReport = makeMacro({
|
|||||||
const initStatusReport: InitStatusReport = {
|
const initStatusReport: InitStatusReport = {
|
||||||
...statusReportBase,
|
...statusReportBase,
|
||||||
tools_input: "",
|
tools_input: "",
|
||||||
|
effective_tools_input: "",
|
||||||
|
effective_tools_input_source: EffectiveToolsInputSource.None,
|
||||||
|
tools_repo_property_mode: "",
|
||||||
tools_resolved_version: "foo",
|
tools_resolved_version: "foo",
|
||||||
tools_source: ToolsSource.Unknown,
|
tools_source: ToolsSource.Unknown,
|
||||||
workflow_languages: "actions",
|
workflow_languages: "actions",
|
||||||
@@ -347,6 +351,8 @@ testCreateInitWithConfigStatusReport.serial(
|
|||||||
languages: [BuiltInLanguage.java, BuiltInLanguage.swift],
|
languages: [BuiltInLanguage.java, BuiltInLanguage.swift],
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
effective_tools_input_source: EffectiveToolsInputSource.None,
|
||||||
|
tools_repo_property_mode: "",
|
||||||
trap_cache_download_size_bytes: 1024,
|
trap_cache_download_size_bytes: 1024,
|
||||||
registries: "[]",
|
registries: "[]",
|
||||||
query_filters: "[]",
|
query_filters: "[]",
|
||||||
@@ -354,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(
|
testCreateInitWithConfigStatusReport.serial(
|
||||||
"includes packs for a single language",
|
"includes packs for a single language",
|
||||||
createTestConfig({
|
createTestConfig({
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
isSelfHostedRunner,
|
isSelfHostedRunner,
|
||||||
} from "./actions-util";
|
} from "./actions-util";
|
||||||
import { getAnalysisKey, getApiClient } from "./api-client";
|
import { getAnalysisKey, getApiClient } from "./api-client";
|
||||||
|
import { EffectiveToolsInputSource } from "./config/resolve-tools-input";
|
||||||
import { parseRegistriesWithoutCredentials, type Config } from "./config-utils";
|
import { parseRegistriesWithoutCredentials, type Config } from "./config-utils";
|
||||||
import { DependencyCacheRestoreStatusReport } from "./dependency-caching";
|
import { DependencyCacheRestoreStatusReport } from "./dependency-caching";
|
||||||
import { DocUrl } from "./doc-url";
|
import { DocUrl } from "./doc-url";
|
||||||
@@ -482,6 +483,12 @@ export async function sendStatusReport<S extends StatusReportBase>(
|
|||||||
export interface InitStatusReport extends StatusReportBase {
|
export interface InitStatusReport extends StatusReportBase {
|
||||||
/** Value given by the user as the "tools" input. */
|
/** Value given by the user as the "tools" input. */
|
||||||
tools_input: string;
|
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. */
|
/** Version of the bundle used. */
|
||||||
tools_resolved_version: string;
|
tools_resolved_version: string;
|
||||||
/** Where the bundle originated from. */
|
/** Where the bundle originated from. */
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import * as sinon from "sinon";
|
|||||||
|
|
||||||
import { CodeQL, getCodeQLForTesting } from "./codeql";
|
import { CodeQL, getCodeQLForTesting } from "./codeql";
|
||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { createTestConfig, makeVersionInfo, setupTests } from "./testing-utils";
|
import { createTestConfig, makeVersionInfo, setupTests } from "./testing-utils";
|
||||||
import { ToolsFeature } from "./tools-features";
|
import { ToolsFeature } from "./tools-features";
|
||||||
import { getCombinedTracerConfig } from "./tracer-config";
|
import { getCombinedTracerConfig } from "./tracer-config";
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
import { Feature } from "./feature-flags";
|
import { Feature } from "./feature-flags";
|
||||||
import * as gitUtils from "./git-utils";
|
import * as gitUtils from "./git-utils";
|
||||||
import { BuiltInLanguage } from "./languages";
|
import { BuiltInLanguage } from "./languages/index";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import {
|
import {
|
||||||
createFeatures,
|
createFeatures,
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import { type Config } from "./config-utils";
|
|||||||
import { DocUrl } from "./doc-url";
|
import { DocUrl } from "./doc-url";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
import * as gitUtils from "./git-utils";
|
import * as gitUtils from "./git-utils";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages/index";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import {
|
import {
|
||||||
asHTTPError,
|
asHTTPError,
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import type { Pack } from "./config/db-config";
|
|||||||
import type { Config } from "./config-utils";
|
import type { Config } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import * as json from "./json";
|
import * as json from "./json";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages/index";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user