Merge pull request #3502 from github/mbg/remove-ccr

Remove all CCR-specific code and tests
This commit is contained in:
Michael B. Gale
2026-02-24 10:58:49 +00:00
committed by GitHub
18 changed files with 23 additions and 229 deletions

View File

@@ -23,13 +23,13 @@ For internal use only. Please select the risk level of this change:
Workflow types:
- **Advanced setup** - Impacts users who have custom CodeQL workflows.
- **Managed** - Impacts users with `dynamic` workflows (Default Setup, CCR, ...).
- **Managed** - Impacts users with `dynamic` workflows (Default Setup, Code Quality, ...).
Products:
- **Code Scanning** - The changes impact analyses when `analysis-kinds: code-scanning`.
- **Code Quality** - The changes impact analyses when `analysis-kinds: code-quality`.
- **CCR** - The changes impact analyses for Copilot Code Reviews.
- **Other first-party** - The changes impact other first-party analyses.
- **Third-party analyses** - The changes affect the `upload-sarif` action.
Environments:
@@ -54,6 +54,7 @@ Environments:
- **Feature flags** - All new or changed code paths can be fully disabled with corresponding feature flags.
- **Rollback** - Change can only be disabled by rolling back the release or releasing a new version with a fix.
- **Development/testing only** - This change cannot cause any failures in production.
- **Other** - Please provide details.
#### How will you know if something goes wrong after this change is released?

87
.github/workflows/__ccr.yml generated vendored
View File

@@ -1,87 +0,0 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pr-checks/sync.sh
# to regenerate this file.
name: PR Check - CCR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO111MODULE: auto
on:
push:
branches:
- main
- releases/v*
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
inputs: {}
workflow_call:
inputs: {}
defaults:
run:
shell: bash
concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
group: ccr-${{github.ref}}
jobs:
ccr:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
version: stable-v2.17.6
- os: ubuntu-latest
version: stable-v2.18.4
- os: ubuntu-latest
version: stable-v2.19.4
- os: ubuntu-latest
version: stable-v2.20.7
- os: ubuntu-latest
version: stable-v2.21.4
- os: ubuntu-latest
version: stable-v2.22.4
- os: ubuntu-latest
version: default
- os: ubuntu-latest
version: linked
- os: ubuntu-latest
version: nightly-latest
name: CCR
if: github.triggering_actor != 'dependabot[bot]'
permissions:
contents: read
security-events: read
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Prepare test
id: prepare-test
uses: ./.github/actions/prepare-test
with:
version: ${{ matrix.version }}
use-all-platform-bundle: 'false'
setup-kotlin: 'true'
- uses: ./../action/init
id: init
with:
languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }}
- uses: ./../action/analyze
id: analysis
with:
upload-database: false
env:
CODEQL_ACTION_ANALYSIS_KEY: dynamic/copilot-pull-request-reviewer/codeql-action-test
CODEQL_ACTION_TEST_MODE: true

11
lib/analyze-action.js generated
View File

@@ -106382,11 +106382,7 @@ function isDynamicWorkflow() {
return getWorkflowEventName() === "dynamic";
}
function isDefaultSetup() {
return isDynamicWorkflow() && !isCCR();
}
var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
function isCCR() {
return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false;
return isDynamicWorkflow();
}
function prettyPrintInvocation(cmd, args) {
return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" ");
@@ -108192,11 +108188,6 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
"Not running against github.com. Using default values for all features."
);
return new OfflineFeatures(logger);
} else if (isCCR()) {
logger.debug(
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features."
);
return new OfflineFeatures(logger);
} else {
return new Features(repositoryNwo, tempDir, logger);
}

View File

@@ -103148,10 +103148,6 @@ function getWorkflowRunAttempt() {
function isSelfHostedRunner() {
return process.env.RUNNER_ENVIRONMENT === "self-hosted";
}
var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
function isCCR() {
return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false;
}
function prettyPrintInvocation(cmd, args) {
return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" ");
}
@@ -104482,11 +104478,6 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
"Not running against github.com. Using default values for all features."
);
return new OfflineFeatures(logger);
} else if (isCCR()) {
logger.debug(
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features."
);
return new OfflineFeatures(logger);
} else {
return new Features(repositoryNwo, tempDir, logger);
}

View File

@@ -163954,11 +163954,7 @@ function isDynamicWorkflow() {
return getWorkflowEventName() === "dynamic";
}
function isDefaultSetup() {
return isDynamicWorkflow() && !isCCR();
}
var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
function isCCR() {
return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false;
return isDynamicWorkflow();
}
function prettyPrintInvocation(cmd, args) {
return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" ");
@@ -165559,11 +165555,6 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
"Not running against github.com. Using default values for all features."
);
return new OfflineFeatures(logger);
} else if (isCCR()) {
logger.debug(
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features."
);
return new OfflineFeatures(logger);
} else {
return new Features(repositoryNwo, tempDir, logger);
}

13
lib/init-action.js generated
View File

