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

Do not freeze file-based Poetry dependency version #4334

Merged
merged 8 commits into from
Nov 22, 2021

Conversation

phillipuniverse
Copy link
Contributor

Fixes #4333. This was modeled after #2361 with the same type of tests.

I also renamed the test files to differentiate between directory-based and file-based dependencies, both of which can be specified by a path.

@phillipuniverse phillipuniverse requested a review from a team as a code owner October 20, 2021 14:49
@@ -54,7 +54,7 @@ def freeze_top_level_dependencies_except(dependencies)

next unless (locked_version = locked_details&.fetch("version"))

next if locked_details&.dig("source", "type") == "directory"
next if locked_details&.dig("source", "type") == "directory" || locked_details&.dig("source", "type") == "file"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really write Ruby but maybe this is better written as:

next if ["directory", "file"].include? locked_details&.dig("source", "type")

Also, looking at the schema we might need to also special-case URL dependencies.

Copy link
Member

Choose a reason for hiding this comment

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

I slightly prefer it, but I don't feel strongly about it

@@ -151,5 +151,20 @@
)
end
end

context "with file dependencies" do
let(:dependencies) { [] }
Copy link
Member

Choose a reason for hiding this comment

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

Rubocop will complain that this is indented 4 spaces instead of 2

@jurre
Copy link
Member

jurre commented Oct 20, 2021

I noticed a couple of files names were changed but their references in the tests weren't, those tests will likely fail because of that I think?

Overall I think this looks good, but it's been a while since I looked at this code so might need to dig into it a bit more.

@phillipuniverse
Copy link
Contributor Author

@jurre thanks for the feedback, changes applied!

I'm still not 100% sure if we need to special-case url pieces or not. It looks like there are already tests for URL dependencies. There's already a test for them so maybe this is already doing the right thing? I'm just not sure how to validate the runtime behavior.

context "with a url dependency" do
let(:pyproject_fixture_name) { "url_dependency.toml" }
let(:pyproject_lock_fixture_name) { "url_dependency.lock" }
it "excludes the url dependency" do
expect(dependencies.map(&:name)).to_not include("toml")
end
end

Copy link

@geori geori 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 typo when ya'll dropped the quotes

@phillipuniverse
Copy link
Contributor Author

@jurre sorry for so much back and forth, TBH I'm writing this a little blind. I'll actually set up a dev environment for this if it fails after the next run.

2 follow-up questions:

  1. Do you think we need to do anything about the url dependencies or do you think those will be covered?
  2. What's the process/timeline for this fix being included in the official GitHub Dependabot?

Thanks for your help!

@phillipuniverse phillipuniverse requested a review from jurre October 30, 2021 14:57
@jurre
Copy link
Member

jurre commented Nov 1, 2021

Do you think we need to do anything about the url dependencies or do you think those will be covered?

Tbh, I am not sure! Maybe we can add a test for it?

What's the process/timeline for this fix being included in the official GitHub Dependabot?

Once it's merged I can cut a release fairly quickly and can roll it out usually the same or next day.

@jurre
Copy link
Member

jurre commented Nov 12, 2021

There's a couple of failing python tests on CI @phillipuniverse, would you mind taking a look at those?

@phillipuniverse
Copy link
Contributor Author

@jurre yup, sorry for letting this languish I'll get this sorted out today.

@phillipuniverse
Copy link
Contributor Author

phillipuniverse commented Nov 18, 2021

ok! @jurre I feel pretty good about this now, sorry again for how long this whole thing has taken.

New updates:

  • Rebased on top of latest updates on main
  • URL dependencies had the same problem and were incorrectly adding a version attribute, I added a test and whitelisted it
  • Added more positive assertions for directory and file dependencies -- essentially make sure the dependency is actually there but the dependency + version is not

Thanks for your help getting this over the line! We should probably squash merge this when it's all done.

@phillipuniverse
Copy link
Contributor Author

@jurre last thing here - I have 1 failing test locally and I'm not sure why:

image

But even with my change in python/lib/dependabot/python/file_updater/pyproject_preparer.rb commented out it still fails. And I even checked out main and ran it and still fails so... 🤷 hopefully it won't fail in CI!

@jurre
Copy link
Member

jurre commented Nov 18, 2021

I have 1 failing test

I am currently working on upgrading pipenv so I think I can tackle that failure, it doesn't seem related to these changes

Copy link
Member

@jurre jurre left a comment

Choose a reason for hiding this comment

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

Thanks!

@jurre jurre merged commit ab5bcd6 into dependabot:main Nov 22, 2021
@phillipuniverse phillipuniverse deleted the poetry-file-dependency branch November 22, 2021 13:14
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.

Cannot use Poetry file-based dependencies
3 participants