Skip to content

Commit c2293b3

Browse files
authored
Merge pull request #4244 from github/henrymercer/graduate-per-language-bundles
Use per-language CodeQL bundles by default
2 parents 0acb923 + f033e23 commit c2293b3

10 files changed

Lines changed: 143 additions & 200 deletions

‎.github/workflows/__export-file-baseline-information.yml‎

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/__per-language-bundle-validation.yml‎

Lines changed: 25 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/entry-points.js‎

Lines changed: 15 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pr-checks/checks/export-file-baseline-information.yml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ installDotNet: true
1111
env:
1212
CODEQL_ACTION_SKIP_FILE_COVERAGE_ON_PRS: false
1313
CODEQL_ACTION_SUBLANGUAGE_FILE_COVERAGE: true
14-
# To balance speed and coverage, we analyze only a single language (JavaScript), but use the
15-
# combined bundle so we can test that baseline information is reported for each language in the
16-
# multi-language source directory.
17-
CODEQL_ACTION_PER_LANGUAGE_BUNDLES: false
1814
steps:
1915
- uses: ./../action/init
2016
id: init
2117
with:
2218
languages: javascript
2319
tools: ${{ steps.prepare-test.outputs.tools-url }}
20+
# To balance speed and coverage, analyze only JavaScript but use the combined bundle so
21+
# baseline information is reported for every language in the multi-language repository. A
22+
# custom configuration prevents per-language bundles from being used.
23+
config: |
24+
paths-ignore: []
2425
- name: Build code
2526
run: ./build.sh
2627
- uses: ./../action/analyze

