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

make DependencySnapshot aware of multiple directories #8963

Merged
merged 19 commits into from
Feb 23, 2024

Conversation

jakecoffman
Copy link
Member

@jakecoffman jakecoffman commented Feb 2, 2024

This PR refactors DependencySnapshot to be aware of multiple directories.

Why

Previously DependencySnapshot would take all of the dependency files and attempt to parse them to discover the dependencies. This breaks down with multi-dir, as really what we need to do is group the files by directory and then parse them, storing the dependencies for each directory separately.

Also, we need to keep track of handled_dependencies per directory as well or we end up thinking we've handled it in one directory, but when we encounter the same dependency in another directory then we've missed an update. Previously I was clearing the handled_dependencies between directories, but then the problem is we are dropping individual PRs that should have been created.

Approach

For now I've encapsulated multi-dir support inside of DependencySnapshot by using @current_directory as a way to set which directory is currently being operated on. This prevents multi-dir from rippling out into the other non-group operations.

The group operations will set dependency_snapshot.current_directory(dir) which then makes all of the pre-existing methods continue to work as they always have.

If I had made all of the methods take a directory param instead I would have had to touch many many more files and specs (I started down this path at first and it was overwhelming!)

Admittedly this looks a bit complex, but I hope getting integration tests down outside of Ruby/rspec will allow us to take a bold refactor to make it all much simpler in the end.

@jakecoffman jakecoffman requested a review from a team as a code owner February 2, 2024 16:23
@jakecoffman jakecoffman marked this pull request as draft February 2, 2024 17:23
@jakecoffman
Copy link
Member Author

Looking at the smoke test failures, it looks like this fixes some issues, and the setup was wrong on two of them so dependabot/smoke-tests#185 fixes that up.

I think this is good to go!

@jakecoffman jakecoffman marked this pull request as ready for review February 13, 2024 20:42
@jakecoffman
Copy link
Member Author

I'll fix the smoke tests once I start deploying, all the failures look correct, if that makes sense.

@jakecoffman jakecoffman merged commit 88be06e into main Feb 23, 2024
104 of 123 checks passed
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