-
Notifications
You must be signed in to change notification settings - Fork 179
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
Use dune-build-info to compute version number #1133
Conversation
We'll discuss the implementation later but I'm curious to hear if that's compatible with your vendoring use cases @jberdine & @ceastlund? |
We currently override the version information anyway, because we use neither dune nor git internally at present. Once we move from jenga to dune I suspect this will work fine for us. |
I'm curious to hear if that's compatible with your vendoring use cases @jberdine & @ceastlund?
As far as I can tell, yes, I think so. But in the past (with a previous version of dune-release I think) I had trouble where it would not use the build command from the opam file and would instead just invoke a generic `dune -p ... -j ...` which would fail. So I worry that this working is dependent on the changes in #1005 that I remain completely unconvinced about.
|
7ff1c3f
to
a4c53ba
Compare
Are you using version strings of the form 0.12-25-g6bdc881 in your .ocamlformat files ?
Yes, we at least currently can't use any released version.
To support that, we could match the version depending on the precision given by the user:
If we use version strings of the form a.b.c-commit:
• 0.12 matches any 0.12.*-*
• 0.12.0 matches only 0.12.0-*
• 0.12-hash match precisely one commit: 0.12.*-hash
IIUC doing that would make it impossible to e.g. depend on exactly the released 0.12 version, as the binary does not know it's commit hash (it could be built from a tarball rather than a git checkout) in order to check it against the specified version.
|
Hashes are for dev binaries that are passed around. |
For users who built the binary, any build between 0.12.0 and 0.12.1 (excluded) would be allowed, on purpose.
If you want an imprecise version check, then it should be added in addition to the existing precise version check, rather than losing the current functionality. It is currently possible for an .ocamlformat file to specify a released version like 0.12 and ensure that an ocamlformat binary from a checkout a few commits ahead cannot mistakenly be used. It should not be necessary to use an unreleased version in order to make the version checking precise enough to fail on anything but a binary built from the expected commit. It is important to catch the mistake of specifying a released version and using a binary built from a checkout that isn't at exactly the released commit.
I have actually been considering adding the compiler version and ppxlib version as well, as they can change the output even for the same ocamlformat commit.
This discussion makes me think that there are several different use case objectives, but I'm only familiar with the one that tries to ensure reproducible formatting.
|
I see. Allowing a range of versions may not be a good idea because even a very small regression or bug fix can change formatting. |
For the compiler/OMP issue, we should test that and increase the constraints if necessary.
In the past we have seen e.g. a compiler upgrade result in the parser producing slightly different locations, which changed comment attachment, and as a result the same ocamlformat commit built with 4.05 and 4.06 (if I remember the versions correctly) would produce different output in some cases.
I suspect that changes can also happen if versions of ppxlib which internally use different versions of the parsetree are used.
|
It would be nice to revive this to simplify the version management and implement it in a more common way. Is there anything blocking this now? One addition I would like to see to help testing and development if nothing else, is a version-stamped binary in a stable/reliable path. Perhaps something like a make target implemented using something like:
|
It seems that there are two distincts problems here:
For the second one, it seems that there's a distinction to be made between the tool version (release vs git vs vendored vs patched) and the behavior version (the thing that is checked by |
I think that this is almost ready. Could you rebase and run |
I rebased and updated the headers. But |
do you mean when running the binary that's copied under |
Yes this binary returns an unknown version. |
4be6877
to
a785182
Compare
The stamping issue I reported happens on linux. But I didn't observe the dune warning you got. |
This will need to add a version constraint for dune > 2.6.0 to make sure to pull in ocaml/dune#3599. |
I rebased and added the constraint on the dune-build-info version, there is still a quirk causing the version number to be 0.14.1-... instead of 0.14.2-... but it's because I messed the last release. |
there is still a quirk causing the version number to be 0.14.1-... instead of 0.14.2-... but it's because I messed the last release
Have you git pulled the tags recently? As far as I can tell, I fixed that a bit ago with some retagging.
|
You pushed a lightweight tag and not an annotated tag (produced by Also I think in general it's better not to try fixing these errors, as moving tags can break more things down the line. |
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.
Everything looks good to me.
Makefile
Outdated
install: | ||
dune build @install | ||
dune install --prefix _install | ||
dune install |
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.
Is this expected to run install twice?
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 also had this question, seems like the second dune install
should be removed.
The version constraint is not necessary (and the fix won't be there until 2.7.0)
How is it not necessary? Once this PR is merged, the versions will be wrong with dune-build-info < 2.7.0, right? If so, this constraint is necessary, and this PR must wait.
|
They will be wrong with dune-build-info < 2.7.0 if you use a flambda switch, yes. But that's not specific to ocamlformat so I'm not sure that this fix should live in ocamlformat metadata. I suppose we can wait until there's a fix available in dune for flambda users, and maybe in the meantime add conflicts between existing versions of dune-build-info and flambda. |
Actually as pointed in the corresponding bug, it's only a problem on 4.10.0+flambda, and it's dune that you need to upgrade, not dune-build-info. |
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.
Ok, that plan sounds good. For now I'll mark this as changes requested as we'll need to update once dune 2.7 is released. There is another question, which whether to also delay merging #1361 until after this one. I don't have a strong view either way, but #1361 doesn't seem to be urgent and delaying would avoid the opam template file business. What do others think?
Makefile
Outdated
install: | ||
dune build @install | ||
dune install --prefix _install | ||
dune install |
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 also had this question, seems like the second dune install
should be removed.
Seems good to batch this with #1361. About bound, yes we just need to depend on dune-build-info and bumping the dune dependency to |
9f7ccd1
to
f255b3f
Compare
I rebased and fixed the opam metadata now that there is a dune version with a fix available. Two remaining questions:
|
Bumping the dnue language version sounds good to me. About the double install rule I think I did that because it was necessary to have the substitution working to have the right version number. Don't know if I missed something or if it was a bug that is fixed now, if only one install works we can simplify it of course. |
There's no need for any |
This uses dune-build-info to compute the version number. It will be resolved in the following way: - if (version) is set in (dune-project), it is used. This is what happens when using opam pins (through dune subst), or for released versions (through dune-release). - otherwise, a description from [git describe] will be used. Caveat for this case: binaries under [_build/] will not have this information, but [dune install --prefix _install] will copy a valid binary under [_install/bin]. We require at least dune 2.7, since `dune-build-info` is broken on flambda switches before this version. See ocaml/dune#3599
f255b3f
to
5760f1f
Compare
I removed the makefile changes, we can add them once we have a concrete use case. Thanks! |
This switches the handling of
--version
usingdune-build-info
instead of a script.Here is how it works.
The version string is resolved in the following way:
(version)
is set in(dune-project)
, it is used.This is what happens when using opam pins (through
dune subst
), or for released versions (throughdune-release
).git describe
will be used.Caveat for this case: binaries under
_build/default
will not have this information, butdune install --prefix _install
will copy a valid binary under_install/bin
.(see #454)