Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ec5eecb
Use per-language CodeQL bundles
henrymercer Sep 15, 2026
eb76062
Include failed bundle attempts in fallback timing
henrymercer Sep 15, 2026
289376d
Use per-language CodeQL bundles
henrymercer Sep 15, 2026
59ce3a2
Include failed bundle attempts in fallback timing
henrymercer Sep 15, 2026
2d47caf
Isolate per-language bundle eligibility state
henrymercer Sep 16, 2026
dfb9bf5
Share CodeQL bundle platform definitions
henrymercer Sep 16, 2026
f536ef4
Centralize CodeQL download telemetry fields
henrymercer Sep 16, 2026
2f552a9
Clarify bundle resolution and latest-nightly selection
henrymercer Sep 16, 2026
bd2ddba
Extract explicit CodeQL bundle URL classification
henrymercer Sep 16, 2026
89606bb
Return toolcache rejection reasons with Result
henrymercer Sep 16, 2026
f4fa111
Share elapsed-time rounding for bundle downloads
henrymercer Sep 16, 2026
69f4715
Use Result.orElse for bundle extraction paths
henrymercer Sep 16, 2026
5a2f29e
Merge published per-language bundle history
henrymercer Sep 16, 2026
28b8f59
Use shared test state for bundle eligibility
henrymercer Sep 17, 2026
ed3a24c
Group bundle eligibility test state overrides
henrymercer Sep 17, 2026
549d498
Simplify per-language platform eligibility checks
henrymercer Sep 17, 2026
ead1f7d
Rename the platform module
henrymercer Sep 17, 2026
79fe3a1
Move download telemetry into the status-report directory
henrymercer Sep 17, 2026
ecec9b5
Share per-language telemetry fields without renaming
henrymercer Sep 17, 2026
f18f353
Describe the bundle URL resolver
henrymercer Sep 17, 2026
07fa87d
Clarify the latest-nightly eligibility exception
henrymercer Sep 17, 2026
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
61 changes: 32 additions & 29 deletions lib/entry-points.js

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

18 changes: 18 additions & 0 deletions src/bundle-platform.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import test from "ava";

import { BundlePlatform, getBundlePlatform } from "./bundle-platform";

for (const [platform, arch, expected] of [
["linux", "x64", BundlePlatform.Linux64],
["linux", "arm64", BundlePlatform.LinuxArm64],
["linux", "ia32", BundlePlatform.Linux64],
["darwin", "x64", BundlePlatform.Osx64],
["darwin", "arm64", BundlePlatform.Osx64],
["win32", "x64", BundlePlatform.Win64],
["win32", "arm64", BundlePlatform.Win64],
["freebsd", "x64", undefined],
] as const) {
test(`getBundlePlatform maps ${platform}/${arch} to ${expected ?? "an all-platform bundle"}`, (t) => {
t.is(getBundlePlatform(platform, arch), expected);
});
}
26 changes: 26 additions & 0 deletions src/bundle-platform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** Platform identifiers used in CodeQL bundle asset names. */
export enum BundlePlatform {
Linux64 = "linux64",
LinuxArm64 = "linux-arm64",
Osx64 = "osx64",
Win64 = "win64",
}

/** Returns the bundle platform, or undefined when an all-platform bundle is required. */
export function getBundlePlatform(
platform: NodeJS.Platform = process.platform,
arch: NodeJS.Architecture = process.arch,
): BundlePlatform | undefined {
switch (platform) {
case "win32":
return BundlePlatform.Win64;
case "linux":
return arch === "arm64"
? BundlePlatform.LinuxArm64
: BundlePlatform.Linux64;
case "darwin":
return BundlePlatform.Osx64;
default:
return undefined;
}
}
44 changes: 18 additions & 26 deletions src/per-language-bundles.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from "ava";

import { BundlePlatform } from "./bundle-platform";
import { ActionsEnvVars, ReadOnlyEnv } from "./environment";
import { Feature } from "./feature-flags";
import { BuiltInLanguage } from "./languages";
Expand All @@ -23,7 +24,7 @@ const ELIGIBLE_OPTIONS: PerLanguageBundleOptions = {
// Any version at least as new as the minimum will do.
cliVersion: MIN_PER_LANGUAGE_BUNDLE_CLI_VERSION,
compressionMethod: "zstd",
platform: "linux64",
platform: BundlePlatform.Linux64,
variant: GitHubVariant.DOTCOM,
};

