An open API service indexing awesome lists of open source software.

https://github.com/hadenlabs/pre-commit-hooks

Pre commit hooks
https://github.com/hadenlabs/pre-commit-hooks

git hadenlabs iac peru pre-commit pre-commit-hook python

Last synced: 8 months ago
JSON representation

Pre commit hooks

Awesome Lists containing this project

README

          

[![Latest Release](https://img.shields.io/github/release/hadenlabs/pre-commit-hooks)](https://github.com/hadenlabs/pre-commit-hooks/releases) [![Lint](https://img.shields.io/github/workflow/status/hadenlabs/pre-commit-hooks/lint-code)](https://github.com/hadenlabs/pre-commit-hooks/actions?workflow=lint-code) [![Test](https://img.shields.io/github/workflow/status/hadenlabs/pre-commit-hooks/test)](https://github.com/hadenlabs/pre-commit-hooks/actions?workflow=test) [![CD](https://img.shields.io/github/workflow/status/hadenlabs/pre-commit-hooks/cd)](https://github.com/hadenlabs/pre-commit-hooks/actions?workflow=cd) [![Best Practices](https://bestpractices.coreinfrastructure.org/projects/5156/badge)](https://bestpractices.coreinfrastructure.org/projects/5156) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow)](https://conventionalcommits.org) [![KeepAChangelog](https://img.shields.io/badge/changelog-Keep%20a%20Changelog%20v1.0.0-orange)](https://keepachangelog.com)

# pre-commit-hooks

This repository is a collection of Git hooks to be used with the [pre-commit](https://pre-commit.com/) framework.

## Features

- [Terraform](https://github.com/terraform-linters/tflint)
- [Go](https://golang.org)
- [Markdown](https://github.com/tcort/markdown-link-check)
- [Shellcheck](https://github.com/koalaman/shellcheck)
- [Hadolint](https://github.com/hadolint/hadolint)

## TODO

- [chore: implement hook gnu make](https://github.com/hadenlabs/pre-commit-hooks/issues/2)

## Installation

### Base

1. Install [pre-commit](https://pre-commit.com/). E.g. `brew install pre-commit`

### MacOS

1. Install [Terraform](https://www.terraform.io/), [TFLint](https://github.com/terraform-linters/tflint), [Go](https://golang.org/), [markdown-link-check](https://github.com/tcort/markdown-link-check), [shellcheck](https://github.com/koalaman/shellcheck). E.g

```shell script
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

```shell script
pre-commit run --all-files
```

### Example: Run A Specific Hook

```shell script
pre-commit run terraform-validate --all-files
```

### terraform:

```yaml
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:

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

### markdown:

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

### shell:

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

### Go:

```yaml
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:

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

### grep:

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

### docker:

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

### docker-compose:

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

### gitleaks:

```yaml
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:

```yaml
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](https://github.com/hadenlabs/pre-commit-hooks/issues).

## Contributing

See [Contributing](./docs/contributing.md).

## Module Versioning

This Module follows the principles of [Semantic Versioning (SemVer)](https://semver.org/).

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

1. Use the `MAJOR` version for incompatible changes.
1. Use the `MINOR` version when adding functionality in a backwards compatible manner.
1. 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](https://hadenlabs.com)

## 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.](LICENSE).

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

[Your feedback is appreciated](https://github.com/hadenlabs/pre-commit-hooks/issues)