|
| 1 | +# Template Repository with pre-commit checks and GitHub Actions |
| 2 | + |
| 3 | +This repository serves as a template for creating new repositories with integrated pre-commit hooks and GitHub Actions. The setup ensures consistent code quality by enforcing pre-commit checks and running tests automatically when a pull request (PR) is made to the `main` branch. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Pre-commit Hooks**: Automatically check code before commits are accepted. |
| 8 | +- **GitHub Actions Integration**: Automatically runs: |
| 9 | + - Pre-commit checks on every PR. |
| 10 | + - Test suite to validate code changes. |
| 11 | + |
| 12 | +## Setup Instructions |
| 13 | + |
| 14 | +### 1. Clone the repository |
| 15 | + |
| 16 | +```bash |
| 17 | +git clone https://github.com/mohilpatel25/template-repository.git |
| 18 | +cd template-repository |
| 19 | +``` |
| 20 | + |
| 21 | +### 2. Install Pre-commit |
| 22 | + |
| 23 | +To enable pre-commit checks locally, install the `pre-commit` package and set it up: |
| 24 | + |
| 25 | +```bash |
| 26 | +pip install pre-commit |
| 27 | +pre-commit install |
| 28 | +``` |
| 29 | + |
| 30 | +This will ensure pre-commit hooks are executed every time you make a commit. |
| 31 | + |
| 32 | +### 3. Modify as a Template |
| 33 | + |
| 34 | +Once cloned, you can use this repository as a template for new projects. Modify the code, tests, or add new pre-commit hooks based on your project requirements. |
| 35 | + |
| 36 | +### 4. Run Pre-commit Manually |
| 37 | + |
| 38 | +You can manually run pre-commit hooks at any time by executing: |
| 39 | + |
| 40 | +```bash |
| 41 | +pre-commit run --all-files |
| 42 | +``` |
| 43 | + |
| 44 | +### 5. GitHub Actions Workflow |
| 45 | + |
| 46 | +The repository includes a GitHub Actions workflow located in `.github/workflows/ci.yml`. This workflow: |
| 47 | + |
| 48 | +- Runs pre-commit checks automatically on all PRs targeting the `main` branch. |
| 49 | +- Runs tests to ensure code integrity. |
| 50 | + |
| 51 | +Ensure your test suite is properly set up and modify the workflow to suit your project needs. |
| 52 | + |
| 53 | +## Customizing Pre-commit Hooks |
| 54 | + |
| 55 | +Pre-commit hooks are configured in the `.pre-commit-config.yaml` file. To add or remove hooks, modify this file and run: |
| 56 | + |
| 57 | +```bash |
| 58 | +pre-commit autoupdate |
| 59 | +``` |
| 60 | + |
| 61 | +## Customizing GitHub Actions |
| 62 | + |
| 63 | +Update the `.github/workflows/ci.yml` file to make changes to the actions. |
0 commit comments