-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Add the force_latest_compat
keyword argument to Pkg.test
#2176
Add the force_latest_compat
keyword argument to Pkg.test
#2176
Conversation
If this is decided to be a good idea, I think an option to |
Sure, that would be fine. We could have an optional keyword argument I definitely think that we need this feature somewhere. Otherwise, you don't actually know if your CompatHelper/Dependabot PRs are passing CI. |
force_latest_compat
functionforce_latest_compat
keyword argument to Pkg.test
@KristofferC Alright, it is now a keyword argument to Pkg.test(coverage = true, force_latest_compat = true) The default value is |
Bump. @KristofferC take a look at the new implementation and let me know what you think. |
Bump. |
Just to put what's been said in Slack somewhere permanent: It might be a good idea to make forcing latest versions of dependencies the default Personally, I don't see this getting much buy-in if it needs to be done manually. |
I agree. Do you think that should go in this PR, or a follow-up PR? I was thinking that we first get this PR merged, and then I'll make a follow-up PR to add the automatic CI detection. The alternative approach would just to be to set |
If we're going to make latest compat default all the time, it's basically the same as just not having the option to at all. Not a good idea IMO. It doesn't really matter to me in which PR stuff happens, just as long as it doesn't get delayed a whole minor Julia version. If it's easier to do it after this is merged, then sure. |
How about this: I'll put the CI changes in a new PR targeting this branch. So Kristoffer and others can review the two PRs separately. But if they do want to review everything at once, they can merge that PR into this one. I'll get the CI changes PR up later today. |
|
Based on the discussion in #2234, I have closed #2234, and the "auto-detect Dependabot/CompatHelper" functionality has been moved into julia-actions/julia-runtest#20. |
Bump; this seems really useful for CompatHelper |
Any additional thoughts or review comments on this PR? If not, I'm inclined to wait a little bit, and then merge this PR. |
return compat_new | ||
end | ||
|
||
function force_latest_compat(filename::AbstractString) |
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 function looks kinda pointless. We already have functions to read and write projects. What you want to do is just change the compat of an existing project. So the only thing that should be modified is
Line 210 in 8b0045d
compat::Dict{String,String} = Dict{String,String}()# TODO Dict{String, VersionSpec} |
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.
Sure, we can get rid of the force_latest_compat(filename::AbstractString)
method. However, we would just end up moving this code (the code to load the project from the Project.toml
file) from this location to line 1443 of src/Operations.jl
.
If you look at lines 1437 through 1443 of src/Operations.jl
: the temp project that is going to be used for the test sandbox is in the form of a Project.toml
file that has been written to disk at the filename tmp_project
. This temp project does not exist in memory yet; it is only a project file on disk. So we will need to read it in from the file.
@@ -1438,6 +1440,10 @@ function sandbox(fn::Function, ctx::Context, target::PackageSpec, target_path::S | |||
cp(sandbox_project, tmp_project) | |||
chmod(tmp_project, 0o600) | |||
end | |||
if force_latest_compat |
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.
Modify the sandbox_project_override.env.project.compat
before it is written (at line 1437) and the correct compat should just be printed automatically. No need to write to disk, chmod, read it back in, modify compat, write it back out to disk, chmod again.
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.
That works if sandbox_project_override !== nothing
. But what if we are in the other branch, i.e. isfile(sandbox_project)
?
See #2439 for an alternative to this PR. |
Closing in favor of #2439 |
This pull request adds the
force_latest_compat
keyword argument to thePkg.test
function.When
force_latest_compat
istrue
, then, for each[compat]
entry in the active project, only the latest compatible version will be allowed.The default value is
force_latest_compat = false
.Motivation
Suppose that you have a bot (e.g. CompatHelper or Dependabot) that opens pull requests to widen your
[compat]
entries whenever one of your dependencies makes a new breaking release.And suppose that originally your package's
Project.toml
file looks like this:The bot opens a PR to change your package's
Project.toml
file to this:Now, your CI runs your test suite with this new
Project.toml
file. The problem is that, during the test suite,Pkg.test
might choose to run your package's tests with version 1 of SomePackage.jl. Therefore, even if your CI tests pass, you don't know whether or not your package is compatible with version 2 of SomePackage.jl.The solution is to modify your CI test script. Instead of using this as your test script (in Travis CI, AppVeyor CI, GitHub Actions CI, etc.):
You would have this as your CI test script instead:
This will guarantee that your tests will run with version 2 of SomePackage.jl.