@@ -103758,11 +103758,7 @@ function isDynamicWorkflow() {
return getWorkflowEventName() === "dynamic";
}
function isDefaultSetup() {
return isDynamicWorkflow() && !isCCR();
}
var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
function isCCR() {
return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false;
return isDynamicWorkflow();
}
function prettyPrintInvocation(cmd, args) {
return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" ");
@@ -105709,11 +105705,6 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
"Not running against github.com. Using default values for all features."
);
return new OfflineFeatures(logger);
} else if (isCCR()) {
logger.debug(
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features."
);
return new OfflineFeatures(logger);
} else {
return new Features(repositoryNwo, tempDir, logger);
}
@@ -106289,7 +106280,7 @@ async function initConfig(features, inputs) {
throw e;
}
}
if (await features.getValue("ignore_generated_files" /* IgnoreGeneratedFiles */) && isCCR()) {
if (await features.getValue("ignore_generated_files" /* IgnoreGeneratedFiles */) && isDynamicWorkflow()) {
try {
const generatedFilesCheckStartedAt = import_perf_hooks.performance.now();
const generatedFiles = await getGeneratedFiles(inputs.sourceRoot);

View File

@@ -103265,10 +103265,6 @@ function isSelfHostedRunner() {
function isDynamicWorkflow() {
return getWorkflowEventName() === "dynamic";
}
var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
function isCCR() {
return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false;
}
function prettyPrintInvocation(cmd, args) {
return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" ");
}
@@ -104382,11 +104378,6 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
"Not running against github.com. Using default values for all features."
);
return new OfflineFeatures(logger);
} else if (isCCR()) {
logger.debug(
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features."
);
return new OfflineFeatures(logger);
} else {
return new Features(repositoryNwo, tempDir, logger);
}

View File

@@ -120284,10 +120284,6 @@ function getWorkflowRunAttempt() {
function isSelfHostedRunner() {
return process.env.RUNNER_ENVIRONMENT === "self-hosted";
}
var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
function isCCR() {
return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false;
}
var persistedInputsKey = "persisted_inputs";
var persistInputs = function() {
const inputEnvironmentVariables = Object.entries(process.env).filter(
@@ -121174,11 +121170,6 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
"Not running against github.com. Using default values for all features."
);
return new OfflineFeatures(logger);
} else if (isCCR()) {
logger.debug(
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features."
);
return new OfflineFeatures(logger);
} else {
return new Features(repositoryNwo, tempDir, logger);
}

6
lib/upload-lib.js generated
View File

@@ -106068,11 +106068,7 @@ function isDynamicWorkflow() {
return getWorkflowEventName() === "dynamic";
}
function isDefaultSetup() {
return isDynamicWorkflow() && !isCCR();
}
var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
function isCCR() {
return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false;
return isDynamicWorkflow();
}
function prettyPrintInvocation(cmd, args) {
return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" ");

View File

@@ -106099,11 +106099,7 @@ function isDynamicWorkflow() {
return getWorkflowEventName() === "dynamic";
}
function isDefaultSetup() {
return isDynamicWorkflow() && !isCCR();
}
var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
function isCCR() {
return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false;
return isDynamicWorkflow();
}
function prettyPrintInvocation(cmd, args) {
return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" ");
@@ -107366,11 +107362,6 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
"Not running against github.com. Using default values for all features."
);
return new OfflineFeatures(logger);
} else if (isCCR()) {
logger.debug(
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features."
);
return new OfflineFeatures(logger);
} else {
return new Features(repositoryNwo, tempDir, logger);
}

View File

@@ -1,16 +0,0 @@
name: "CCR"
description: "A standard analysis in CCR mode"
env:
CODEQL_ACTION_ANALYSIS_KEY: "dynamic/copilot-pull-request-reviewer/codeql-action-test"
steps:
- uses: ./../action/init
id: init
with:
languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }}
- uses: ./../action/analyze
id: analysis
with:
upload-database: false

View File

@@ -5,14 +5,13 @@ import {
fixCodeQualityCategory,
getPullRequestBranches,
isAnalyzingPullRequest,
isCCR,
isDefaultSetup,
isDynamicWorkflow,
} from "./actions-util";
import { computeAutomationID } from "./api-client";
import { EnvVar } from "./environment";
import { getRunnerLogger } from "./logging";
import { mockCCR, setupTests } from "./testing-utils";
import { setupTests } from "./testing-utils";
import { initializeEnvironment } from "./util";
setupTests(test);
@@ -257,16 +256,8 @@ test("isDynamicWorkflow() returns true if event name is `dynamic`", (t) => {
t.false(isDynamicWorkflow());
});
test("isCCR() returns true when expected", (t) => {
mockCCR();
t.assert(isCCR());
t.false(isDefaultSetup());
});
test("isDefaultSetup() returns true when expected", (t) => {
process.env.GITHUB_EVENT_NAME = "dynamic";
process.env[EnvVar.ANALYSIS_KEY] = "dynamic/github-code-scanning";
t.assert(isDefaultSetup());
t.false(isCCR());
});

View File

