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

Add pre-commit hook configuration #2326

Merged
merged 4 commits into from
May 30, 2024
Merged

Add pre-commit hook configuration #2326

merged 4 commits into from
May 30, 2024

Conversation

wiktorn
Copy link
Collaborator

@wiktorn wiktorn commented May 30, 2024

Adding this for those who are forgetful as me, to run terraform fmt or tools/tfdoc.py on changed files.

As of now configuration includes following linters.

  • Terraform:
    • terraform fmt
    • terraform tflint
  • Python specific:
    • yapf
  • Shell scripts
    • shellcheck
    • shfmt
  • YAML files:
    • yamllint (disabled as of now)
    • check-yaml
  • Other:
    • end-of-file-fixer
    • trailing-whitespace fixer
  • Fabric specific
    • tools/tfdoc.py
    • tools/check_boilerplate.py

The checks that are raising most issues in our repo are:

  • end-of-file-fixer
  • trailing-whitespace fixer
  • shellfmt
  • shellcheck

Out of those, only shellcheck requires manual fixes, all other 3 above just apply the fix themselves. Shellcheck is controversial so we may want to disable it.

If you want to check the changes the linters introduce run pre-commit run -a to see all effect on the whole repo. When installed, pre-commit hook runs only on changed files in the commit.


Checklist

I applicable, I acknowledge that I have:

  • Read the contributing guide
  • 😁 Ran terraform fmt on all modified files
  • 😁 Regenerated the relevant README.md files using tools/tfdoc.py
  • Made sure all relevant tests pass

wiktorn added 3 commits May 30, 2024 14:22
Run following linters on commit:
Terraform:
- terraform fmt
- terraform tflint

Python specific:
- yapf

Shell scripts
- shellcheck
- shfmt

YAML files:
- yamllint (disabled as of now)
- check-yaml

Other:
- end-of-file-fixer
- trailing-whitespace fixer

Fabric specific
- tools/tfdoc.py
- tools/check_boilerplate.py
@github-actions github-actions bot added on:tools New or changed tool on:blueprints labels May 30, 2024
@juliocc juliocc merged commit f8f1873 into master May 30, 2024
13 checks passed
@juliocc juliocc deleted the wiktorn-pre-commit branch May 30, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on:blueprints on:tools New or changed tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants