Skip to content

Merge main into releases/v3 #2814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d1b3f74
Update changelog and version after v3.28.11
github-actions[bot] Mar 7, 2025
ff91c9d
Update checked-in dependencies
github-actions[bot] Mar 7, 2025
b2e6519
Merge pull request #2799 from github/mergeback/v3.28.11-to-main-6bb031af
cklin Mar 7, 2025
88676f2
Minimally remove micromatch
aeisenberg Mar 7, 2025
d76f393
Do not set --expect-discarded-cache on "cleanup-level: overlay"
cklin Mar 10, 2025
248ab9b
build(deps-dev): bump the npm group with 3 updates
dependabot[bot] Mar 10, 2025
053e218
Update checked-in dependencies
github-actions[bot] Mar 10, 2025
aecf015
build(deps): bump ruby/setup-ruby in the actions group
dependabot[bot] Mar 10, 2025
b46b37a
Merge pull request #2803 from github/dependabot/npm_and_yarn/npm-129f…
henrymercer Mar 10, 2025
d376269
Update pr-check
aeisenberg Mar 10, 2025
270886f
Pass overlay mode into databaseInitCluster()
cklin Mar 10, 2025
ff5f0b9
Support overlay database creation
cklin Mar 10, 2025
0efe12d
build: refresh js files
cklin Mar 10, 2025
13f2f96
Merge pull request #2801 from github/cklin/overlay-databases
cklin Mar 11, 2025
7254660
Merge pull request #2804 from github/dependabot/github_actions/action…
aeisenberg Mar 11, 2025
dc49dca
Merge pull request #2800 from github/aeisenberg/remove-minimatch
aeisenberg Mar 11, 2025
f8367fb
Set and cache dependency directory for Java `build-mode: none`
mbg Mar 10, 2025
afa3ed3
Add more documentation
mbg Mar 13, 2025
251c7fd
Update changelog
mbg Mar 13, 2025
c31f6c8
git-utils: deleted unused functions
cklin Mar 13, 2025
f338ec8
Merge pull request #2806 from github/cklin/delete-unused-git-utils
cklin Mar 13, 2025
5f98c40
Fix dependabot errors
aeisenberg Mar 14, 2025
70df9de
Merge pull request #2808 from github/aeisenberg/fix-dependabot
aeisenberg Mar 14, 2025
4c409a5
Remove temporary dependency directory in `analyze` post action
mbg Mar 17, 2025
611289e
build(deps): bump ruby/setup-ruby in the actions group
dependabot[bot] Mar 17, 2025
7866bcd
Manually bump workflow to match autogenerated file
angelapwen Mar 17, 2025
6a151cd
Merge pull request #2811 from github/dependabot/github_actions/action…
angelapwen Mar 17, 2025
55f0237
Merge pull request #2802 from github/mbg/dependency-caching/java-buil…
mbg Mar 18, 2025
4e3a534
Update default bundle to codeql-bundle-v2.20.7
github-actions[bot] Mar 17, 2025
d7d03fd
Add changelog note
github-actions[bot] Mar 17, 2025
6349095
Merge pull request #2810 from github/update-bundle/codeql-bundle-v2.20.7
smowton Mar 18, 2025
bb59f77
Update changelog for v3.28.12
github-actions[bot] Mar 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support overlay database creation
This commit adds support for creating overlay-base and overlay
databases, controlled via the CODEQL_OVERLAY_DATABASE_MODE environment
variable.
  • Loading branch information
cklin committed Mar 10, 2025
commit ff5f0b9efdde997429172d6cec95233686451b0e
22 changes: 22 additions & 0 deletions src/git-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,28 @@ export const decodeGitFilePath = function (filePath: string): string {
return filePath;
};

/**
* Get the root of the Git repository.
*
* @param sourceRoot The source root of the code being analyzed.
* @returns The root of the Git repository.
*/
export const getGitRoot = async function (
sourceRoot: string,
): Promise<string | undefined> {
try {
const stdout = await runGitCommand(
sourceRoot,
["rev-parse", "--show-toplevel"],
`Cannot find Git repository root from the source root ${sourceRoot}.`,
);
return stdout.trim();
} catch {
// Errors are already logged by runGitCommand()
return undefined;
}
};

