Skip to content
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

build: fail Travis if commit message check fails #32334

Closed

Conversation

mmarchini
Copy link
Contributor

"Allowed to fail" tests are easy to miss. With the failure on Travis,
new contributors can learn our commit guidelines. Collaborators are
still allowed (per our current policy) to land PRs where this check
fails, as long as the warnings are fixed before pushing to master.

Signed-off-by: Matheus Marchini [email protected]

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

"Allowed to fail" tests are easy to miss. With the failure on Travis,
new contributors can learn our commit guidelines. Collaborators are
still allowed (per our current policy) to land PRs where this check
fails, as long as the warnings are fixed before pushing to master.

Signed-off-by: Matheus Marchini <[email protected]>
@nodejs-github-bot nodejs-github-bot added the build Issues and PRs related to build files or the CI. label Mar 17, 2020
@richardlau

This comment has been minimized.

@mmarchini
Copy link
Contributor Author

One of the motivations behind this PR is preparing for nodejs/build#2201. If the commit message don't follow the guidelines, we can't use a commit queue to land it. And if a collaborator needs to manually update the commit message, it's easier to land with git node.

Also, we have a checklist item explicitly stating that the commit follow our guidelines. If folks are checking it without reading the guidelines, we could remove that item to keep the summary leaner. Or, if the guidelines are not clear, we should update them to be.

One of the assumptions from #31116 is that (at least some) folks will check the result from Travis. Not sure about others, but if CI shows green, I don't open it to double check. IMO if the check is allowed to fail, we can remove it (especially since #32336 uses Actions).

@mmarchini
Copy link
Contributor Author

On the other hand, I'm starting to question our strict validation of commit messages. While some basic linting makes sense (72 characters), I'm starting to feel we focus more on the format than the content of commit messages. I can't remember the last time I asked someone to add more information to a commit message, even when the commit message is not super descriptive.

I don't think I know any other projects with commit message rules as strict as ours. At most they enforce feat/chore/fix/doc, which is more common on the JavaScript ecosystem than submodule: message. Also, knowing which submodules are valid is hard for newcomers. And I'm not sure a commit message like doc,src,tools: is better than feat: or just some descriptive title. If we look at V8, they have a suggested style, but it is not enforced.

Maybe it's time to revisit our commit guidelines.

@targos
Copy link
Member

targos commented Mar 18, 2020

@mmarchini our commit title format is very strict because of how the changelog is generated using it.

@mmarchini
Copy link
Contributor Author

Right, but as a changelog reader, the tagging on several commit messages don't add extra value. Some examples from recent commits:

  • deps,doc: move openssl maintenance guide to doc could be move openssl maintenance guide to doc/
  • tools: update [email protected] could be update [email protected]
  • doc,lib,src,test: make --experimental-report a nop could be make --experimental-report a nop

I'm not saying the format is bad, I personally like it. But it seems hard for new contributors to get it right (and recently I landed PRs from collaborators where I had to fix the title, so even for us it's not entirely clear), adds extra burden to those landing pull requests, and can get in the way of an automated landing process.

On a somewhat related topic: would it be possible to automatically identify which subsystems changed based on which files were touched? If so, our testing could output a suggested commit message for the user.

@sam-github
Copy link
Contributor

People who only write code don't need to care about commit messages, and often don't, but speaking as someone who often is trying to figure why things are broken, consistently structured commit messages help me a lot.

Also, when the commit message description isn't well formatted, then its just pushing the work of writing up the commit description to the releasers when they prepare the changelogs, and that isn't fair. Or effective. Its the author of the commit who is best positioned to describe their change, and to do so in a consistent way.

In your example from above, I regularly scan commit logs visually, or with grep, and having consistent prefixes helps me a lot. This has a prefix:

deps,doc: move openssl maintenance guide to doc

This has a suffix, harder to scan:

move openssl maintenance guide to doc/

And it lacks a capital letter, the releasers would have to fix the punctuation when building the changelog.

Its true that authors seem to just tick the checkboxes off without reading, I'll avoid singling people out by linking to examples, but I think the best we can do here is to start failing PRs that don't follow the (well-advertised!) conventions.

We might also want to provide a pre-canned commit message comment pointing to conventions, if that's possible across the project. Though the commit message fail text already links to the docs on the convention, maybe they just need a bit of git rebase advice added, since how to find the correct prefix for a file is documented in the link from the github PR template: https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md#commit-message-guidelines

Check the output of git log --oneline files/you/changed to find out what subsystems your changes touch.

We could add "check the automatically applied labels" of the PR, but the currently doced advice is the best, and its not Node.js specific! I do one-off commits to a fair number of projects across the ecosystem, and I always run git log before writing my commit descriptions to see they match the house style.

@mmarchini
Copy link
Contributor Author

but speaking as someone who often is trying to figure why things are broken, consistently structured commit messages help me a lot.

This might vary from person to person, but consistent structure hasn't helped me when things are broken, meaningful messages did. And as I mentioned above, I think we are failing at enforcing meaningful messages.

Also, when the commit message description isn't well formatted, then its just pushing the work of writing up the commit description to the releasers when they prepare the changelogs, and that isn't fair.

I agree we should avoid pushing the work of writing descriptions to releasers. I believe this is a good enough reason to preserve the current format.

We might also want to provide a pre-canned commit message comment pointing to conventions

This would be interesting, except when folks commit with git commit -m "...", as it would bypass any pre-canned commit message. git config commit.template seems to do what you suggested though, but unfortunately users need to set it manually, which makes it less helpful...

Though the commit message fail text already links to the docs on the convention, maybe they just need a bit of git rebase advice added

We already have some git rebase advice (pull-requests.md#step-5-rebase), but it could be improved.

since how to find the correct prefix for a file is documented in the link from the github PR template: /doc/guides/contributing/pull-requests.md@master#commit-message-guidelines

Check the output of git log --oneline files/you/changed to find out what subsystems your changes touch.

I don't think this is clear enough for non-collaborators though.


I'm gonna try something with GitHub Actions, maybe we can get something similar to JS linter with annotations on the commit message, so folks have actionable things to fix on it?

@sam-github
Copy link
Contributor

I don't think this is clear enough for non-collaborators though.

Perhaps you can think of some improvements to the text. Willingness to use git is a pre-requisite to contributing to projects on github, IMO.

Anyhow, there are clearly variant opinions on whether commit messages should have conventions, just as there are projects that are perfectly happy to not have conventions on whitespace, or any other coding conventions. That's fair enough, but I'm personally OK with Node.js's stance on this.

I'd be stoked if someone updated make lint so that it linted all the commit messages added in the branch. That wouldn't help anyone who follows a make test; git commit -m "this is great"; git push flow, but it would help people who do git commit -m "this is great"; make test; git push, so it could give local on-machine feedback early.

@richardlau
Copy link
Member

On a somewhat related topic: would it be possible to automatically identify which subsystems changed based on which files were touched? If so, our testing could output a suggested commit message for the user.

Kind of. The Node.js GitHub bot does apply labels based on changed files (https://github.com/nodejs/github-bot/blob/master/lib/node-labels.js) although there isn't a 1:1 mapping between subsystems used in the commit messages and labels used in the web interface.

Despite its name core-validate-commit, which does the current commit message linting, doesn't currently look at anything beyond the commit message. Which isn't to say it couldn't in the future.

@mmarchini
Copy link
Contributor Author

I'll close this one since #32417 will probably have better results.

@mmarchini mmarchini closed this Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants