-
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
Draft: Go modules ignore conditions using go list -m -versions
#3630
Conversation
Instead of using our custom Go-based updatechecker (go_modules/helpers/updatechecker/main.go), let's rely on the built-in Go tooling to identify the latest resolvable version of a dependency (i.e., `go list -m --versions <module>`). This also signals a move to performing all of our Dependabot-specific logic in Ruby (which is the norm for most ecosystems), as opposed to splitting it between Ruby and Go. Co-authored-by: David McIntosh <[email protected]>
json, stderr, status = Open3.capture3(env, SharedHelpers.escape_command("go list -m -mod=mod -versions --json #{dependency.name}")) | ||
if !status.success? | ||
|
||
# TODO: Should we populate an error_context here? | ||
handle_subprocess_error(SharedHelpers::HelperSubprocessFailed.new(message: stderr, error_context: {})) | ||
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.
json, stderr, status = Open3.capture3(env, SharedHelpers.escape_command("go list -m -mod=mod -versions --json #{dependency.name}")) | |
if !status.success? | |
# TODO: Should we populate an error_context here? | |
handle_subprocess_error(SharedHelpers::HelperSubprocessFailed.new(message: stderr, error_context: {})) | |
end | |
json = SharedHelpers.run_shell_command("go list -m -mod=mod -versions --json #{dependency.name}") |
Closing in favor of #3631. We'd still like to make use of |
To extend this: both approaches download the target module into the cache. I setup the following sandbox:
When I wipe the package cache and invoke the helper, the dependency is cloned:
The difference is that module listing fetches the entire module graph (e.g. including transitive), not just the module being queried:
Yikes! Also worth a shout,
Now that's where it's at - the query time shouldn't scale with the target repository's size! Aside: in the experiment where |
@thepwagner Thanks for that insight! I think it's downloading all the transitive deps to create the |
Thanks for the deep analysis and reporting the result publicly so that drive-by contributors like me don't try to re-invent the wheel. Note that the transitive deps download may go away (or be greatly reduced in scope) when golang/go#36460 lands. Given the really nice benefits listed above re: gaining retraction, major version support, etc this is probably worth re-investigating once |
Now that go 1.17 is out we should give this another shot. Avoiding the need to maintain our own copy of the internal go modules libs would be a great benefit. See #4157. |
go 1.17 didn't end up helping but I was able to make progress with an empty |
This is an initial exploration of moving go_module latest version selection out of the
updatechecker
helper and into the ruby code. The goal is to support the upcomingupdate_type
ignore conditions.Instead of modifying the
updatechecker
helper we started down the route of usinggo list -m -versions --json <module>
to fetch the list of available versions and then added any extra filtering that was needed to make the tests pass.This appeared to work pretty well and had some benefits:
updatechecker
codeHowever, we hit one snag. While pairing with @jasonrudolph we discovered that his dev shell was out of date and using go 1.15. When I tried this under 1.16 the
go list
command started to report this error:A workaround I came up with was to change the command to
go list -m -mod=mod -versions --json github.com/dependabot-fixtures/go-modules-lib
. This works but takes much more time as it ends up downloading the module into the module cache. Forupdate_checker_spec.rb
this increased the runtime from ~2s to ~10s when run with an empty module cache. In practice this change would mean we need to download every dependency we check for updates instead of only downloading dependencies that need to be updated.Because of the potential performance impact I'm not feeling good about rolling out the
go list
change as part of supporting ignore conditions but wanted to put this out for feedback in case I missed something. I'm also going to put up a draft of an alternate approach which modifies theupdatechecker
helper to behave more likego list
instead of switching togo list
. That could make it easier to swap out the implementation in the future.Alternate: #3631