-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d21c851
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- id: circleci-config-validate | ||
name: CircleCI config validator | ||
description: Validates CircleCI configuration files locally | ||
entry: hooks/circleci-config-validate.sh | ||
language: [script] | ||
files: ^.circleci/config.ya?ml$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Chase Pierce <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# git-hooks | ||
|
||
[pre-commit]: http://pre-commit.com/ | ||
|
||
A collection of useful Git hooks for integration with [pre-commit][]. | ||
|
||
## Usage | ||
|
||
Create or append to your `.pre-commit-config.yml` configuration: | ||
|
||
```yaml | ||
- repo: https://github.com/syntaqx/git-hooks | ||
hooks: | ||
- id: circleci-config-validate | ||
``` | ||
Then simply install or run the checks on-demand as desired. | ||
## License | ||
[MIT]: https://opensource.org/licenses/MIT | ||
`git-hooks` is open source software released under the [MIT license][MIT]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Test if the CircleCI config file is well formed via the circleci local cli. | ||
# https://circleci.com/docs/2.0/local-cli/ | ||
# https://circleci.com/blog/circleci-hacks-validate-circleci-config-on-every-commit-with-a-git-hook/ | ||
|
||
set -o errexit | ||
set -o pipefail | ||
set -o nounset | ||
|
||
readonly DEBUG=${DEBUG:-unset} | ||
[[ $DEBUG != unset ]] && set -x | ||
|
||
# assert the circleci command exists | ||
if ! [ -x "$(command -v circleci)" ]; then | ||
echo 'circleci command not found' | ||
echo 'See https://circleci.com/docs/2.0/local-cli/ for installation instructions.' | ||
exit 1 | ||
fi | ||
|
||
# The following is needed by the circleci local build tool (due to Docker interactivity) | ||
exec < /dev/tty | ||
|
||
# If validation fails, tell Git to stop and provide error message. Otherwise, continue. | ||
if ! msg=$(circleci config validate); then | ||
echo "CircleCI Configuration Failed Validation." | ||
echo "$msg" | ||
exit 1 | ||
fi |