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

fix(core): correctly apply source.path in VCS logic #5305

Merged
merged 1 commit into from Nov 1, 2023

Conversation

thsig
Copy link
Collaborator

@thsig thsig commented Oct 26, 2023

What this PR does / why we need it:

Before this fix, we weren't accounting for the source.path config option for actions when determining the path passed to getFiles.

This meant that actions using source.path would essentially have their versions computed using an empty file list.

Special notes for your reviewer:

As you can see, this is a pretty conservative fix that makes the minimal required changes to resolve the problem.

The naming of config.internal.basePath and action.getBasePath() is confusing. The relevant method on the VCS handler receives an action config (not an action), so the getBasePath method isn't available.

The helper I changed is very similar to the getBasePath method, but it doesn't factor in remoteSourcePath (which is available to actions, but not action configs).

I haven't given it any thought yet, but this might be a good opportunity to rename these fields to more clearly distinguish the intended semantics (and avoid more mistakes like this in the future).

Should I take a closer look and see about cleaning up & refactoring some of this, or should we make do with the actual fix for now?

@@ -0,0 +1 @@
We're putting the new cover letter on all of these now, Peter. Didn't you get the memo?
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

Copy link
Collaborator

@eysi09 eysi09 left a comment

Choose a reason for hiding this comment

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

Had a couple of comments / suggestions. Nothing blocking.

I'd also like to test manually to see if it resolves the issues I bumped into.

@@ -462,7 +462,13 @@ export function getConfigFilePath(config: ModuleConfig | BaseActionConfig) {
}

export function getConfigBasePath(config: ModuleConfig | BaseActionConfig) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be good to add a comment to this function explaining that it either returns the actual config file path or user defined path if source.path is set.

Also wondering if there's a better name for this function. Like resolvedActionPath or similar.

WDYT?

@@ -462,7 +462,13 @@ export function getConfigFilePath(config: ModuleConfig | BaseActionConfig) {
}

export function getConfigBasePath(config: ModuleConfig | BaseActionConfig) {
return isActionConfig(config) ? config.internal.basePath : config.path
if (isActionConfig(config)) {
const basePath = config.internal.basePath
Copy link
Collaborator

Choose a reason for hiding this comment

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

In a similar vein, would be good to clarify what these different paths actually refer to.

config.internal.basePath and config.source.path don't really tell me anything.

If it's a big refactor to rename these, maybe we can just start by clarifying with code comments.

And tbh, I'm not sure what could be better.

Something like configFilePath and resolvedActionPath?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added some docstrings to the config.internal interface and renamed the action.basePath() method to action.sourcePath(), hope that clarifies things a bit.

I didn't see a straightforward way to reduce the number of these fields, since e.g. config.source can have template strings and the remote source path stuff hasn't been taken care of when the configs are scanned from disk.

Before this fix, we weren't accounting for the `source.path` config
option for actions when determining the path passed to `getFiles`.

This meant that actions using `source.path` would essentially have their
versions computed using an empty file list.
@thsig
Copy link
Collaborator Author

thsig commented Oct 31, 2023

@eysi09 Do you have any further comments on this one, or should we get it merged?

@eysi09
Copy link
Collaborator

eysi09 commented Nov 1, 2023

I'm testing this manually now, against the example where I bumped into this.

Copy link
Collaborator

@eysi09 eysi09 left a comment

Choose a reason for hiding this comment

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

LGTM!

@vvagaytsev vvagaytsev added this pull request to the merge queue Nov 1, 2023
Merged via the queue into main with commit aaaf6d5 Nov 1, 2023
44 checks passed
@vvagaytsev vvagaytsev deleted the source-path-fix branch November 1, 2023 11:56
thsig added a commit that referenced this pull request Nov 2, 2023
This reverts commit aaaf6d5, which
causes a regression in certain projects using config templates.

I'll open another PR to reintroduce the changes that were reverted here,
with the relevant fixes and added test cases.
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.

None yet

3 participants