★ wanayoo — archive 1999 https://github.com/nodejs/node/pull/24030Nouvelle recherche | Portail wanayoo
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

tools: add script to lint first PR commit message #24030

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
6 participants
@richardlau
Copy link
Member

commented Nov 2, 2018

Decouple first commit in pull request linting from Travis by using
the GitHub API to work out the first commit.

The shell script obtains the pull request number in one of the
following ways:

  1. supplied on the command line (use this to test against any PR)
  2. TRAVIS_PULL_REQUEST if set and != "false"
  3. derived from the HEAD commit via the GitHub API

The GitHub API should be more consistent with the web UI in terms of finding
the first commit for a pull request.

This is an alternative to #23758 with the bonus that
you can run the script against any pull request number.

Checklist

@richardlau richardlau referenced this pull request Nov 2, 2018

Closed

tools: add script to lint commit messages #23758

1 of 1 task complete
@richardlau

This comment has been minimized.

Copy link
Member Author

commented Nov 2, 2018

Examples:

Run locally, no pull request specified (script works out based on current HEAD commit):

-bash-4.2$ bash tools/lint-pr-commit-message.sh
Linting the first commit message for pull request 24030
according to the guidelines at https://goo.gl/p2fr5Q.
Commit message for 826115ee852b8aef3dd6e9578c8b0190605c0e98 is:
tools: add script to lint first PR commit message

Decouple first commit in pull request linting from Travis by using
the GitHub API to work out the first commit.

The shell script obtains the pull request number in one of the
following ways:
 1) supplied on the command line (use this to test against any PR)
 2) TRAVIS_PULL_REQUEST if set and != "false"
 3) derived from the HEAD commit via the GitHub API
  ✔  826115ee852b8aef3dd6e9578c8b0190605c0e98
     ✔  0:0      skipping fixes-url                        fixes-url
     ✔  0:0      blank line after title                    line-after-title
     ✔  0:0      line-lengths are valid                    line-length
     ✔  0:0      valid subsystems                          subsystem
     ✔  0:0      Title is formatted correctly.             title-format
     ✔  0:0      Title is <= 50 columns.                   title-length
-bash-4.2$

Checking a completely different PR:

-bash-4.2$ bash tools/lint-pr-commit-message.sh 23758
Linting the first commit message for pull request 23758
according to the guidelines at https://goo.gl/p2fr5Q.
Commit message for fa99a11b207932c6d02ccfc9e8308984ed0f1f76 is:
tools: add script to lint commit messages

This script attempts to guess the target upstream branch.
To manually specify, e.g. to target `canary-base`:
  TARGET_BRANCH=canary-base bash lint-commit-message.sh
  ✔  fa99a11b207932c6d02ccfc9e8308984ed0f1f76
     ✔  0:0      skipping fixes-url                        fixes-url
     ✔  0:0      blank line after title                    line-after-title
     ✔  0:0      line-lengths are valid                    line-length
     ✔  0:0      valid subsystems                          subsystem
     ✔  0:0      Title is formatted correctly.             title-format
     ✔  0:0      Title is <= 50 columns.                   title-length
-bash-4.2$

On Travis (for this PR), https://travis-ci.com/nodejs/node/jobs/155889224:
image

@refack refack added build meta labels Nov 2, 2018

Show resolved Hide resolved tools/lint-pr-commit-message.sh Outdated
tools: add script to lint first PR commit message
Decouple first commit in pull request linting from Travis by using
the GitHub API to work out the first commit.

The shell script obtains the pull request number in one of the
following ways:
 1) supplied on the command line (use this to test against any PR)
 2) derived from the HEAD commit via the GitHub API

@richardlau richardlau force-pushed the richardlau:pr-commit-lint branch from 826115e to 38f2b1e Nov 2, 2018

@richardlau

This comment has been minimized.

Copy link
Member Author

commented Nov 2, 2018

Moved the Travis specific stuff out of the script back into .travis.yml.

@richardlau

This comment has been minimized.

Copy link
Member Author

commented Nov 2, 2018

Longer term we could teach core-validate-commit:

  1. to take a PR argument and lint all the commits for that PR (as determined by GitHub's API)
  2. to ignore "fixup!" and "squash!" commit messages

and then replace the shell script here with a direct call to npx -q core-validate-commit ....

@refack

refack approved these changes Nov 2, 2018

@Trott

Trott approved these changes Nov 4, 2018

@Trott Trott added the author ready label Nov 4, 2018

@Trott

This comment has been minimized.

Trott added a commit to Trott/io.js that referenced this pull request Nov 4, 2018

tools: add script to lint first PR commit message
Decouple first commit in pull request linting from Travis by using
the GitHub API to work out the first commit.

The shell script obtains the pull request number in one of the
following ways:
 1) supplied on the command line (use this to test against any PR)
 2) derived from the HEAD commit via the GitHub API

