Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update pre-commit to only run checks on affected files #407

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
#!/bin/bash

echo "Running .husky/pre-commit checks. Use -n/--no-verify to skip"
echo "------------------------------------------------------------"

npm run check-format
npm run prettier-check
npm run eslint
npm run markdown-link-check
npm run mdlint
npm run typecheck
npm run terraform-validate
npm test

function hasModifiedMatching() {
[[ -z "$1" ]] && echo "hasModifiedMatching needs arg" && return 1
git status --short --untracked-files=all --column=never | grep -q "$1"
return $?
}

# check for modified markdown?
if hasModifiedMatching '\.md$' ; then
echo "Markdown files modified... running checks"
npm run markdown-link-check
npm run mdlint
fi

if hasModifiedMatching ' src/' ; then
echo "src files modified... running checks"
npm run typecheck
npm test
fi


if hasModifiedMatching '\.tf$' ; then
echo "Terraform files modified... running checks"
npm run terraform-fmt-check
npm run terraform-validate
fi