function getRefFromEnv(): string {
// To workaround a limitation of Actions dynamic workflows not setting
// the GITHUB_REF in some cases, we accept also the ref within the
Expand Down
25 changes: 18 additions & 7 deletions src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { Feature, featureConfig, Features } from "./feature-flags";
import {
checkInstallPython311,
cleanupDatabaseClusterDirectory,
getOverlayDatabaseMode,
initCodeQL,
initConfig,
runInit,
Expand Down Expand Up @@ -396,7 +397,22 @@ async function run() {
}

try {
cleanupDatabaseClusterDirectory(config, logger);
const sourceRoot = path.resolve(
getRequiredEnvParam("GITHUB_WORKSPACE"),
getOptionalInput("source-root") || "",
);

const overlayDatabaseMode = await getOverlayDatabaseMode(
(await codeql.getVersion()).version,
config,
sourceRoot,
logger,
);
logger.info(`Using overlay database mode: ${overlayDatabaseMode}`);

if (overlayDatabaseMode !== OverlayDatabaseMode.Overlay) {
cleanupDatabaseClusterDirectory(config, logger);
}

if (zstdAvailability) {
await recordZstdAvailability(config, zstdAvailability);
Expand Down Expand Up @@ -676,19 +692,14 @@ async function run() {
}
}

const sourceRoot = path.resolve(
getRequiredEnvParam("GITHUB_WORKSPACE"),
getOptionalInput("source-root") || "",
);

const tracerConfig = await runInit(
codeql,
config,
sourceRoot,
"Runner.Worker.exe",
getOptionalInput("registries"),
apiDetails,
OverlayDatabaseMode.None,
overlayDatabaseMode,
logger,
);
if (tracerConfig !== undefined) {
Expand Down
48 changes: 47 additions & 1 deletion src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import * as path from "path";

import * as toolrunner from "@actions/exec/lib/toolrunner";
import * as io from "@actions/io";
import * as semver from "semver";

import { getOptionalInput, isSelfHostedRunner } from "./actions-util";
import { GitHubApiCombinedDetails, GitHubApiDetails } from "./api-client";
import { CodeQL, setupCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { CodeQLDefaultVersionInfo, FeatureEnablement } from "./feature-flags";
import { getGitRoot } from "./git-utils";
import { Language, isScannedLanguage } from "./languages";
import { Logger } from "./logging";
import { OverlayDatabaseMode } from "./overlay-database-utils";
import {
CODEQL_OVERLAY_MINIMUM_VERSION,
OverlayDatabaseMode,
} from "./overlay-database-utils";
import { ToolsSource } from "./setup-codeql";
import { ZstdAvailability } from "./tar";
import { ToolsDownloadStatusReport } from "./tools-download";
Expand Down Expand Up @@ -80,6 +85,47 @@ export async function initConfig(
return config;
}

export async function getOverlayDatabaseMode(
codeqlVersion: string,
config: configUtils.Config,
sourceRoot: string,
logger: Logger,
): Promise<OverlayDatabaseMode> {
const overlayDatabaseMode = process.env.CODEQL_OVERLAY_DATABASE_MODE;

if (
overlayDatabaseMode === OverlayDatabaseMode.Overlay ||
overlayDatabaseMode === OverlayDatabaseMode.OverlayBase
) {
if (config.buildMode !== util.BuildMode.None) {
logger.warning(
`Cannot build an ${overlayDatabaseMode} database because ` +
`build-mode is set to "${config.buildMode}" instead of "none". ` +
"Falling back to creating a normal full database instead.",
);
return OverlayDatabaseMode.None;
}
if (semver.lt(codeqlVersion, CODEQL_OVERLAY_MINIMUM_VERSION)) {
logger.warning(
`Cannot build an ${overlayDatabaseMode} database because ` +
`the CodeQL CLI is older than ${CODEQL_OVERLAY_MINIMUM_VERSION}. ` +
"Falling back to creating a normal full database instead.",
);
return OverlayDatabaseMode.None;
}
if ((await getGitRoot(sourceRoot)) === undefined) {
logger.warning(
`Cannot build an ${overlayDatabaseMode} database because ` +
`the source root "${sourceRoot}" is not inside a git repository. ` +
"Falling back to creating a normal full database instead.",
);
return OverlayDatabaseMode.None;
}
return overlayDatabaseMode as OverlayDatabaseMode;
}
return OverlayDatabaseMode.None;
}

export async function runInit(
codeql: CodeQL,
config: configUtils.Config,
Expand Down
2 changes: 2 additions & 0 deletions src/overlay-database-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export enum OverlayDatabaseMode {
OverlayBase = "overlay-base",
None = "none",
}

export const CODEQL_OVERLAY_MINIMUM_VERSION = "2.20.5";
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy