{"id":21834635,"url":"https://github.com/mineiros-io/pre-commit-hooks","last_synced_at":"2025-04-14T08:51:43.582Z","repository":{"id":42024558,"uuid":"232107712","full_name":"mineiros-io/pre-commit-hooks","owner":"mineiros-io","description":"A collection of pre-commit-hooks the Mineiros Infrastructure as Code (IaC) library.","archived":false,"fork":false,"pushed_at":"2024-02-13T13:55:39.000Z","size":136,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-27T22:22:33.768Z","etag":null,"topics":["iac","mineiros","pre-commit","pre-commit-hooks"],"latest_commit_sha":null,"homepage":"https://mineiros.io/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mineiros-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-01-06T13:33:12.000Z","updated_at":"2024-11-19T20:54:14.000Z","dependencies_parsed_at":"2024-02-13T14:25:00.584Z","dependency_job_id":"19fe2ce4-7110-4897-825f-cabf79fbc726","html_url":"https://github.com/mineiros-io/pre-commit-hooks","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mineiros-io%2Fpre-commit-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mineiros-io%2Fpre-commit-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mineiros-io%2Fpre-commit-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mineiros-io%2Fpre-commit-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mineiros-io","download_url":"https://codeload.github.com/mineiros-io/pre-commit-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852084,"owners_count":21171837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iac","mineiros","pre-commit","pre-commit-hooks"],"created_at":"2024-11-27T20:13:39.933Z","updated_at":"2025-04-14T08:51:43.562Z","avatar_url":"https://github.com/mineiros-io.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg src=\"https://raw.githubusercontent.com/mineiros-io/brand/3bffd30e8bdbbde32c143e2650b2faa55f1df3ea/mineiros-primary-logo.svg\" width=\"400\"/\u003e](https://www.mineiros.io/?ref=pre-commit-hooks)\n\n[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/mineiros-io/pre-commit-hooks.svg?label=latest\u0026sort=semver)](https://github.com/mineiros-io/pre-commit-hooks/releases)\n[![license](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Terraform Version](https://img.shields.io/badge/terraform-~%3E%200.12.20-623CE4.svg)](https://github.com/hashicorp/terraform/releases)\n[\u003cimg src=\"https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack\"\u003e](https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg)\n\n# pre-commit-hooks\n\nThis repository is a collection of Git hooks to be used with the\n[pre-commit](https://pre-commit.com/) framework.\n\n- [Available Hooks](#available-hooks)\n  - [Terraform](#terraform)\n  - [Go](#go)\n  - [GNU Make](#gnu-make)\n  - [Markdown](#markdown)\n  - [Bash](#bash)\n- [Installation \u0026 Dependencies](#installation--dependencies)\n- [Usage](#usage)\n  - [Run](#run)\n    - [Example: Run All Hooks](#example-run-all-hooks)\n    - [Example: Run A Specific Hook](#example-run-a-specific-hook)\n  - [Pre-Commit and Continuous Integration](#pre-commit-and-continuous-integration)\n  - [Add Custom Hooks](#add-custom-hooks)\n- [Module Versioning](#module-versioning)\n  - [Backwards compatibility in `0.0.z` and `0.y.z` version](#backwards-compatibility-in-00z-and-0yz-version)\n- [About Mineiros](#about-mineiros)\n- [Reporting Issues](#reporting-issues)\n- [Contributing](#contributing)\n- [Makefile Targets](#makefile-targets)\n- [License](#license)\n\n## Available Hooks\n\nCurrently, the following hooks are supported:\n\n### Terraform\n\n- [terraform-fmt](https://www.terraform.io/docs/commands/fmt.html): The terraform fmt command is used to rewrite\n  Terraform configuration `*.tf` files to a canonical format and style.\n- [terraform-validate](https://www.terraform.io/docs/commands/validate.html): The terraform validate command validates\n  all Terraform configuration `*.tf` files, referring only to the configuration and not accessing any remote services\n  such as remote state, provider APIs, etc.\n- [tflint](https://github.com/terraform-linters/tflint): TFLint is a Terraform linter focused on possible errors, best\n  practices, etc. (Terraform \u003e= 0.12). Applied to all Terraform configuration `*.tf` files.\n\n### Go\n\n- [golangci-lint](https://github.com/golangci/golangci-lint): GolangCI-Lint is a linters aggregator.\n  It's fast: on average 5 times faster than gometalinter. It's easy to integrate and use, has nice output and has a\n  minimum number of false positives. An example configuration can be found in\n  [.golangci.example.yml](https://github.com/mineiros-io/pre-commit-hooks/blob/master/.golangci.example.yml).\n\n#### The following hooks can be configured through golangci-lint and are therefore redundant when golangci-lint is being used\n\n- [gofmt](https://golang.org/cmd/gofmt/): Go fmt is a tool that automatically formats Go `*.go` files to canonical\n  format and style.\n- [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports): The goimports command updates import lines in Go\n  `*.go` files, adding missing ones and removing unreferenced ones.\n\n### GNU Make\n\n- [phony-targets](https://github.com/mineiros-io/pre-commit-hooks/blob/master/pre_commit_hooks/make/phony-targets.sh):\n  This hook validates if targets that are marked as `PHONY` actually exist.\n\n### Markdown\n\n- [markdown-link-check](https://github.com/tcort/markdown-link-check): Validates that all hyperlinks in a markdown\n  text alive or dead.\n\n### Bash\n\n- [shellcheck](https://github.com/koalaman/shellcheck): ShellCheck is a GPLv3 tool that gives warnings and suggestions\n  for bash/sh shell scripts.\n\n### Terradoc\n\n- [terradoc-fmt](https://github.com/mineiros-io/terradoc): The terradoc fmt command is used to rewrite Terradoc\n    configuration configuration `*.tfdoc.hcl` files to a canonical format and\n    style.\n- [terradoc-generate](https://github.com/mineiros-io/terradoc): The terradoc generate command generates a markdown document\n    from Terradoc configuration `*.tfdoc.hcl` files.\n- [terradoc-validate](https://github.com/mineiros-io/terradoc): The terradoc validate command is used validate Terradoc\n    configuration in `README.tfdoc.hcl` file against Terraform variable\n    definitions.\n\n### Terramate\n\n- [terramate-fmt](https://github.com/mineiros-io/terramate): The terramate generate command formats code in Terramate configuration files.\n- [terramate-generate](https://github.com/mineiros-io/terramate): The terramate generate command generates code from Terramate configuration files.\n\n## Installation \u0026 Dependencies\n\n1. Install [pre-commit](https://pre-commit.com/). E.g. `brew install pre-commit`\n1. Install [Terraform](https://www.terraform.io/), [TFLint](https://github.com/terraform-linters/tflint),\n   [Go](https://golang.org/), [markdown-link-check](https://github.com/tcort/markdown-link-check),\n   [shellcheck](https://github.com/koalaman/shellcheck). E.g\n\n   ```shell script\n     brew install terraform \\\n         tflint \\\n         go \\\n         golangci/tap/golangci-lint \\\n         shellcheck \u0026\u0026 \\\n         npm install -g markdown-link-check \u0026\u0026 \\\n         go install github.com/mineiros-io/terradoc/cmd/terradoc@latest\n   ```\n\n## Usage\n\nCreate a `.pre-commit-config.yaml` inside your repositories and add the desired list of hooks.\nPlease see the [documentation](https://pre-commit.com/#usage) for further information.\n\n```yaml\nrepos:\n  - repo: https://github.com/mineiros-io/pre-commit-hooks\n    rev: \u003cVERSION\u003e # Check for the latest version: https://github.com/mineiros-io/pre-commit-hooks/releases\n    hooks:\n      - id: terraform-fmt\n      - id: terraform-validate\n      - id: tflint\n      - id: golangci-lint\n      - id: phony-targets\n      - id: markdown-link-check\n        args: [-p] # When adding the -p flag, markdown-link-check will always with an exit code 0, even if dead links are found\n      - id: shellcheck\n      - id: terradoc-validate\n      - id: terradoc-fmt\n      - id: terradoc-generate\n      - id: terramate-generate\n\n      # The following hooks are redundant when golangci-lint is being. Our recommendation is to use golangci-lint\n      # as the main linter for go since it enables you to run all available linters in parallel.\n      # For details please see the example configuration https://github.com/mineiros-io/pre-commit-hooks/blob/master/.golangci.example.yml\n      # - id: gofmt\n      # - id: goimports\n```\n\nOnce you created the configuration file inside your repository, you must run `pre-commit install` to activate the hooks.\nThat's it, pre-commit will now listen for changes in your files and run the checks accordingly.\n\n### Run\n\nIt's usually a good idea to run the hooks against all of the files when adding new hooks (usually pre-commit will only\nrun on the changed files during git hooks).\n\n#### Example: Run All Hooks\n\n```shell script\npre-commit run --all-files\n```\n\n#### Example: Run A Specific Hook\n\n```shell script\npre-commit run terraform-validate --all-files\n```\n\n### Pre-Commit and Continuous Integration\n\nIt's recommended to run pre-commit as part of CI pipeline/build as there will be always that one rebel in the team\nwho won't run them locally. On CI, replace `pre-commit install` by `pre-commit run -a`. We don't need to install it on\nCI as it'll be a one-shot operation. run -a will run the hooks over all files (taking into account excludes if\nconfigured).\n\n### Add Custom Hooks\n\nAll `*.sh` files inside pre_commit_hooks need to be flagged as executable. Otherwise the pre-commit hooks won't be\nexecutable by default. You apply the flag to all `*.sh` files with the following command:\n\n```bash\nfind pre_commit_hooks/ -type f -iname \"*.sh\" -exec chmod +x {} \\;\n```\n\n## Module Versioning\n\nThis Module follows the principles of [Semantic Versioning (SemVer)](https://semver.org/).\n\nUsing the given version number of `MAJOR.MINOR.PATCH`, we apply the following constructs:\n\n1. Use the `MAJOR` version for incompatible changes.\n1. Use the `MINOR` version when adding functionality in a backwards compatible manner.\n1. Use the `PATCH` version when introducing backwards compatible bug fixes.\n\n### Backwards compatibility in `0.0.z` and `0.y.z` version\n\n- In the context of initial development, backwards compatibility in versions `0.0.z` is **not guaranteed** when `z` is\n  increased. (Initial development)\n- In the context of pre-release, backwards compatibility in versions `0.y.z` is **not guaranteed** when `y` is\n  increased. (Pre-release)\n\n## About Mineiros\n\nMineiros is a [DevOps as a Service](https://mineiros.io/?ref=pre-commit-hooks) company based in Berlin, Germany. We offer commercial support\nfor all of our projects and encourage you to reach out if you have any questions or need help.\nFeel free to send us an email at [hello@mineiros.io](mailto:hello@mineiros.io).\n\nWe can also help you with:\n\n- Terraform modules for all types of infrastructure such as VPCs, Docker clusters, databases, logging and monitoring, CI, etc.\n- Consulting \u0026 training on AWS, Terraform and DevOps\n\n## Reporting Issues\n\nWe use GitHub [Issues](https://github.com/mineiros-io/pre-commit-hooks/issues)\nto track community reported issues and missing features.\n\n## Contributing\n\nContributions are always encouraged and welcome! For the process of accepting changes, we use\n[Pull Requests](https://github.com/mineiros-io/pre-commit-hooks/pulls). If you'd like more information, please\nsee our [Contribution Guidelines](https://github.com/mineiros-io/pre-commit-hooks/blob/master/CONTRIBUTING.md).\n\n## Makefile Targets\n\nThis repository comes with a handy\n[Makefile](https://github.com/mineiros-io/pre-commit-hooks/blob/master/Makefile).\nRun `make help` to see details on each available target.\n\n## License\n\nThis module is licensed under the Apache License Version 2.0, January 2004.\nPlease see [LICENSE](https://github.com/mineiros-io/pre-commit-hooks/blob/master/LICENSE) for full details.\n\nCopyright \u0026copy; 2020 Mineiros GmbH\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmineiros-io%2Fpre-commit-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmineiros-io%2Fpre-commit-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmineiros-io%2Fpre-commit-hooks/lists"}