PR-URL: nodejs#24030
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@Trott

This comment has been minimized.

Copy link
Member

commented Nov 4, 2018

Landed in 7489ee8

@Trott Trott closed this Nov 4, 2018

@addaleax

This comment has been minimized.

Copy link
Member

commented Nov 4, 2018

@Trott @richardlau This seems to have broken Travis CI for non-PR branches without TRAVIS_PULL_REQUEST?

addaleax added a commit to addaleax/node that referenced this pull request Nov 4, 2018

build: do not lint on non-PR Travis builds
Do not run any linting at all when `TRAVIS_PULL_REQUEST` is `false`.
This would otherwise break Travis CI for `master` and release branches.

Refs: nodejs#24030

@addaleax addaleax referenced this pull request Nov 4, 2018

Closed

build: do not lint on non-PR Travis builds #24076

2 of 2 tasks complete

Trott added a commit to Trott/io.js that referenced this pull request Nov 4, 2018

build: do not lint on non-PR Travis builds
Do not run any linting at all when `TRAVIS_PULL_REQUEST` is `false`.
This would otherwise break Travis CI for `master` and release branches.

Refs: nodejs#24030

PR-URL: nodejs#24076
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

@richardlau richardlau deleted the richardlau:pr-commit-lint branch Nov 5, 2018

targos added a commit that referenced this pull request Nov 5, 2018

tools: add script to lint first PR commit message
Decouple first commit in pull request linting from Travis by using
the GitHub API to work out the first commit.

The shell script obtains the pull request number in one of the
following ways:
 1) supplied on the command line (use this to test against any PR)
 2) derived from the HEAD commit via the GitHub API

PR-URL: #24030
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

targos added a commit that referenced this pull request Nov 5, 2018

build: do not lint on non-PR Travis builds
Do not run any linting at all when `TRAVIS_PULL_REQUEST` is `false`.
This would otherwise break Travis CI for `master` and release branches.

Refs: #24030

PR-URL: #24076
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

@BridgeAR BridgeAR referenced this pull request Nov 14, 2018

Merged

Release proposal: v11.2 #24350

codebytere added a commit that referenced this pull request Nov 29, 2018

tools: add script to lint first PR commit message
Decouple first commit in pull request linting from Travis by using
the GitHub API to work out the first commit.

The shell script obtains the pull request number in one of the
following ways:
 1) supplied on the command line (use this to test against any PR)
 2) derived from the HEAD commit via the GitHub API

PR-URL: #24030
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

codebytere added a commit that referenced this pull request Nov 29, 2018

build: do not lint on non-PR Travis builds
Do not run any linting at all when `TRAVIS_PULL_REQUEST` is `false`.
This would otherwise break Travis CI for `master` and release branches.

Refs: #24030

PR-URL: #24076
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

MylesBorins added a commit that referenced this pull request Nov 29, 2018

tools: add script to lint first PR commit message
Decouple first commit in pull request linting from Travis by using
the GitHub API to work out the first commit.

The shell script obtains the pull request number in one of the
following ways:
 1) supplied on the command line (use this to test against any PR)
 2) derived from the HEAD commit via the GitHub API

PR-URL: #24030
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

MylesBorins added a commit that referenced this pull request Nov 29, 2018

build: do not lint on non-PR Travis builds
Do not run any linting at all when `TRAVIS_PULL_REQUEST` is `false`.
This would otherwise break Travis CI for `master` and release branches.

Refs: #24030

PR-URL: #24076
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

@codebytere codebytere referenced this pull request Nov 29, 2018

Merged

v10.14.2 proposal #24727

MylesBorins added a commit that referenced this pull request Dec 3, 2018

tools: add script to lint first PR commit message
Decouple first commit in pull request linting from Travis by using
the GitHub API to work out the first commit.

The shell script obtains the pull request number in one of the
following ways:
 1) supplied on the command line (use this to test against any PR)
 2) derived from the HEAD commit via the GitHub API

PR-URL: #24030
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

MylesBorins added a commit that referenced this pull request Dec 3, 2018

build: do not lint on non-PR Travis builds
Do not run any linting at all when `TRAVIS_PULL_REQUEST` is `false`.
This would otherwise break Travis CI for `master` and release branches.

Refs: #24030

PR-URL: #24076
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.