Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
12 changes: 3 additions & 9 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.

15 changes: 15 additions & 0 deletions lib/init-action.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/init-action.js.map

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export interface FeatureEnablement {
export enum Feature {
ArtifactV4Upgrade = "artifact_v4_upgrade",
CleanupTrapCaches = "cleanup_trap_caches",
CppBuildModeNoneDisabled = "cpp_build_mode_none_disabled",
CppBuildModeNoneEnabled = "cpp_build_mode_none",
CppBuildModeNone = "cpp_build_mode_none",
CppDependencyInstallation = "cpp_dependency_installation_enabled",
DiffInformedQueries = "diff_informed_queries",
DisableCsharpBuildless = "disable_csharp_buildless",
Expand Down Expand Up @@ -105,14 +104,9 @@ export const featureConfig: Record<
envVar: "CODEQL_ACTION_CLEANUP_TRAP_CACHES",
minimumVersion: undefined,
},
[Feature.CppBuildModeNoneDisabled]: {
[Feature.CppBuildModeNone]: {
defaultValue: false,
envVar: "CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE_DISABLED",
minimumVersion: undefined,
},
[Feature.CppBuildModeNoneEnabled]: {
defaultValue: false,
envVar: "CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE_ENABLED",
envVar: "CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE",
minimumVersion: undefined,
},
[Feature.CppDependencyInstallation]: {
Expand Down
14 changes: 14 additions & 0 deletions src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,20 @@ async function run() {
}
}

// Set CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE
if (config.languages.includes(Language.cpp)) {
const bmn_var = "CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a linter error. Here's a more canonical name.

Suggested change
const bmn_var = "CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE";
const bmnVar = "CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this simpler? features.getValue is guaranteed to return a boolean and if the env var is already set, it will use that as an override.

const bmnVar = await features.getValue(Feature.CppBuildModeNone, codeql);
core.exportVariable(bmnVar);
logger.info(`Setting C++ build-mode: none to ${bmnVar}`);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That didn't quite compile, but I managed to simplify things. The code in init-action.ts is not written in this idiomatic way, and the docs to exportVariable() don't mention the behaviour when the variable is already set. Most of the code in init-action.ts defensively checks the environment.

I would suggest refactoring this file as most people will just adapt code that's already there.

if (process.env[bmn_var]) {
logger.info("CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE is already set");
} else if (await features.getValue(Feature.CppBuildModeNone, codeql)) {
logger.info("Enabling C++ build-mode: none");
core.exportVariable(bmn_var, "true");
} else {
logger.info("Disabling C++ build-mode: none");
core.exportVariable(bmn_var, "false");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the reason why you are doing this is because the extractor requires this same env var to be set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not required, just setting it for completeness.

}
}

// For CLI versions <2.15.1, build tracing caused errors in MacOS ARM machines with
// System Integrity Protection (SIP) disabled.
if (
Expand Down
Loading