A pre-commit hook in the form of a rubygem. Not published to rubgems.org.
Looks for a Travis yaml file and lints it, to protect against yaml errors or bad Travis configuration.
The linting logic itself uses the travis-yaml gem.
This gem is simply wiring between pre-commit and travis-yaml.
If your codebase builds on Travis, you can use this linting hook to make sure you don't commit a bad .travis.yml
.
Follow the instructions on http://pre-commit.com/. You will end up with a
.pre-commit-config.yaml
file something like:
repos:
- repo: git://github.com/alphagov/verify-travis-pre-commit-hook
sha: master
hooks:
- id: travis-yml-lint
Then you can do pre-commit install
.
Install rbenv
to make sure you are using the suggested ruby version.
Install bundler and the required gems:
gem install bundler
bundle install
To run the tests just use rake
.
To test the hook against a local codebase, use the try-repo command provided by pre-commit to run the hook from your local checkout:
pre-commit try-repo ../verify-travis-pre-commit-hook travis-yml-lint --verbose --all-files