travis.rb
travis.rb copied to clipboard
Define pre-commit hook to help projects run `travis lint`
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:
(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!
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.
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
I opened a support ticket asking for this to be reviewed and I encourage anyone interested by it to do the same.
The work here seems to be finished. Can this PR be merged please ? :)
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.
Wow. Now 5th anniversary of this PR.