Skip to content

Commit

Permalink
Remove feature flag for analysis summary v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Oct 25, 2023
1 parent edb8265 commit 2cbabea
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 49 deletions.
2 changes: 1 addition & 1 deletion lib/analyze.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze.js.map

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

28 changes: 22 additions & 6 deletions lib/codeql.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.test.js.map

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions lib/feature-flags.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/feature-flags.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import del from "del";
import * as yaml from "js-yaml";

import * as analysisPaths from "./analysis-paths";
import { CodeQL, getCodeQL } from "./codeql";
import {
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
CodeQL,
getCodeQL,
} from "./codeql";
import * as configUtils from "./config-utils";
import {
FeatureEnablement,
Expand Down Expand Up @@ -389,7 +393,10 @@ export async function runQueries(
}

if (
!(await features.getValue(Feature.AnalysisSummaryV2Enabled, codeql))
!(await util.codeQlVersionAbove(
codeql,
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
))
) {
await runPrintLinesOfCode(language);
}
Expand Down
34 changes: 25 additions & 9 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1005,29 +1005,45 @@ test("databaseInterpretResults() does not set --sarif-add-baseline-file-info for

const NEW_ANALYSIS_SUMMARY_TEST_CASES = [
{
featureEnabled: true,
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
flagPassed: true,
negativeFlagPassed: false,
},
{
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.GHES,
version: "3.9.0",
},
flagPassed: true,
negativeFlagPassed: false,
},
{
featureEnabled: false,
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.GHES,
version: "3.8.6",
},
flagPassed: false,
negativeFlagPassed: true,
},
{
featureEnabled: false,
codeqlVersion: "2.14.6",
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
flagPassed: false,
negativeFlagPassed: false,
},
];

for (const {
featureEnabled,
codeqlVersion,
flagPassed,
githubVersion,
negativeFlagPassed,
} of NEW_ANALYSIS_SUMMARY_TEST_CASES) {
test(`database interpret-results passes ${
Expand All @@ -1036,9 +1052,9 @@ for (const {
: negativeFlagPassed
? "--no-new-analysis-summary"
: "nothing"
} for CodeQL CLI v${codeqlVersion} when the new analysis summary feature is ${
featureEnabled ? "enabled" : "disabled"
}`, async (t) => {
} for CodeQL CLI v${codeqlVersion} and ${
util.GitHubVariant[githubVersion.type]
} ${githubVersion.version ? ` ${githubVersion.version}` : ""}`, async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon
Expand All @@ -1054,8 +1070,8 @@ for (const {
"",
"-v",
"",
stubConfig,
createFeatures(featureEnabled ? [Feature.AnalysisSummaryV2Enabled] : []),
Object.assign({}, stubConfig, { gitHubVersion: githubVersion }),
createFeatures([]),
getRunnerLogger(true),
);
t.is(
Expand Down
18 changes: 16 additions & 2 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as path from "path";
import * as core from "@actions/core";
import * as toolrunner from "@actions/exec/lib/toolrunner";
import * as yaml from "js-yaml";
import * as semver from "semver";

import {
getActionVersion,
Expand All @@ -15,7 +16,6 @@ import type { Config } from "./config-utils";
import { EnvVar } from "./environment";
import {
CODEQL_VERSION_INTRA_LAYER_PARALLELISM,
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
CodeQLDefaultVersionInfo,
Feature,
FeatureEnablement,
Expand Down Expand Up @@ -362,6 +362,11 @@ export const CODEQL_VERSION_LANGUAGE_BASELINE_CONFIG = "2.14.2";
*/
export const CODEQL_VERSION_LANGUAGE_ALIASING = "2.14.4";

/**
* Versions 2.15.0+ of the CodeQL CLI support new analysis summaries.
*/
export const CODEQL_VERSION_ANALYSIS_SUMMARY_V2 = "2.15.0";

/**
* Set up CodeQL CLI access.
*
Expand Down Expand Up @@ -925,7 +930,16 @@ export async function getCodeQLForCmd(
} else if (await util.codeQlVersionAbove(this, "2.12.4")) {
codeqlArgs.push("--no-sarif-include-diagnostics");
}
if (await features.getValue(Feature.AnalysisSummaryV2Enabled, this)) {
if (
// Analysis summary v2 links to the status page, so check the GHES version we're running on
// supports the status page.
(config.gitHubVersion.type !== util.GitHubVariant.GHES ||
semver.gte(config.gitHubVersion.version, "3.9.0")) &&
(await util.codeQlVersionAbove(
this,
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
))
) {
codeqlArgs.push("--new-analysis-summary");
} else if (
await util.codeQlVersionAbove(this, CODEQL_VERSION_ANALYSIS_SUMMARY_V2)
Expand Down
11 changes: 0 additions & 11 deletions src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export const CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = "2.13.4";
*/
export const CODEQL_VERSION_INTRA_LAYER_PARALLELISM = "2.14.6";

/**
* Versions 2.15.0+ of the CodeQL CLI support new analysis summaries.
*/
export const CODEQL_VERSION_ANALYSIS_SUMMARY_V2 = "2.15.0";

/**
* Versions 2.15.0+ of the CodeQL CLI support sub-language file coverage information.
*/
Expand All @@ -54,7 +49,6 @@ export interface FeatureEnablement {
* Each value of this enum should end with `_enabled`.
*/
export enum Feature {
AnalysisSummaryV2Enabled = "analysis_summary_v2_enabled",
CliConfigFileEnabled = "cli_config_file_enabled",
CodeqlJavaLombokEnabled = "codeql_java_lombok_enabled",
CppDependencyInstallation = "cpp_dependency_installation_enabled",
Expand All @@ -71,11 +65,6 @@ export const featureConfig: Record<
Feature,
{ envVar: string; minimumVersion: string | undefined; defaultValue: boolean }
> = {
[Feature.AnalysisSummaryV2Enabled]: {
envVar: "CODEQL_ACTION_ANALYSIS_SUMMARY_V2",
minimumVersion: CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
defaultValue: false,
},
[Feature.CodeqlJavaLombokEnabled]: {
envVar: "CODEQL_JAVA_LOMBOK",
minimumVersion: "2.14.0",
Expand Down

0 comments on commit 2cbabea

Please sign in to comment.