-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Nixpkgs documentation: reword info about version testers #348025
base: master
Are you sure you want to change the base?
Conversation
c770b3c
to
3d6d946
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/4695 |
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.
Sounds very good, I cannot really judge the content besides being able to understand it better
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.
Thanks for the PR. The rephrasings are indeed better, but I'm not sure about a few things.
- If the `versionCheckPhase` (the phase defined by [`versionCheckHook`](#versioncheckhook)) fails, it triggers a failure which can't be ignored if you use the package, or if you find out about it in a [`nixpkgs-review`](https://github.com/Mic92/nixpkgs-review) report. | ||
- Sometimes packages become silently broken - meaning they fail to launch but their build passes because they don't perform any tests in the `checkPhase`. If you use this tool infrequently, such a silent breakage may rot in your system / profile configuration, and you will not notice the failure until you will want to use this package. Testing such basic functionality ensures you have to deal with the failure when you update your system / profile. | ||
- When you open a PR, [ofborg](https://github.com/NixOS/ofborg)'s CI _will_ run `passthru.tests` of [packages that are directly changed by your PR (according to your commits' messages)](https://github.com/NixOS/ofborg?tab=readme-ov-file#automatic-building), but if you'd want to use the [`@ofborg build`](https://github.com/NixOS/ofborg?tab=readme-ov-file#build) command for dependent packages, you won't have to specify in addition the `.tests` attribute of the packages you want to build, and no body will be able to avoid these tests. |
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.
Hmm in principal I don't mind much how this got moved and rephrased into versionCheckHook.section.md
, but I think there should be a single place in which we compare both of the methods. Perhaps the "Package tests" subtitle in pkgs/README.md
is a better? What do you think? If you agree we should concentrate the information about this somewhere, I hope we'd agree the correct thing to do would be to link from here and from versionCheckHook.section.md
to that comparison section.
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.
Comparing both methods on a third place is a nice idea.
I will do this asap.
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.
Hmm in principal I don't mind much how this got moved and rephrased into
versionCheckHook.section.md
, but I think there should be a single place in which we compare both of the methods. Perhaps the "Package tests" subtitle inpkgs/README.md
is a better? What do you think? If you agree we should concentrate the information about this somewhere, I hope we'd agree the correct thing to do would be to link from here and fromversionCheckHook.section.md
to that comparison section.Comparing both methods on a third place is a nice idea. I will do this asap.
One more thing: I don't like how this section was moved to a different place on a different commit (I'm reviewing this PR commit-wise).
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.
Modifying multiple files at once is confusing and is prone to merge conflicts.
851811d
to
63d05d4
Compare
7587fac
to
32b264b
Compare
32b264b
to
092b9aa
Compare
pkgs/README.md
Outdated
- Since [`nixpkgs-review`](https://github.com/Mic92/nixpkgs-review) does not execute `passthru.tests` attributes, it will not execute `passthru.tests.version`. | ||
|
||
On the other hand, `versionCheckHook` will be executed as a regular phase during the build time of the derivation, therefore it will be indirectly catched by `nixpkgs-review`, working around this limitation. | ||
|
||
- When a pull request is opened against Nixpkgs repository, [ofborg](https://github.com/NixOS/ofborg)'s CI will automatically run `passthru.tests` attributes for the packages that are [directly changed by your PR (according to your commits' messages)](https://github.com/NixOS/ofborg?tab=readme-ov-file#automatic-building). | ||
|
||
However, ofBorg does not run the `passthru.tests` attributes for _transitive dependencies_ of those packages. To execute them, commands like [`@ofborg build dependency1.tests dependency2.tests ...`](https://github.com/NixOS/ofborg?tab=readme-ov-file#build) are needed. | ||
|
||
On the other hand, `versionCheckHook` will be executed as a regular phase during the build time of the derivation, therefore it will be indirectly catched by ofBorg, working around this limitation. | ||
|
||
- Sometimes a package triggers no errors while being built - especially when the upstream provides no unit tests-, however it fails at runtime. When such a package is not used in a regular basis, it leaves room for a silent breakage that rots in the system / profile configuration, not being noticed for long periods of time until the next usage of this package. | ||
|
||
Although `passthru.tests` fills the same purpose, it is more prone to be forgotten by human beings; on the other hand, `versionCheckHook` will be executed as a regular phase during the build time of the derivation, therefore it will not be accidentally ignored. | ||
|
||
Despite having an almost identical functioning and a huge overlap, `versionCheckHook` and `testers.testVersion` have complementary roles, and there are no impediments for using both at the same time. |
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.
These should be moved back to nixpkgs documentation.
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.
Done.
pkgs/README.md
Outdated
|
||
- When a pull request is opened against Nixpkgs repository, [ofborg](https://github.com/NixOS/ofborg)'s CI will automatically run `passthru.tests` attributes for the packages that are [directly changed by your PR (according to your commits' messages)](https://github.com/NixOS/ofborg?tab=readme-ov-file#automatic-building). | ||
|
||
However, ofBorg does not run the `passthru.tests` attributes for _transitive dependencies_ of those packages. To execute them, commands like [`@ofborg build dependency1.tests dependency2.tests ...`](https://github.com/NixOS/ofborg?tab=readme-ov-file#build) are needed. |
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.
Ofborg also doesn't run versionCheckHook
for those transisive dependencies, unless you add them to passthru?
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.
Ofborg also doesn't run
versionCheckHook
for those transisive dependencies, unless you add them to passthru?
If passthru.tests
is empty, indeed ofborg won't run versionCheckHook
for those dependent packages, but nixpkgs-review will.
pkgs/README.md
Outdated
|
||
However, ofBorg does not run the `passthru.tests` attributes for _transitive dependencies_ of those packages. To execute them, commands like [`@ofborg build dependency1.tests dependency2.tests ...`](https://github.com/NixOS/ofborg?tab=readme-ov-file#build) are needed. | ||
|
||
On the other hand, `versionCheckHook` will be executed as a regular phase during the build time of the derivation, therefore it will be indirectly catched by ofBorg, working around this limitation. |
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.
It's worth noting that people are supposed to add one package per commit, so ofborg will still build all passthru.tests
.
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 is more about future updates. E. g. SDL has many dependencies but an update of SDL does not trigger the already existing transitive dependencies in the current CI setup.
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 have a general comment: When such a big system such as Nixpkgs as managed and designed, you want to keep the amount of moving parts to a minimum, especially since you want to attract as much contributors as possible, and to make it easy for them as possible to contribute.
Hence, having 2 perfectly legitimate ways of doing sort of the same thing is a binary moving part that is not justified in my opinion - inexperienced contributors reading these docs won't know what to do and I anticipate their decision will be random in the best case, and they'd stay confused and won't contribute in the worst case. I really think we should reach a decision regarding this.
- Catch dynamic linking errors and such and missing environment variables that should be added by wrapping. | ||
- Probable protection against accidentally building the wrong version, for example when using an "old" hash in a fixed-output derivation. | ||
- It assures the main program can run. | ||
- It catches dynamic linking errors, missing or malformed environment variables and other runtime errors. |
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.
You know the word "catches" doesn't fit a passthru.tests.version
check, because if you won't build that passthru.tests
derivation you won't catch anything. I'd use the word "catches" when describing versionCheckHook
, but not when describing both.
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.
You approved that wording before.
Further, I don't think this difference matters here.
passthru.tests.version
catches errors when executed.
versionCheckHook
catches errors when executed.
The difference is passthru.tests.version
is executed directly when called e.g. via commandline, while versionCheckHook
is executed indirectly when the package containing it is built.
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.
Correct, I inspected your phrasing in more details and changed my mind.
Further, I don't think this difference matters here.
passthru.tests.version
catches errors when executed.versionCheckHook
catches errors when executed.The difference is
passthru.tests.version
is executed directly when called e.g. via commandline, whileversionCheckHook
is executed indirectly when the package containing it is built.
That's a big difference IMO. Of course we agree that if you'd explicitly build passthru.tests.version
you'd catch an issue with the package, but I find it inaccurate to suggest that merely adding a passthru.tests.version
will make any such issue be catched, because all the reasons you are already aware of from our discussion on Discourse.
- If the `versionCheckPhase` (the phase defined by [`versionCheckHook`](#versioncheckhook)) fails, it triggers a failure which can't be ignored if you use the package, or if you find out about it in a [`nixpkgs-review`](https://github.com/Mic92/nixpkgs-review) report. | ||
- Sometimes packages become silently broken - meaning they fail to launch but their build passes because they don't perform any tests in the `checkPhase`. If you use this tool infrequently, such a silent breakage may rot in your system / profile configuration, and you will not notice the failure until you will want to use this package. Testing such basic functionality ensures you have to deal with the failure when you update your system / profile. | ||
- When you open a PR, [ofborg](https://github.com/NixOS/ofborg)'s CI _will_ run `passthru.tests` of [packages that are directly changed by your PR (according to your commits' messages)](https://github.com/NixOS/ofborg?tab=readme-ov-file#automatic-building), but if you'd want to use the [`@ofborg build`](https://github.com/NixOS/ofborg?tab=readme-ov-file#build) command for dependent packages, you won't have to specify in addition the `.tests` attribute of the packages you want to build, and no body will be able to avoid these tests. |
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.
Hmm in principal I don't mind much how this got moved and rephrased into
versionCheckHook.section.md
, but I think there should be a single place in which we compare both of the methods. Perhaps the "Package tests" subtitle inpkgs/README.md
is a better? What do you think? If you agree we should concentrate the information about this somewhere, I hope we'd agree the correct thing to do would be to link from here and fromversionCheckHook.section.md
to that comparison section.Comparing both methods on a third place is a nice idea. I will do this asap.
One more thing: I don't like how this section was moved to a different place on a different commit (I'm reviewing this PR commit-wise).
@@ -22,14 +24,32 @@ stdenv.mkDerivation (finalAttrs: { | |||
}) | |||
``` | |||
|
|||
Note that for [`buildPythonPackage`](#buildpythonpackage-function) and [`buildPythonApplication`](#buildpythonapplication-function), `doInstallCheck` is enabled by default. | |||
Note that some builders, e.g. [`buildPythonPackage`](#buildpythonpackage-function) and [`buildPythonApplication`](#buildpythonapplication-function), enable `doInstallCheck` by default. |
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.
It's not such a big effort IMO to maintain here a list of all builders that enable installCheck
phase by default. Hence, the previous phrasing is a bit more decisive and informative. This phrasing sort of suggests: "We don't keep track of which builders enable installCheck
by default and which do, so you should inspect the source code of each if you don't want to enable it when not needed."
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.
Hum, should this paragraph be rewritten each time a new custom builder appears? I don't think so.
This paragraph looks like an example of builder, not a exhaustive listing.
Further, the documentation of these builders should provide this information, and it is the duty of a contributor to read the documentation of that builder at least.
If this info is not found in the docs, a bug report should be opened and the docs team should be pinged.
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.
Further, the documentation of these builders should provide this information, and it is the duty of a contributor to read the documentation of that builder at least.
If this info is not found in the docs, a bug report should be opened and the docs team should be pinged.
I agree with that. But as for:
Hum, should this paragraph be rewritten each time a new custom builder appears? I don't think so.
This paragraph looks like an example of builder, not a exhaustive listing.
Nowadays, the list of builders that enable installCheck
is very small, so I don't find it exhaustive to list them. I agree that theoretically if a new builder that enables installCheck
will be added in the future to Nixpkgs, probably no one will remember or know to add it to this "list", but I doubt that will happen TBH, from my experience with Nixpkgs.
The previous phrasing also didn't suggest that the builders mentioned is the definitive list of builders that enable installCheck
by default. I just say that your phrasing slightly more implies that maybe many more builders are enabling installCheck
, and that is not true.
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.
Reverted, in terms. I reworded the example in a more direct sentence.
pkgs/README.md
Outdated
|
||
The most notable difference between `versionCheckHook` and `testers.testVersion` is that `versionCheckHook` runs at the build time of the package, while `passthru.tests.versions` executes a whole derivation that depends on the package. | ||
|
||
The advantages of `testers.testVersion` over `versionCheckHook` are listed at [Package tests](#var-passthru-tests-packages) already. Below we will list some advantages of `versionCheckHook` over `testers.testVersion`: |
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.
Hmm it felt natural how the advantages of testVersion
were listed there, but here it doesn't feel natural at all how the advantages of versionCheckHook
are listed here and not in it's documentation. If this section is a comparison, it should aggregate advantages and disadvantages of both methods in the same place.
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.
You suggested to put the comparison in pkgs/README before.
Do you think this comparison should be in versionCheckHook.md instead?
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 know, but I didn't anticipate that it'd come out so inconsistent, because you'd keep the pros and cons of testVersion
elsewhere. What I suggested was (this time more accurately):
Put the 2x2 matrix of pros & cons of both testVersion
& versionCheckHook
in a neutral place like pkgs/README.md
, and link to that comparison section from both testVersion
's documentation and versionCheckHook.section.md
. Mention shortly the motivation to use either tests in testVersion
's documentation and versionCheckHook.section.md
.
I cannot promise I'd approve such a change never the less, because if we can (and I think we should) reach a consensus that one of the approaches should be the default approach to use, there is no justification for putting such an exhaustive 2x2 matrix of pros and cons in a neutral place.
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.
pkgs/readme.md
does not work.
For now I will move this to versioncheckhook docs
pkgs/README.md
Outdated
|
||
Although `passthru.tests` fills the same purpose, it is more prone to be forgotten by human beings; on the other hand, `versionCheckHook` will be executed as a regular phase during the build time of the derivation, therefore it will not be accidentally ignored. | ||
|
||
Despite having an almost identical functioning and a huge overlap, `versionCheckHook` and `testers.testVersion` have complementary roles, and there are no impediments for using both at the same time. |
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 agree with this sentence. Why would someone make an effort to use both? Why can't we agree that either of them fits most cases?
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.
Why would someone make an effort to use both?
I don't know. Maybe stress-testing.
Why can't we agree that either of them fits most cases?
Because there is no objective metric for this right now.
On the other hand, I can delete this last 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.
Why can't we agree that either of them fits most cases?
Because there is no objective metric for this right now.
Objective metric? Metric of what?
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.
Metric of fittingness.
"For packages with such and such characteristics, this approach is well-suited because of such and such premises; otherwise the other approach is better".
(I am redacting this the more neutral possible way, precisely because we have no objective metric.)
- Flip the explanation and buildPythonPackage reference paragraphs - Add a section to emphasize the attributes controlling the hook
092b9aa
to
654f87f
Compare
654f87f
to
49377ae
Compare
- Reword the paragraphs - Remove the comparison with `versionCheckHook` - It will be moved to `versionCheckHook.section.md`
49377ae
to
4d4f230
Compare
Note: see also: | ||
- [`versionCheckHook`](#versioncheckhook), an independent hook with similar functionality. | ||
- [A comparison between both](#versioncheckhook-comparison-testversion) |
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 find it confusing to mention this alternative and not telling the users right away which approach should be used most of the times.
It does so in a clean environment (using `env --ignore-environment`), and it checks for the `${version}` string in both the `stdout` and the `stderr` of the command. It will report to you in the build log the output it received and it will fail the build if it failed to find `${version}`. | ||
|
||
The variables that this phase control are: | ||
Note that `doInstallCheck` is enabled by default for [`buildPythonPackage`](#buildpythonpackage-function) and [`buildPythonApplication`](#buildpythonapplication-function). |
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's almost the same sentence..
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.
Getting better, but I'd still insist that we should tell users that in most cases one of the approaches is better.
- E.g. extra tools, customized programs etc. | ||
- `testers.testVersion` executed in an identical environment of a consumer would, independent of the environment it was built. | ||
- `testers.testVersion` can be executed without rebuilding the package, saving time especially when the rebuild takes too much time. | ||
- `testers.testVersion` do not add overhead to each build, since it runs after the build, not during it. |
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.
Calling this an overhead is an overstatement IMO.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.