|
| 1 | +# Pre-commit Automation Tools 🔧 |
| 2 | +A comprehensive suite of Git hooks and development environment setup tools that enforce code quality, formatting standards, and conventional commits across your projects. |
| 3 | + |
| 4 | +## Table of Contents 📋 |
| 5 | + |
| 6 | +- [Overview](#overview) |
| 7 | +- [Prerequisites](#prerequisites) |
| 8 | +- [Installation](#installation) |
| 9 | +- [Skipping Pre-commit Hooks](#skipping-pre-commit-hooks) |
| 10 | +- [Maintainers](#maintainers) |
| 11 | +- [Contributing](#contributing) |
| 12 | +- [Credits](#credits) |
| 13 | +- [License](#license) |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +## Overview |
| 18 | +This toolkit provides automated setup and enforcement of development best practices through: |
| 19 | + |
| 20 | +- Code formatting and linting |
| 21 | +- Security scanning |
| 22 | +- Conventional commit message enforcement |
| 23 | +- Development environment standardization across multiple projects |
| 24 | + |
| 25 | +## OS Requirements |
| 26 | +- **Linux:** Above Linux 4.16.10-300.fc28.x86_64 x86_64 |
| 27 | +- **MacOS:** Above Mac OS X 10.7 Lion |
| 28 | + |
| 29 | +## Prerequisites |
| 30 | +- ```sudo``` may be required depending on your system configuration |
| 31 | +- git (version control) |
| 32 | +## Installation Tools |
| 33 | +The following tools will be automatically installed during setup: |
| 34 | + |
| 35 | +- asdf (version manager) |
| 36 | +- Node.js |
| 37 | +- python |
| 38 | +- typescript |
| 39 | +- black 23.9.1 |
| 40 | +- Golang |
| 41 | +- terraform |
| 42 | +- tflint 0.39.2 |
| 43 | +- tfsec 1.28.1 |
| 44 | +- terraform-docs 0.16.0 |
| 45 | +- pre-commit 3.3.3 |
| 46 | +- yamlfmt 0.14.0 |
| 47 | +- prettier |
| 48 | +- codespell 2.2.5 |
| 49 | +- gitleaks 8.21.0 |
| 50 | + |
| 51 | + |
| 52 | +## Installation |
| 53 | + |
| 54 | +1. Clone this repository |
| 55 | +``` |
| 56 | +git clone git@github.com:BerryBytes/precommit-util.git |
| 57 | +``` |
| 58 | + |
| 59 | +2. Make the precommit-startup.sh executable: |
| 60 | +``` |
| 61 | +chmod +x precommit-startup.sh |
| 62 | +``` |
| 63 | +3. Run the startup script: |
| 64 | +``` |
| 65 | +./precommit-startup.sh |
| 66 | +``` |
| 67 | +4. Choose the pre-commit hooks you want to install: |
| 68 | +``` |
| 69 | +
|
| 70 | +[1] Golang pre-commit hooks |
| 71 | +[2] Python pre-commit hooks |
| 72 | +[3] Terraform pre-commit hooks |
| 73 | +[4] TypeScript pre-commit hooks |
| 74 | +[5] Exit |
| 75 | +``` |
| 76 | +5. Ensure that you provide the correct version of [nodejs/golang/python/terraform] instead of "latest" before proceeding. |
| 77 | +6. After installation, the githooks template will be set up globally for all repositories. |
| 78 | + |
| 79 | +7. Note that the setup is only required for new repositories. Existing repositories will not automatically adopt these hooks. To set up the hooks for an existing repository: |
| 80 | + - You will need to manually reinitialize the repository with `git init` to apply the template. |
| 81 | + |
| 82 | + OR |
| 83 | + |
| 84 | + - Clone the existing repository to your local machine again to adopt the hooks automatically. |
| 85 | + |
| 86 | + |
| 87 | +8. After initializing / cloning the repository, make changes to the codebase and commit them. The pre-commit hooks will automatically run and enforce the code quality standards. |
| 88 | + |
| 89 | + |
| 90 | +## Skipping Pre-commit Hooks |
| 91 | + |
| 92 | +To ignore specific pre-commit hooks for a specific file, you can modify the .pre-commit-config.yaml file by adding an `exclude` pattern under the specific hook configuration. |
| 93 | + |
| 94 | +For example, to exclude the main.yaml file from the check-yaml hook, add the following line to the .pre-commit-config.yaml file: |
| 95 | + |
| 96 | +a. Exclude a file (main.yaml is excluded) |
| 97 | + |
| 98 | +``` |
| 99 | +repos: |
| 100 | +- repo: https://github.com/pre-commit/pre-commit-hooks |
| 101 | + rev: v4.4.0 |
| 102 | + hooks: |
| 103 | + - id: check-yaml |
| 104 | + exclude: ^main\.yaml$ |
| 105 | +``` |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +b. Exclude multiple files (main.yaml and config.yaml are excluded) |
| 110 | + |
| 111 | +``` |
| 112 | +repos: |
| 113 | +- repo: https://github.com/pre-commit/pre-commit-hooks |
| 114 | + rev: v4.4.0 |
| 115 | + hooks: |
| 116 | + - id: check-yaml |
| 117 | + exclude: ^(main\.yaml|config\.yaml)$ |
| 118 | +``` |
| 119 | + |
| 120 | + |
| 121 | +c. If you want to ignore all files inside the folder from being processed by your pre-commit hooks, you can modify the `exclude` filed in your `.pre-commit-config.yaml` file to ignore the files you want to ignore. |
| 122 | + |
| 123 | +``` |
| 124 | +repos: |
| 125 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 126 | + rev: v4.4.0 |
| 127 | + hooks: |
| 128 | + - id: check-yaml |
| 129 | + exclude: ^folder-to-ignore/ |
| 130 | +``` |
| 131 | + |
| 132 | +d. If multiple folders are to be ignored, you can use the `exclude` field to ignore multiple folders. |
| 133 | + |
| 134 | +``` |
| 135 | +repos: |
| 136 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 137 | + rev: v4.4.0 |
| 138 | + hooks: |
| 139 | + - id: check-yaml |
| 140 | + exclude: ^(first-folder-to-ignore|second-folder-to-ignore)/ |
| 141 | +``` |
| 142 | + |
| 143 | +## Maintainers |
| 144 | + |
| 145 | +We embrace an open and inclusive community philosophy. Motivated contributors are encouraged to join the [maintainers' team](docs/content/contributing/maintainers.md). |
| 146 | +Learn more about pull request reviews and issue triaging in our [maintainers guide](https://github.com/01cloud/01cloud-githooks/blob/develop/docs/content/contributing/maintainers-guidelines.md). |
| 147 | + |
| 148 | +## Contributing |
| 149 | +Interested in contributing? Refer to our [contributing documentation](CONTRIBUTING.md). |
| 150 | +This project adheres to a [Code of Conduct](CODE_OF_CONDUCT.md), and participation requires compliance with its terms. |
| 151 | + |
| 152 | +--- |
| 153 | +When contributing to this project: |
| 154 | + |
| 155 | +- Follow the conventional commit message format |
| 156 | +- Ensure all pre-commit hooks pass |
| 157 | +- Test your changes across different environments |
| 158 | + |
| 159 | +## Credits |
| 160 | + |
| 161 | +Special thanks to [Berrybytes](https://www.berrybytes.com) for bringing this project to life! |
| 162 | + |
| 163 | + |
| 164 | +## License |
| 165 | + |
| 166 | +Pre-commit Automation Tools is open-source software licensed under the [MIT License](LICENSE). |
| 167 | + |
| 168 | +### Key Enhancements: |
| 169 | + |
| 170 | +1. **Visually Engaging Structure**: We've used emojis to separate sections and make key areas stand out. This creates an easy-to-read, welcoming atmosphere. |
| 171 | +2. **Readable Headers**: The use of headers like **Installation**, **Features**, **Prerequisites**, etc., makes the document easy to navigate. |
| 172 | +3. **Clear Examples and Code Blocks**: Code snippets are formatted properly and separated for easier reading. |
| 173 | +4. **Table of Contents**: The Table of Contents at the beginning allows users to quickly navigate the document to relevant sections. |
| 174 | +5. **Improved Formatting**: Sections like **Installation** and **Prerequisites** are cleanly formatted, making the process easier to follow. |
| 175 | + |
| 176 | +This revised README is more visually appealing and user-friendly while maintaining its clarity and professionalism. |
0 commit comments