‎pr-checks/checks/per-language-bundle-validation.yml‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
name: Per-language bundles
22
description: Validates extraction and analysis using each per-language CodeQL bundle.
3-
# TODO: Use a released bundle once releases include per-language bundles.
43
matrix:
54
include:
65
- language: actions
76
os: ubuntu-latest
8-
version: nightly-latest
7+
version: linked
98
# Actions also needs the JavaScript extractor.
109
expected-extractors: actions javascript
1110
- language: cpp
1211
os: ubuntu-latest
13-
version: nightly-latest
12+
version: linked
1413
build-mode: manual
1514
build-command: gcc -o main main.c
1615
- language: csharp
1716
os: ubuntu-latest
18-
version: nightly-latest
17+
version: linked
1918
build-mode: none
2019
- language: go
2120
os: ubuntu-latest
22-
version: nightly-latest
21+
version: linked
2322
build-mode: autobuild
2423
- language: java
2524
os: ubuntu-latest
26-
version: nightly-latest
25+
version: linked
2726
build-mode: none
2827
- language: javascript
2928
os: ubuntu-latest
30-
version: nightly-latest
29+
version: linked
3130
- language: python
3231
os: ubuntu-latest
33-
version: nightly-latest
32+
version: linked
3433
- language: ruby
3534
os: ubuntu-latest
36-
version: nightly-latest
35+
version: linked
3736
- language: rust
3837
os: ubuntu-latest
39-
version: nightly-latest
38+
version: linked
4039
- language: swift
4140
os: macos-latest-xlarge
42-
version: nightly-latest
41+
version: linked
4342
build-mode: autobuild
44-
env:
45-
CODEQL_ACTION_PER_LANGUAGE_BUNDLES: true
43+
installNode: true
4644
steps:
45+
- name: Remove CodeQL from toolcache
46+
run: |
47+
cd ./../action
48+
npx tsx ./pr-checks/toolcache.ts clear
4749
- uses: ./../action/init
4850
id: init
4951
with:
@@ -84,9 +86,8 @@ steps:
8486
CODEQL_PATH: ${{ steps.init.outputs.codeql-path }}
8587
run: |
8688
# A bundle that is missing most of its extractors must never be left in the toolcache,
87-
# where a later job analyzing a different language could pick it up. The runner image
88-
# ships with its own CodeQL in the toolcache, so check where this bundle was extracted to
89-
# rather than whether the toolcache contains CodeQL at all.
89+
# where a later job analyzing a different language could pick it up. Per-language bundles
90+
# must instead be extracted under the runner's temporary directory.
9091
echo "CodeQL is at $CODEQL_PATH"
9192
if [[ "$CODEQL_PATH" == "$RUNNER_TOOL_CACHE"/* ]]; then
9293
echo "::error::The per-language bundle was added to the toolcache at $CODEQL_PATH."

‎src/feature-flags.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ export enum Feature {
143143
OverlayAnalysisStatusCheck = "overlay_analysis_status_check",
144144
/** Controls whether overlay build failures on the default branch are stored in the Actions cache. */
145145
OverlayAnalysisStatusSave = "overlay_analysis_status_save",
146-
/**
147-
* Controls whether we may download a bundle containing only the single language being analysed,
148-
* rather than the combined bundle that contains every language.
149-
*/
150-
PerLanguageBundles = "per_language_bundles_v2",
151146
QaTelemetryEnabled = "qa_telemetry_enabled",
152147
/** Routes (some) API requests through the registry proxy. */
153148
ProxyApiRequests = "proxy_api_requests",
@@ -393,11 +388,6 @@ export const featureConfig = {
393388
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_SKIP_RESOURCE_CHECKS",
394389
minimumVersion: undefined,
395390
},
396-
[Feature.PerLanguageBundles]: {
397-
defaultValue: false,
398-
envVar: "CODEQL_ACTION_PER_LANGUAGE_BUNDLES",
399-
minimumVersion: undefined,
400-
},
401391
[Feature.QaTelemetryEnabled]: {
402392
defaultValue: false,
403393
envVar: "CODEQL_ACTION_QA_TELEMETRY",

‎src/per-language-bundles.test.ts‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import test from "ava";
22

33
import { ActionsEnvVars } from "./environment";
4-
import { Feature } from "./feature-flags";
54
import { BuiltInLanguage } from "./languages";
65
import {
76
getOtherLanguagePacksReason,
@@ -12,7 +11,6 @@ import {
1211
} from "./per-language-bundles";
1312
import { BundlePlatform } from "./platform";
1413
import {
15-
createFeatures,
1614
getRecordingLogger,
1715
getTestEnv,
1816
initAllState,
@@ -40,7 +38,6 @@ async function checkEligibility(
4038
env: getTestEnv({
4139
[ActionsEnvVars.RUNNER_ENVIRONMENT]: "github-hosted",
4240
}),
43-
features: createFeatures([Feature.PerLanguageBundles]),
4441
...stateOverrides,
4542
}),
4643
{ ...ELIGIBLE_OPTIONS, ...overrides },
@@ -145,27 +142,6 @@ test("getPerLanguageBundleLanguage requires a supported release version", async
145142
t.is(await checkEligibility({ cliVersion: "2.27.1" }), BuiltInLanguage.java);
146143
});
147144

148-
test("getPerLanguageBundleLanguage requires the feature flag", async (t) => {
149-
t.is(await checkEligibility({}, { features: createFeatures([]) }), undefined);
150-
});
151-
152-
test("getPerLanguageBundleLanguage explains a disabled feature before checking eligibility", async (t) => {
153-
const messages: LoggedMessage[] = [];
154-
const language = await getPerLanguageBundleLanguage(
155-
initAllState({
156-
features: createFeatures([]),
157-
logger: getRecordingLogger(messages, { logToConsole: false }),
158-
}),
159-
{ ...ELIGIBLE_OPTIONS, rawLanguages: undefined, cliVersion: undefined },
160-
);
161-
162-
t.is(language, undefined);
163-
t.deepEqual(
164-
messages.map((message) => message.message),
165-
["Not using a per-language CodeQL bundle since the feature is disabled."],
166-
);
167-
});
168-
169145
test("getPerLanguageBundleLanguage skips only the release version check for the latest nightly", async (t) => {
170146
const nightly = { isLatestNightly: true, cliVersion: undefined };
171147
t.is(await checkEligibility(nightly), BuiltInLanguage.java);
@@ -181,10 +157,6 @@ test("getPerLanguageBundleLanguage skips only the release version check for the
181157
]) {
182158
t.is(await checkEligibility({ ...nightly, ...overrides }), undefined);
183159
}
184-
t.is(
185-
await checkEligibility(nightly, { features: createFeatures([]) }),
186-
undefined,
187-
);
188160
t.is(
189161
await checkEligibility(nightly, {
190162
env: getTestEnv({ [ActionsEnvVars.RUNNER_ENVIRONMENT]: "self-hosted" }),

0 commit comments

Comments
 (0)