-
-
Notifications
You must be signed in to change notification settings - Fork 568
Description
Some hooks recursively check all files in provided dir.
So performance degradation exists only in the pre-commit run --all
situation, because it will provide all existing repo files to hook:
pre-commit-terraform/terrascan.sh
Lines 15 to 19 in e6ffbcd
# consume modified files passed from pre-commit so that | |
# terrascan runs against only those relevant directories | |
for file_with_path in "${files[@]}"; do | |
file_with_path="${file_with_path// /__REPLACED__SPACE__}" | |
paths[index]=$(dirname "$file_with_path") |
Then, unique paths are found and run terrascan
for each repo folder:
pre-commit-terraform/terrascan.sh
Lines 29 to 30 in e6ffbcd
# for each path run terrascan | |
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do |
It works literally how it should work: checks only diffs.
So, good to know when the --all
(-a
) argument passed to pre-commit
and just run terrascan -d GIT_REPO_ROOT
, not all-all dirs.
Useful info
-
pre-commit
automatically parallel checks to exiting cores, so you need to run tests on a repo that has at least 2x more tf-dirs than CPU cores you have. If you have not so big repo - just copy-paste code-structure a few times, and you'll get needed. -
Create solution as function, that can be called from
terrascan_()
hook function and depends on the result, inif
run other flow and stop execution withexit 0
-
checkov
run checks recursively. need-d GIT_REPO_POOT_PATH
feat: Addterraform_checkov
, that run per folder. Deprecatecheckov
hook #290 -
tfsec
runs recursively without any additional args. feat: Improved speed ofpre-commit run -a
for multiple hooks #338 -
terragrunt_fmt
(terragrunt hclfmt
) runs recursively without any additional args. feat: Improved speed ofpre-commit run -a
for multiple hooks #338 -
terrascan
runs recursively without any additional args. feat:terrascan
- Improve performance duringpre-commit --all (-a)
run #327 -
terragrunt_validate
have optionterragrunt run-all validate
that run checks recursively. feat: Improved speed ofpre-commit run -a
for multiple hooks #338
Founded in #305