-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adds support for elixir sub-projects without the need for umbrella applications #3944
Conversation
Here is the content of the encoded
|
Thanks @gjsduarte, this updates the FileFetcher to ensure we pull in the right files, but it's not clear to me if the rest of the update process actually works with this setup. It'd be awesome if you could add a few tests for the So far looks great and thanks for tackling this 🙇 |
Thanks for the feedback @jurre. I've added tests for the Basically, they ensure the rest of the process behaves the same as with umbrella applications. Let me know what you think. |
map { |f| File.join(apps_path, f.name) } | ||
repo_contents(dir: apps_path). | ||
select { |f| f.type == "dir" }. | ||
map { |f| File.join(apps_path, f.name) } if apps_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's already a guard against apps_path
being nil on line 51
map { |f| File.join(apps_path, f.name) } if apps_path | |
map { |f| File.join(apps_path, f.name) } |
@@ -0,0 +1,4 @@ | |||
%{"distillery": {:hex, :distillery, "1.5.2", "eec18b2d37b55b0bcb670cf2bcf64228ed38ce8b046bb30a9b636a6f5a4c0080", [:mix], [], "hexpm"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've got a new pattern for fixtures that would be neat to use here. Could you move these these files and the mixfile + lockfile into a project folder instead?
e.g. hex/spec/fixtures/projects/umbrella_sub_projects
, so this would include all files needed for the update: apps/dependabot_business/mix.exs
, apps/dependabot_web/mix.exs
, mix.exs
and mix.lock
(you could copy these files from mixfiles/umbrella
and lockfiles/umbrella
).
Example layout for bundler: https://github.com/dependabot/dependabot-core/tree/11695abbfbd2c8c54db885c56a26a3f2fdc5bedb/bundler/spec/fixtures/projects/bundler1/custom_tag_gemfile
You can then replace let(:files) { [mixfile, lockfile, sub_mixfile1, sub_mixfile2] }
with let(:files) { project_dependency_files("umbrella_sub_projects") }
let(:mixfile_body) { fixture("mixfiles", "sub_projects") } | ||
let(:lockfile_body) { fixture("lockfiles", "sub_projects") } | ||
let(:files) { [mixfile, lockfile, sub_mixfile1, sub_mixfile2] } | ||
let(:sub_mixfile1) do | ||
Dependabot::DependencyFile.new( | ||
name: "apps/dependabot_business/mix.exs", | ||
content: fixture("mixfiles", "dependabot_business") | ||
) | ||
end | ||
let(:sub_mixfile2) do | ||
Dependabot::DependencyFile.new( | ||
name: "apps/dependabot_web/mix.exs", | ||
content: fixture("mixfiles", "dependabot_web") | ||
) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you've got the project fixture set up this should work:
let(:mixfile_body) { fixture("mixfiles", "sub_projects") } | |
let(:lockfile_body) { fixture("lockfiles", "sub_projects") } | |
let(:files) { [mixfile, lockfile, sub_mixfile1, sub_mixfile2] } | |
let(:sub_mixfile1) do | |
Dependabot::DependencyFile.new( | |
name: "apps/dependabot_business/mix.exs", | |
content: fixture("mixfiles", "dependabot_business") | |
) | |
end | |
let(:sub_mixfile2) do | |
Dependabot::DependencyFile.new( | |
name: "apps/dependabot_web/mix.exs", | |
content: fixture("mixfiles", "dependabot_web") | |
) | |
end | |
let(:files) { project_dependency_files("umbrella_sub_projects") } |
let(:mixfile_fixture_name) { "sub_projects" } | ||
let(:lockfile_fixture_name) { "sub_projects" } | ||
|
||
let(:files) { [mixfile, lockfile, sub_mixfile1, sub_mixfile2] } | ||
let(:sub_mixfile1) do | ||
Dependabot::DependencyFile.new( | ||
name: "apps/dependabot_business/mix.exs", | ||
content: fixture("mixfiles", "dependabot_business") | ||
) | ||
end | ||
let(:sub_mixfile2) do | ||
Dependabot::DependencyFile.new( | ||
name: "apps/dependabot_web/mix.exs", | ||
content: fixture("mixfiles", "dependabot_web") | ||
) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, once the project is set up:
let(:mixfile_fixture_name) { "sub_projects" } | |
let(:lockfile_fixture_name) { "sub_projects" } | |
let(:files) { [mixfile, lockfile, sub_mixfile1, sub_mixfile2] } | |
let(:sub_mixfile1) do | |
Dependabot::DependencyFile.new( | |
name: "apps/dependabot_business/mix.exs", | |
content: fixture("mixfiles", "dependabot_business") | |
) | |
end | |
let(:sub_mixfile2) do | |
Dependabot::DependencyFile.new( | |
name: "apps/dependabot_web/mix.exs", | |
content: fixture("mixfiles", "dependabot_web") | |
) | |
end | |
let(:files) { project_dependency_files("umbrella_sub_projects") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution 🙇 left a few minor comments otherwise LGTM!
Thanks for the feedback @feelepxyz! I've refactored the tests to use the new pattern as you suggested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the spec changes 👌 I forgot to approve the action run so just waiting for ci to come back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
This PR will change the hex file fetcher to include path dependencies from a monorepo main
mix.exs
file.With this change, dependabot will now correctly update dependencies used in sub-projects, as long as they exist as path dependencies of your project.
Addresses #820