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

Add default config file location for init action #2828

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

GeekMasher
Copy link
Member

@GeekMasher GeekMasher commented Mar 26, 2025

This pull request includes an update to the src/init-action.ts file to improve the handling of the configuration file in the run function. The most important change is the addition of logic to set a default configuration file location if none is provided.

Improvements to configuration file handling:

  • src/init-action.ts: Changed the configFile variable to be mutable and added logic to check for a default configuration file location at .github/codeql/codeql.yml within the GITHUB_WORKSPACE if no configuration file is specified. If the default configuration file exists, it sets configFile to this location and logs the path. Otherwise, it logs that no configuration file was found.

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.

@Copilot Copilot bot review requested due to automatic review settings March 26, 2025 13:49
@GeekMasher GeekMasher requested a review from a team as a code owner March 26, 2025 13:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the configuration file handling in the init action by adding logic to use a default configuration file if none is provided.

  • Made the configFile variable mutable
  • Added a default config file lookup in GITHUB_WORKSPACE
  • Logged appropriate messages based on whether the default file is found
Comments suppressed due to low confidence (1)

src/init-action.ts:302

  • Consider checking for both undefined and empty string values for configFile, as getOptionalInput may return an empty string when the input is not provided.
if (configFile === undefined) {

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

Copy link
Member

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution, this looks reasonable to me.

I think we also need a changelog entry for this change, and it also might be something that might need a docs change, but I will let someone else confirm that.

logger.info(
`Using default config file location: ${path.resolve(configFile)}`,
);
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious whether it would make sense to add a log message if the default file fails to be found, to warn both the users and us when debugging that something has gone very wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually added it in the first commit but thought it would almost always trigger a log that no config was used. I'm okay with either personally

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.

2 participants