Skip to content
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

C++: Handle codeql_action_cpp_build_mode_none feature flag #2568

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

calumgrant
Copy link
Contributor

@calumgrant calumgrant commented Oct 24, 2024

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

Continues #2565, tidying up the feature flag options and setting the environment variables.

src/init-action.ts Fixed Show fixed Hide fixed
src/init-action.ts Fixed Show fixed Hide fixed
@calumgrant calumgrant marked this pull request as ready for review October 24, 2024 16:41
@calumgrant calumgrant requested a review from a team as a code owner October 24, 2024 16:41
Comment on lines 555 to 559
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.

@@ -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.

src/init-action.ts Fixed Show fixed Hide fixed
src/init-action.ts Fixed Show fixed Hide fixed
src/init-action.ts Fixed Show fixed Hide fixed
Comment on lines +549 to +551
// Set CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE
if (config.languages.includes(Language.cpp)) {
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.

If you think we might want users to interact with this option, we should make this an extractor option by changing the name to CODEQL_EXTRACTOR_CPP_OPTION_BUILD_MODE_NONE and including an entry in codeql-extractor.yml. That gives customers more options for configuring it. If this is only going to be used by the Action, then we can leave it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is internal and short-lived, so I don't think we should give customers the option of configuring it.

@calumgrant calumgrant merged commit b91f43b into main Oct 25, 2024
275 checks passed
@calumgrant calumgrant deleted the calumgrant/bmn-ff2 branch October 25, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants