travis.rb icon indicating copy to clipboard operation
travis.rb copied to clipboard

Define pre-commit hook to help projects run `travis lint`

Open chriskuehl opened this issue 9 years ago • 6 comments

Howdy Travis folks!

pre-commit is a system for managing git pre-commit hooks. Projects can define a .pre-commit-config.yaml file in their root directory containing a list of hooks to run on commit and during tests (including in Travis CI).

pre-commit handles installation and version management of hooks (linters, fixers, and other code quality checks) in several languages. For example, a Python project can easily use a Ruby SCSS linter, without every developer having to worry about installing a specific version of Ruby or a Ruby gem.

A lot of projects are actually running pre-commit on Travis. It would be super convenient if they could run travis-yaml to validate their .travis.yml file as part of their testing.

With this change, projects would just need to add:

- repo: https://github.com/travis-ci/travis.rb.git
  sha: 438c81fd718bf105d11da0e9f32dd4c353c04281
  hooks:
     - id: travis-lint

...to their existing .pre-commit-config.yaml file, and they would automatically be able to take advantage of travis lint any time they change their travis.yml file.

Here's an example of what it looks like from a developer's perspective: developer example

(Normally you wouldn't ever run pre-commit manually except in CI; the first line is just an example.)

Here's an example of a Travis run where a developer is using pre-commit: https://travis-ci.org/Yelp/pgctl/builds/72168253#L216

Would be really cool to add this hook definition. Happy to answer any questions you have!

chriskuehl avatar Jul 26 '15 00:07 chriskuehl

Holly... I was trying to make a PR to implement the same feature and I discover that this 3 year of PR was totally ignored by travis team.

ssbarnea avatar Mar 14 '19 12:03 ssbarnea

Related to https://github.com/travis-ci/travis.rb/pull/307

It can easily be seen that my own work is almost identical with this PR -- https://github.com/ssbarnea/travis.rb/blob/master/.pre-commit-hooks.yaml

ssbarnea avatar Mar 14 '19 12:03 ssbarnea

I opened a support ticket asking for this to be reviewed and I encourage anyone interested by it to do the same.

ssbarnea avatar Mar 14 '19 13:03 ssbarnea

The work here seems to be finished. Can this PR be merged please ? :)

Lucas-C avatar Jul 24 '19 15:07 Lucas-C

Few more months, and we can commemorate the 4th anniversary of this PR. Clearly nobody from Travis gives a dime about community contributions. Is not as if someone had raised concerns about the PR, they didn't even look at it.

ssbarnea avatar Feb 08 '20 10:02 ssbarnea

Wow. Now 5th anniversary of this PR.

proinsias avatar Apr 09 '21 03:04 proinsias