/pre-commit-hooks

Pre commit hooks

Primary LanguageGoGNU Lesser General Public License v3.0LGPL-3.0

Latest Release Lint Test CD Best Practices pre-commit Conventional Commits KeepAChangelog

pre-commit-hooks

This repository is a collection of Git hooks to be used with the pre-commit framework.

Features

TODO

Installation

Base

  1. Install pre-commit. E.g. brew install pre-commit

MacOS

  1. Install Terraform, TFLint, Go, markdown-link-check, shellcheck. E.g
  brew install terraform \
      tflint \
      go \
      golangci/tap/golangci-lint \
      shellcheck && \
      yarn global add markdown-link-check

Linux

Usage

How to use this project

Examples

Example: Run All Hooks

pre-commit run --all-files

Example: Run A Specific Hook

pre-commit run terraform-validate --all-files

terraform:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: terraform-fmt
      - id: terraform-validate
      - id: terraform-docs
        args:
          - '--output-file=docs/include/terraform.md'
          - '--output-mode=replace'
          - '--sort-by-type'
      - id: terraform-docs-replace
      - id: terraform-tflint
      - id: terraform-tfsec
      - id: checkov

terragrunt:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: terragrunt-fmt
      - id: terraform-validate

markdown:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: markdown-link-check
        args:
          - '--config=markdown-config.json'

shell:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: shellcheck

Go:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: go-fmt
      - id: go-imports
      - id: go-vet
      - id: golint
      - id: gocyclo
      - id: validate-toml
      - id: no-go-testing
      - id: golangci-lint
      - id: go-critic
      - id: go-unit-tests
      - id: go-build
      - id: go-mod-tidy
      - id: go-mod-vendor

check:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: todocheck

grep:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: do-not-commit

docker:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: hadolint
        args:
          - --config=.ci/linters/.hadolint.yaml

docker-compose:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: docker-compose-check

gitleaks:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: gitleaks
        args:
          - --path=.
          - --repo-config-path=.ci/linters/.gitleaks.toml
          - --verbose

prepare-commit-msg:

repos:
  - repo: https://github.com/hadenlabs/pre-commit-hooks
    rev: 0.4.0
    hooks:
      - id: prepare-commit-msg
        stages: [prepare-commit-msg]

Help

Got a question?

File a GitHub issue.

Contributing

See Contributing.

Module Versioning

This Module follows the principles of Semantic Versioning (SemVer).

Using the given version number of MAJOR.MINOR.PATCH, we apply the following constructs:

  1. Use the MAJOR version for incompatible changes.
  2. Use the MINOR version when adding functionality in a backwards compatible manner.
  3. Use the PATCH version when introducing backwards compatible bug fixes.

Backwards compatibility in 0.0.z and 0.y.z version

  • In the context of initial development, backwards compatibility in versions 0.0.z is not guaranteed when z is increased. (Initial development)
  • In the context of pre-release, backwards compatibility in versions 0.y.z is not guaranteed when y is increased. (Pre-release)

Copyright

Copyright © 2018-2022 Hadenlabs

Trademarks

All other trademarks referenced herein are the property of their respective owners.

License

The code and styles are licensed under the LGPL-3.0 license See project license..

Don't forget to 🌟 Star 🌟 the repo if you like pre-commit-hooks

Your feedback is appreciated