Skip to content

Commit feafcfe

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

File tree

9 files changed

+44
-3
lines changed

9 files changed

+44
-3
lines changed

lib/config-utils.js

Lines changed: 13 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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import * as fs from "fs";
22
import * as path from "path";
33
import { performance } from "perf_hooks";
44

5+
import * as core from "@actions/core";
56
import * as yaml from "js-yaml";
67
import * as semver from "semver";
78

89
import * as api from "./api-client";
910
import { CachingKind, getCachingKind } from "./caching-utils";
1011
import { CodeQL } from "./codeql";
1112
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
13+
import { DocUrl } from "./doc-url";
14+
import { EnvVar } from "./environment";
1215
import { Feature, FeatureEnablement } from "./feature-flags";
1316
import { Language, parseLanguage } from "./languages";
1417
import { Logger } from "./logging";
@@ -389,6 +392,22 @@ export async function getRawLanguages(
389392
.split(",")
390393
.map((x) => x.trim().toLowerCase())
391394
.filter((x) => x.length > 0);
395+
396+
if (
397+
rawLanguages.length > 1 &&
398+
process.env[EnvVar.SUPPRESS_SINGLE_LANGUAGE_PER_JOB_RECOMMENDATION] !==
399+
"true"
400+
) {
401+
core.notice(
402+
"When creating a new setup of CodeQL, we recommend analyzing each language within its own Actions job for the best experience. " +
403+
"If you do not need a highly customizable code scanning configuration, consider using default setup for code scanning. " +
404+
"Otherwise, consider using a matrix to analyze each language in its own job. " +
405+
// Space before period to avoid issues copying links
406+
`For more information, see ${DocUrl.CONFIGURE_DEFAULT_SETUP} and ${DocUrl.ACTIONS_MATRIX} . ` +
407+
`To suppress this recommendation, set the environment variable ${EnvVar.SUPPRESS_SINGLE_LANGUAGE_PER_JOB_RECOMMENDATION} to "true".`,
408+
);
409+
}
410+
392411
let autodetected: boolean;
393412
if (rawLanguages.length) {
394413
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)