Skip to content

Commit

Permalink
feat: Add support for multiple config files (#9)
Browse files Browse the repository at this point in the history
* fixes #8
- remove hard coded config file location
- trigger on any `.yml` file in `.circleci/`
- update readme for details on specifying config files

This is possible because by default, `circleci config validate` looks for a config file in `.circleci/config.yml`.

* fix grammar

* Use equal separated args over space separated
  • Loading branch information
nimakalantar authored Nov 23, 2022
1 parent 7b1bd92 commit 8e09e3b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- id: circleci_validate
name: Validate CircleCI config
description: This hook validate CircleCI config
description: This hook validates CircleCI config
entry: circleci_validate.sh
language: script
files: .circleci/config.yml
files: .circleci/.*.yml
pass_filenames: false
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $ cat .pre-commit-config.yaml

If you wish to pass additional args to circleci_validate, you can specify
them in the config. See `circleci config validate --help` for accepted args.
You must use the form `--arg=value`, not `--arg value`.

For example, to set an org-slug:
```bash
Expand All @@ -23,7 +24,18 @@ $ cat .pre-commit-config.yaml
hooks:
- id: circleci_validate
args:
- --org-slug my/organization
- --org-slug=my/organization
```

Or specify a custom config file:
```bash
$ cat .pre-commit-config.yaml
- repo: https://github.com/zahorniak/pre-commit-circleci.git
rev: v0.5 # Ensure this is the latest tag, comparing to the Releases tab
hooks:
- id: circleci_validate
args:
- .circleci/continue_config.yml
```

## 3. Install hook
Expand Down
2 changes: 1 addition & 1 deletion circleci_validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ then
exit 1
fi

if ! eMSG=$(circleci config validate "$@" -c .circleci/config.yml); then
if ! eMSG=$(circleci config validate "$@"); then
echo "CircleCI Configuration Failed Validation."
echo "${eMSG}"
exit 1
Expand Down

0 comments on commit 8e09e3b

Please sign in to comment.