-
-
Notifications
You must be signed in to change notification settings - Fork 285
Add the force_latest_compatible_version keyword argument to Pkg.test
#2439
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
Conversation
8d4a250 to
04a1de8
Compare
04a1de8 to
98b9f95
Compare
98b9f95 to
c17b1ac
Compare
61299f2 to
64546bb
Compare
5294636 to
147321e
Compare
237b0a6 to
3b932f9
Compare
|
I am not super clear on the |
fcb4da6 to
d037718
Compare
So, one of the enhancements that I would like to make in the future is to be able to slightly loosen the requirement from "latest compatible version of your dependency" to "latest compatible breaking family of versions of your dependency". So, for example, suppose that your package has a Foo = "0.1"And a bot (CompatHelper, Dependabot, etc.) makes a PR to change this to: Foo = "0.1, 0.2"Suppose that the list of versions of the
When CI runs your package's test suite on this CompatHelper/Dependabot pull request, we want to make sure that your tests use version 0.2.x of Foo.jl. But, to be honest, we don't actually care if it uses Foo 0.2.0 instead of 0.2.1. According to (Pkg's implementation of) SemVer, if your package is compatible with Foo 0.2.0, then it is also compatible with Foo 0.2.1, because any changes from Foo 0.2.0 -> 0.2.1 must be (by definition) backwards-compatible. So what we really want is:
I don't think that we can do this with I haven't implemented this feature in this PR, because I would like to get this PR reviewed and merged relatively quickly. But I will implement this feature in a future PR. This is really the workflow that we need to support in CompatHelper/Dependabot PRs. The rule for computing step 4 is:
|
|
The natural follow-up question is: "under what circumstances might my package be compatible with Foo 0.1.0 and Foo 0.2.0 but not Foo 0.2.1" Suppose that our package's Foo = "0.1"
Bar = "0.8"And after the CompatHelper/Dependabot PR, it looks like this: Foo = "0.1, 0.2"
Bar = "0.8"Suppose that:
Now, our package will be compatible with Foo 0.1.0 and Foo 0.2.0. But it will not be compatible with Foo 0.2.1. So, when CI runs our package's test suite, all that we need to ensure is that the tests run with Foo 0.2.x. In this case, they will run with Foo 0.2.0. They can't run with Foo 0.2.1 because Foo 0.2.1 requires Bar 0.9.x, but our package only supports Bar 0.8.x. But, from a CompatHelper/Dependabot point of view, it is perfectly fine that our tests ran with Foo 0.2.0. Because any changes from Foo 0.2.0 to 0.2.1 (or Foo 0.2.0 to Foo 0.2.x) are by definition backwards compatible. And fundamentally, what we really want to test when CompatHelper/Dependabot makes a PR to change |
Since CompatHelper knows the new version, it can determine this on its own correct? e.g. if the new version is 0.2.3 it can know that the set of compatible versions is 0.2.x
You can make sure that some 0.2.x is installed with It seems like this workflow is already supported? Am I missing something? |
|
FWIW I don't mean to seem like I am necessarily against this 😅 , just that it seems like there is already a way to do it. |
fa60b81 to
b6702a3
Compare
b6702a3 to
b41cf6c
Compare
Ah, I hadn't realized this. In that case it does seem like you would need to read straight from the compat bounds. Something that could be done (possibly in a future PR) is to take the set of version ranges you compute and add them during the sandbox resolve step. That way you can error out with a resolver trace of why it was not possible (in the case that the resolve step fails). It seems it would give you a better shot of meeting those requirements since you would be explicitly asking the resolver to look for a solution. |
Sure, that would be an enhancement that we could make. In the documentation, I've indicated that this feature is experimental, which will allow us to make modification to its behavior. Since this PR is already pretty big, I'd prefer to get this merged first, and then make this enhancement in a future PR. |
00vareladavid
left a comment
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.
I left a few nitpicky suggestions but otherwise looks good to me
6c905a2 to
9406d86
Compare
Co-authored-by: Kristoffer Carlsson <[email protected]> Co-authored-by: Ian Butterworth <[email protected]> Co-authored-by: David Varela <[email protected]>
9406d86 to
4c441e0
Compare
|
Thanks @00vareladavid! |
| - `julia_args::Union{Cmd, Vector{String}}`: options to be passed the test process. | ||
| - `test_args::Union{Cmd, Vector{String}}`: test arguments (`ARGS`) available in the test process. | ||
| - `force_latest_compatible_version::Bool=false`: [EXPERIMENTAL] force the latest compatible version of each direct dependency. | ||
| - `allow_earlier_backwards_compatible_versions::Bool=false`: [EXPERIMENTAL] allow any version that is backwards-compatible with the latest compatible version of a direct dependency. If `force_latest_compatible_version` is `false`, then the value of `force_latest_compatible_version` has no effect. |
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.
I don't understand what this means.
(also very long line).
Closes #2176
Fixes #2445
Summary
This pull request adds the
force_latest_compatible_version::Boolkeyword argument to thePkg.testfunction.If
force_latest_compatible_versionistrue, then an error will be thrown if any of the direct dependencies is not at the latest compatible version.The default value is
force_latest_compatible_version = false.This is an experimental feature. The behavior is subject to change or removal in minor or patch releases of Julia.
How It Works
Here is a summary of how this feature works.
Pkg.testsets up the temporary sandbox project and runs the resolver.force_latest_compatible_versionisfalse, we do nothing. Ifforce_latest_compatible_versionistrue, we assemble the list of all direct dependencies, and then loop over the list; for each direct dependencyDepName, we take the following steps:DepNamethe resolver selected.DepName.[compat]entry forDepName. At the end of this step, we have a list of all registered versions ofDepNamethat are compatible with the[compat]entry forDepName.maximumof the list from step (iii). This gives us the latest registered version ofDepNamethat is compatible with the[compat]entry forDepName.Vsuch that all changes fromVto the result of step (iv) are backwards-compatible.Pkg.testruns thetests/runtests.jlfile.The algorithm for computing step (v) above is as follows. The input is a version number of the form
x.y.z.x > 0, returnx.0.0. (This is because, forx > 0, all changes fromx.0.0tox.y.zare backwards-compatible.)y > 0, return0.y.0. (This is because, fory > 0, all changes from0.y.0to0.y.zare backwards-compatible.)0.0.z.Motivation
Suppose that you have a
[compat]entry that looks like this:And suppose that a bot (e.g. CompatHelper, Dependabot, etc.) opens a pull request to edit the above
[compat]entry so that it looks like this instead:When CI runs your package tests on this pull request, you want to make sure that the tests use Foo version
0.4. (If the tests do not use Foo version0.4, then even if the tests pass, you do not know whether or not your package works with Foo version0.4.)However, currently, there is no way to automatically check that your package tests used Foo version
0.4.With this pull request, you simply set
force_latest_compatible_version = true. Then, if your package tests do not use Foo version0.4, Pkg will throw an error, and therefore your CI job will fail. This will alert you to the fact that you should probably not yet merge the CompatHelper/Dependabot PR.Future Plans
Note the default value is
force_latest_compatible_version = false.However, for GitHub Actions CI, we will add a feature to julia-actions/julia-runtest that works as follows:
force_latest_compatible_version = true.force_latest_compatible_version = false.Related Discussions
force_latest_compatkeyword argument toPkg.test#2176force_latest_compat=trueby default on Dependabot/CompatHelper PRs, and setforce_latest_compat=falseby default otherwise #2234force_latest_compatible_versioninput, and add the "auto-detect Dependabot/CompatHelper" functionality julia-actions/julia-runtest#20