@@ -8,7 +8,6 @@ import * as io from "@actions/io";
import { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package";
import type { Config } from "./config-utils";
import { EnvVar } from "./environment";
import { Logger } from "./logging";
import {
doesDirectoryExist,
@@ -255,15 +254,7 @@ export function isDynamicWorkflow(): boolean {
/** Determines whether we are running in default setup. */
export function isDefaultSetup(): boolean {
return isDynamicWorkflow() && !isCCR();
}
/* The analysis key prefix used for CCR. */
const CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer";
/** Determines whether we are running in CCR. */
export function isCCR(): boolean {
return process.env[EnvVar.ANALYSIS_KEY]?.startsWith(CCR_KEY_PREFIX) || false;
return isDynamicWorkflow();
}
export function prettyPrintInvocation(cmd: string, args: string[]): string {

View File

@@ -7,7 +7,7 @@ import * as yaml from "js-yaml";
import {
getActionVersion,
isAnalyzingPullRequest,
isCCR,
isDynamicWorkflow,
} from "./actions-util";
import {
AnalysisConfig,
@@ -964,10 +964,13 @@ export async function initConfig(
}
}
// If we are in CCR or the corresponding FF is enabled, try to determine
// If we are in a dynamic workflow or the corresponding FF is enabled, try to determine
// which files in the repository are marked as generated and add them to
// the `paths-ignore` configuration.
if ((await features.getValue(Feature.IgnoreGeneratedFiles)) && isCCR()) {
if (
(await features.getValue(Feature.IgnoreGeneratedFiles)) &&
isDynamicWorkflow()
) {
try {
const generatedFilesCheckStartedAt = performance.now();
const generatedFiles = await getGeneratedFiles(inputs.sourceRoot);

View File

@@ -21,7 +21,6 @@ import {
getRecordingLogger,
initializeFeatures,
LoggedMessage,
mockCCR,
mockCodeQLVersion,
mockFeatureFlagApiEndpoint,
setupTests,
@@ -535,12 +534,3 @@ test("initFeatures returns a `Features` instance by default", async (t) => {
t.is("Features", features.constructor.name);
});
});
test("initFeatures returns an `OfflineFeatures` instance in CCR", async (t) => {
await withTmpDir(async (tmpDir) => {
mockCCR();
const features = setUpFeatureFlagTests(tmpDir);
t.is("OfflineFeatures", features.constructor.name);
});
});

View File

@@ -3,7 +3,6 @@ import * as path from "path";
import * as semver from "semver";
import { isCCR } from "./actions-util";
import { getApiClient } from "./api-client";
import type { CodeQL } from "./codeql";
import * as defaults from "./defaults.json";
@@ -818,11 +817,6 @@ export function initFeatures(
"Not running against github.com. Using default values for all features.",
);
return new OfflineFeatures(logger);
} else if (isCCR()) {
logger.debug(
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features.",
);
return new OfflineFeatures(logger);
} else {
return new Features(repositoryNwo, tempDir, logger);
}

View File

@@ -6,10 +6,9 @@ import {
checkExpectedLogMessages,
getRecordingLogger,
LoggedMessage,
mockCCR,
setupTests,
} from "../testing-utils";
import { initializeEnvironment, withTmpDir } from "../util";
import { GitHubVariant, initializeEnvironment, withTmpDir } from "../util";
import {
assertAllFeaturesHaveDefaultValues,
@@ -20,14 +19,16 @@ setupTests(test);
test.beforeEach(() => {
initializeEnvironment("1.2.3");
mockCCR();
});
test("OfflineFeatures makes no API requests", async (t) => {
await withTmpDir(async (tmpDir) => {
const loggedMessages: LoggedMessage[] = [];
const logger = getRecordingLogger(loggedMessages);
const features = setUpFeatureFlagTests(tmpDir, logger);
const features = setUpFeatureFlagTests(tmpDir, logger, {
type: GitHubVariant.GHES,
version: "3.0.0",
});
t.is("OfflineFeatures", features.constructor.name);
sinon
@@ -36,7 +37,7 @@ test("OfflineFeatures makes no API requests", async (t) => {
await assertAllFeaturesHaveDefaultValues(t, features);
checkExpectedLogMessages(t, loggedMessages, [
"Querying feature flags is not currently supported in Copilot Code Review. Using offline data for all features.",
"Not running against github.com. Using default values for all features.",
]);
});
});

View File

@@ -14,7 +14,6 @@ import { CachingKind } from "./caching-utils";
import * as codeql from "./codeql";
import { Config } from "./config-utils";
import * as defaults from "./defaults.json";
import { EnvVar } from "./environment";
import {
CodeQLDefaultVersionInfo,
Feature,
@@ -505,9 +504,3 @@ export function makeTestToken(length: number = 36) {
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return chars.repeat(Math.ceil(length / chars.length)).slice(0, length);
}
/** Sets the environment variables needed for isCCR() to be `true`. */
export function mockCCR() {
process.env.GITHUB_EVENT_NAME = "dynamic";
process.env[EnvVar.ANALYSIS_KEY] = "dynamic/copilot-pull-request-reviewer";
}