Expand All @@ -44,14 +45,21 @@ async function checkEligibility(
);
}

test("getPerLanguageBundleLanguage selects Linux bundles for non-Swift languages", async (t) => {
for (const language of Object.values(BuiltInLanguage)) {
if (language === BuiltInLanguage.swift) {
continue;
for (const platform of Object.values(BundlePlatform)) {
test(`getPerLanguageBundleLanguage selects only supported languages on ${platform}`, async (t) => {
for (const language of Object.values(BuiltInLanguage)) {
const supported =
language === BuiltInLanguage.swift
? platform === BundlePlatform.Osx64
: platform === BundlePlatform.Linux64;
t.is(
await checkEligibility({ rawLanguages: [language], platform }),
supported ? language : undefined,
language,
);
}
t.is(await checkEligibility({ rawLanguages: [language] }), language);
}
});
});
}

test("getPerLanguageBundleLanguage normalizes aliases before selecting a bundle", async (t) => {
Comment thread
mbg marked this conversation as resolved.
Resolved
t.is(
Expand All @@ -60,23 +68,7 @@ test("getPerLanguageBundleLanguage normalizes aliases before selecting a bundle"
);
});

test("getPerLanguageBundleLanguage selects the macOS bundle for Swift", async (t) => {
t.is(
await checkEligibility({ rawLanguages: ["swift"], platform: "osx64" }),
BuiltInLanguage.swift,
);
// Swift is only published for macOS.
t.is(
await checkEligibility({ rawLanguages: ["swift"], platform: "linux64" }),
undefined,
);
});

test("getPerLanguageBundleLanguage rejects unsupported platforms", async (t) => {
t.is(await checkEligibility({ platform: "osx64" }), undefined);
t.is(await checkEligibility({ platform: "win64" }), undefined);
// We do not publish per-language bundles for Linux Arm64 either.
t.is(await checkEligibility({ platform: "linux-arm64" }), undefined);
test("getPerLanguageBundleLanguage rejects unknown platforms", async (t) => {
t.is(await checkEligibility({ platform: undefined }), undefined);
});

Expand Down Expand Up @@ -164,7 +156,7 @@ test("getPerLanguageBundleLanguage skips only the release version check for nigh
{ rawLanguages: undefined },
{ rawLanguages: ["java", "python"] },
{ compressionMethod: "gzip" as const },
{ platform: "osx64" },
{ platform: BundlePlatform.Osx64 },
{ variant: GitHubVariant.GHES },
{ variant: GitHubVariant.GHEC_DR },
]) {
Expand Down
48 changes: 26 additions & 22 deletions src/per-language-bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as semver from "semver";

import { ActionState } from "./action-common";
import { isGitHubHostedRunner } from "./actions-util";
import { BundlePlatform } from "./bundle-platform";
import { Feature } from "./feature-flags";
import { BuiltInLanguage, parseBuiltInLanguage } from "./languages";
import * as tar from "./tar";
Expand Down Expand Up @@ -30,20 +31,24 @@ export function tryGetBundleLanguageFromUrl(
return match ? parseBuiltInLanguage(match[1]) : undefined;
}

/** Published platform for each language; absent entries are ineligible. */
const PER_LANGUAGE_BUNDLE_PLATFORMS: Readonly<
Partial<Record<BuiltInLanguage, string>>
/** Languages with per-language bundles published for each platform. */
const PER_LANGUAGE_BUNDLE_LANGUAGES: Readonly<
Record<BundlePlatform, ReadonlySet<BuiltInLanguage>>
> = {
[BuiltInLanguage.actions]: "linux64",
[BuiltInLanguage.cpp]: "linux64",
[BuiltInLanguage.csharp]: "linux64",
[BuiltInLanguage.go]: "linux64",
[BuiltInLanguage.java]: "linux64",
[BuiltInLanguage.javascript]: "linux64",
[BuiltInLanguage.python]: "linux64",
[BuiltInLanguage.ruby]: "linux64",
[BuiltInLanguage.rust]: "linux64",
[BuiltInLanguage.swift]: "osx64",
[BundlePlatform.Linux64]: new Set([
BuiltInLanguage.actions,
BuiltInLanguage.cpp,
BuiltInLanguage.csharp,
BuiltInLanguage.go,
BuiltInLanguage.java,
BuiltInLanguage.javascript,
BuiltInLanguage.python,
BuiltInLanguage.ruby,
BuiltInLanguage.rust,
]),
[BundlePlatform.LinuxArm64]: new Set(),
[BundlePlatform.Osx64]: new Set([BuiltInLanguage.swift]),
[BundlePlatform.Win64]: new Set(),
};

/** Inputs that determine whether we may download a per-language bundle. */
Expand All @@ -53,8 +58,8 @@ export interface PerLanguageBundleOptions {
/** CLI version, if known. Ignored for nightly bundles. */
Comment thread
mbg marked this conversation as resolved.
Resolved
cliVersion: string | undefined;
compressionMethod: tar.CompressionMethod;
/** Bundle platform identifier, such as linux64. */
platform: string | undefined;
/** Platform for which the bundle is requested. */
platform: BundlePlatform | undefined;
variant: GitHubVariant;
isNightly?: boolean;
}
Expand Down Expand Up @@ -130,14 +135,13 @@ export async function getPerLanguageBundleLanguage(
}
}

const supportedPlatform = PER_LANGUAGE_BUNDLE_PLATFORMS[language];
if (supportedPlatform === undefined) {
return explain(`no per-language bundle is published for ${language}`);
}
if (supportedPlatform !== platform) {
const supportedLanguages =
platform === undefined
? undefined
: PER_LANGUAGE_BUNDLE_LANGUAGES[platform];
if (!supportedLanguages?.has(language)) {
Comment thread
mbg marked this conversation as resolved.
Resolved
return explain(
`the ${language} bundle is only published for ${supportedPlatform}, but this job is ` +
`running on ${platform ?? "an unknown platform"}`,
`no per-language bundle is published for ${language} on ${platform ?? "an unknown platform"}`,
);
}

Expand Down
15 changes: 1 addition & 14 deletions src/setup-codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
isRunningLocalAction,
} from "./actions-util";
import * as api from "./api-client";
import { getBundlePlatform } from "./bundle-platform";
import * as defaults from "./defaults.json";
import {
addNoLanguageDiagnostic,
Expand Down Expand Up @@ -78,20 +79,6 @@ function getCodeQLBundleExtension(
}
}

/** Returns the platform component of the CodeQL bundle name for the current platform. */
export function getBundlePlatform(): string | undefined {
switch (process.platform) {
case "win32":
return "win64";
case "linux":
return process.arch === "arm64" ? "linux-arm64" : "linux64";
case "darwin":
return "osx64";
default:
return undefined;
}
}

/**
* Returns the name of the CodeQL bundle asset to download.
*
Expand Down
12 changes: 3 additions & 9 deletions src/testing-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ActionsEnv, getActionVersion } from "./actions-util";
import { AnalysisKind } from "./analyses";
import * as apiClient from "./api-client";
import { GitHubApiDetails } from "./api-client";
import { getBundlePlatform } from "./bundle-platform";
import { CachingKind } from "./caching-utils";
import { resetCachedCodeQlVersion } from "./cli/output-cache";
import type { VersionInfo } from "./cli/types";
Expand Down Expand Up @@ -933,21 +934,14 @@ export function mockBundleDownloadApi({
platformSpecific?: boolean;
tagName: string;
}): string {
const platform =
process.platform === "win32"
? "win64"
: process.platform === "linux"
? process.arch === "arm64"
? "linux-arm64"
: "linux64"
: "osx64";
const platform = platformSpecific ? getBundlePlatform() : undefined;

const baseUrl = apiDetails?.url ?? "https://example.com";

const bundleUrls = ["tar.gz", "tar.zst"].map((extension) => {
const relativeUrl = apiDetails
? `/${repo}/releases/download/${tagName}/codeql-bundle${
platformSpecific ? `-${platform}` : ""
platform !== undefined ? `-${platform}` : ""
}.${extension}`
: `/download/${tagName}/codeql-bundle.${extension}`;

Expand Down