Skip to content

Commit 7554332

Browse files
committed
Recommend using default setup or matrixing languages
1 parent 15bce5b commit 7554332

File tree

9 files changed

+42
-3
lines changed

9 files changed

+42
-3
lines changed

lib/config-utils.js

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

lib/config-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/doc-url.js

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

lib/doc-url.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/environment.js

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

lib/environment.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import * as api from "./api-client";
99
import { CachingKind, getCachingKind } from "./caching-utils";
1010
import { CodeQL } from "./codeql";
1111
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
12+
import { DocUrl } from "./doc-url";
13+
import { EnvVar } from "./environment";
1214
import { Feature, FeatureEnablement } from "./feature-flags";
1315
import { Language, parseLanguage } from "./languages";
1416
import { Logger } from "./logging";
@@ -389,6 +391,22 @@ export async function getRawLanguages(
389391
.split(",")
390392
.map((x) => x.trim().toLowerCase())
391393
.filter((x) => x.length > 0);
394+
395+
if (
396+
rawLanguages.length > 1 &&
397+
process.env[EnvVar.SUPPRESS_SINGLE_LANGUAGE_PER_JOB_RECOMMENDATION] !==
398+
"true"
399+
) {
400+
logger.warning(
401+
"For the best experience, we recommend analyzing each language within its own Actions job. " +
402+
"If you do not need a highly customizable code scanning configuration, consider using default setup for code scanning. " +
403+
"Otherwise, consider using a matrix to analyze each language in its own job. " +
404+
// Space before period to avoid issues copying links
405+
`For more information, see ${DocUrl.CONFIGURE_DEFAULT_SETUP} and ${DocUrl.ACTIONS_MATRIX} . ` +
406+
`To suppress this warning, set the environment variable ${EnvVar.SUPPRESS_SINGLE_LANGUAGE_PER_JOB_RECOMMENDATION} to "true".`,
407+
);
408+
}
409+
392410
let autodetected: boolean;
393411
if (rawLanguages.length) {
394412
autodetected = false;

src/doc-url.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
*/
44

55
export enum DocUrl {
6+
ACTIONS_MATRIX = "https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow",
67
ASSIGNING_PERMISSIONS_TO_JOBS = "https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs",
78
AUTOMATIC_BUILD_FAILED = "https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed",
9+
CONFIGURE_DEFAULT_SETUP = "https://docs.github.com/en/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning",
810
DEFINE_ENV_VARIABLES = "https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow",
911
SCANNING_ON_PUSH = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push",
1012
SPECIFY_BUILD_STEPS_MANUALLY = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#about-specifying-build-steps-manually",

src/environment.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ export enum EnvVar {
7979
/** Whether to suppress the warning if the current CLI will soon be unsupported. */
8080
SUPPRESS_DEPRECATED_SOON_WARNING = "CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING",
8181

82+
/** Whether to suppress the recommendation for analyzing a single language per job. */
83+
SUPPRESS_SINGLE_LANGUAGE_PER_JOB_RECOMMENDATION = "CODEQL_ACTION_SUPPRESS_SINGLE_LANGUAGE_PER_JOB_RECOMMENDATION",
84+
8285
/** Whether to disable uploading SARIF results or status reports to the GitHub API */
8386
TEST_MODE = "CODEQL_ACTION_TEST_MODE",
8487

0 commit comments

Comments
 (0)