-
-
Notifications
You must be signed in to change notification settings - Fork 15.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
lib: Add contribution guidelines #272083
lib: Add contribution guidelines #272083
Conversation
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.
Unfortunately we can't automate ourselves away, but better expectations and structure are great goals.
I just hope people will find it. Maybe link it from relevant other contributing oriented pages? I'm thinking the general coding guidelines, and maybe the PR template?
lib/README.md
Outdated
## Contributing | ||
|
||
Follow these guidelines for proposing a change to the interface of `lib`: | ||
- Motivation: Clearly describe why the change is necessary and its use 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.
- Motivation: Clearly describe why the change is necessary and its use cases | |
- Provide a motivation: Clearly describe why the change is necessary and its use 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.
If your suggestion is to use imperative titles, I believe this is better:
- Do that thing
<More details about why doing that things is good>
lib/README.md
Outdated
If the same can be done with the existing interface, | ||
consider just updating the documentation with more examples and links. | ||
This is also known as the [Fairbairn Threshold](https://wiki.haskell.org/Fairbairn_threshold). | ||
- Single PR: Don't have multiple changes in one PR, instead split it up |
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.
- Single PR: Don't have multiple changes in one PR, instead split it up | |
- Single purpose PR: Don't have multiple changes in one PR, instead split it up. It keeps the conversation focused and has a higher chance of getting merged. |
lib/README.md
Outdated
- If there's no obvious best name, include the alternatives you considered | ||
- Documentation: Update the reference documentation to reflect the change | ||
- Add links to related functions | ||
- Tests: Add reasonable test coverage for the change |
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.
What do we consider reasonable? Can we provide a rule of thumb?
Some recommendations I would suggest:
- Tests: Add reasonable test coverage for the change | |
- Tests: Add good test coverage for the change | |
- For each parameter, test edge cases of the types such as empty values. | |
- Look for tricky inputs, to a reasonable degree. For example: a string with a string context (e.g. adding some file to the store), or a path value that points to a non-existing path if that should be accepted. | |
- Make sure to cover all code paths, except perhaps assertions that relate to internal invariants, as those may be impossible to trigger. | |
- We don't require checks on error messages for files tested by test suites that don't support this. For new error messages in the module system, we do. |
a421656
to
5925f69
Compare
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.
Love the new layout.
Should the items be headers though? That way we get to link to them too.
|
||
Name variables well, even if they're internal. | ||
Add code comments where the code isn't self-explanatory. | ||
|
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.
As a baseline, follow the [Nixpkgs code conventions](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#code-conventions). | |
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.
Not a fan of that section, but sure we have it, let's reference it. Most of it should become obsolete with NixOS/rfcs#166 :)
0d5bd8a
to
585ebba
Compare
I did try that out briefly but decided against it because I don't want people to just link to one part of it. This section should be short enough that people can read the entire one without focusing on just one aspect. I applied all your suggestions 🙂 (diff) |
Why's that?
I agree, but seems quite unrelated. |
Hmm I didn't think it's needed, but I guess I don't mind very much, I'll change that. |
Co-Authored-By: Robert Hensing <[email protected]>
585ebba
to
395fc06
Compare
Actually would be good to have links. I mentioned it in the review summary/preface thingy, which is too easy to overlook. Bad UI. Maybe link it from relevant other contributing oriented pages? I'm thinking the general coding guidelines, and maybe the PR template? |
Oh yeah, sorry I was a bit sloppy with properly addressing the feedback this time.
I am fairly happy with the overview section in CONTRIBUTING.md, which links to |
|
||
This keeps the conversation focused and has a higher chance of getting merged. | ||
|
||
### Name the interface appropriately |
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 section feels a bit arbitrary. I agree that naming is important, but I'm having a hard time to figure out if a name is good or bad, only based on this information.
Providing examples of good and bad names accompanied with explanations, or links to similar functional libraries (maybe hoogle or elm?) might be a good addition. Or maybe recommend people to read through earlier PRs tagged with https://github.com/NixOS/nixpkgs/labels/6.topic:%20lib, to see the name discussions there and get a feeling for 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.
If we're going to refer to languages, we'd have to point out the differences as well. That is, link to a document that does that.
Here's a few things:
- Nix lists don't have lazy spines like in Haskell, nor is cons cheap.
- Maybe and Nullable are very different.
mapNullable
is not a lawful functor. It behaves like>>=
/flatMap
.Nullable (Nullable a) == Nullable a
, etc. Less suitable for composition. - Haskell
Map.union
is flipped compared to//
.
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.
Until we codify anything: maybe make it "here's what we think" and "if you don't know, just open a PR and let's talk about 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.
I added
If you don't know what name to choose, indicate this as a discussion point in the PR.
to this item. I don't think we could have very concrete guidelines here for now.
395fc06
to
0476c4d
Compare
lib/README.md
Outdated
|
||
Names should be self-explanatory and consistent with the rest of `lib`. | ||
If there's no obvious best name, include the alternatives you considered. | ||
If you don't know what name to choose, indicate this as a discussion point in the PR. |
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.
"indicate as discussion point" sounds really heavy.
This sentence also conflicts a bit with the preceding one. Do we really think contributors can't come up with any name whatsoever? It actually seems condescending.
If you don't know what name to choose, indicate this as a discussion point in the PR. |
or
If you don't know what name to choose, indicate this as a discussion point in the PR. | |
If you don't know what name to choose, feel free to say so in the PR description. |
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 really mind either way, ping @h7x4
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.
👍
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.
@h7x4 I was hoping to get some thoughts 😅
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.
Alright I'll just remove this sentence again. Let's merge before this stalls out for too long. Feel free to open follow-up PRs if there's something to improve.
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.
Sorry, the ping went by without me noticing. The thumbs up was intended for the entirety of roberth's comment, so if you removed the sentence I think all is good!
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.
Cool thanks!
0476c4d
to
395fc06
Compare
Description of changes
This should be written down so we can refer to it.
This work is sponsored by Antithesis ✨
Add a 👍 reaction to pull requests you find important.