From 127851b3990661ebf44282b5f297622c88ecac3f Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Mon, 27 Oct 2025 15:42:43 +0000 Subject: [PATCH] Add environment variable for skipping workflow validation --- lib/init-action.js | 20 +++++++++++--------- src/environment.ts | 6 ++++++ src/init-action.ts | 21 ++++++++++++--------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/lib/init-action.js b/lib/init-action.js index 202465611..f5a537666 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -92345,16 +92345,18 @@ async function run() { toolsVersion = initCodeQLResult.toolsVersion; toolsSource = initCodeQLResult.toolsSource; zstdAvailability = initCodeQLResult.zstdAvailability; - core13.startGroup("Validating workflow"); - const validateWorkflowResult = await validateWorkflow(codeql, logger); - if (validateWorkflowResult === void 0) { - logger.info("Detected no issues with the code scanning workflow."); - } else { - logger.warning( - `Unable to validate code scanning workflow: ${validateWorkflowResult}` - ); + if (process.env["CODEQL_ACTION_SKIP_WORKFLOW_VALIDATION" /* SKIP_WORKFLOW_VALIDATION */] !== "true") { + core13.startGroup("Validating workflow"); + const validateWorkflowResult = await validateWorkflow(codeql, logger); + if (validateWorkflowResult === void 0) { + logger.info("Detected no issues with the code scanning workflow."); + } else { + logger.warning( + `Unable to validate code scanning workflow: ${validateWorkflowResult}` + ); + } + core13.endGroup(); } - core13.endGroup(); if ( // Only enable the experimental features env variable for Rust analysis if the user has explicitly // requested rust - don't enable it via language autodetection. diff --git a/src/environment.ts b/src/environment.ts index 698664122..16a016aaa 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -137,4 +137,10 @@ export enum EnvVar { * This setting is more specific than `CODEQL_ACTION_TEST_MODE`, which implies this option. */ SKIP_SARIF_UPLOAD = "CODEQL_ACTION_SKIP_SARIF_UPLOAD", + + /** + * Whether to skip workflow validation. Intended for internal use, where we know that + * the workflow is valid and validation is not necessary. + */ + SKIP_WORKFLOW_VALIDATION = "CODEQL_ACTION_SKIP_WORKFLOW_VALIDATION", } diff --git a/src/init-action.ts b/src/init-action.ts index 8961b09f4..d10c6a81a 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -288,16 +288,19 @@ async function run() { toolsSource = initCodeQLResult.toolsSource; zstdAvailability = initCodeQLResult.zstdAvailability; - core.startGroup("Validating workflow"); - const validateWorkflowResult = await validateWorkflow(codeql, logger); - if (validateWorkflowResult === undefined) { - logger.info("Detected no issues with the code scanning workflow."); - } else { - logger.warning( - `Unable to validate code scanning workflow: ${validateWorkflowResult}`, - ); + // Check the workflow for problems, unless `SKIP_WORKFLOW_VALIDATION` is `true`. + if (process.env[EnvVar.SKIP_WORKFLOW_VALIDATION] !== "true") { + core.startGroup("Validating workflow"); + const validateWorkflowResult = await validateWorkflow(codeql, logger); + if (validateWorkflowResult === undefined) { + logger.info("Detected no issues with the code scanning workflow."); + } else { + logger.warning( + `Unable to validate code scanning workflow: ${validateWorkflowResult}`, + ); + } + core.endGroup(); } - core.endGroup(); // Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for Rust if between 2.19.3 (included) and 2.22.1 (excluded) // We need to set this environment variable before initializing the config, otherwise Rust