|
3 | 3 | </p> |
4 | 4 |
|
5 | 5 | # CONVCOMMITLINT |
| 6 | + |
6 | 7 | [](https://github.com/coolapso/convcommitlint/actions/workflows/release.yaml) |
7 | 8 |  |
8 | 9 | [](https://hub.docker.com/r/coolapso/convcommitlint) |
9 | 10 | [](https://goreportcard.com/report/github.com/coolapso/convcommitlint) |
10 | 11 |  |
11 | 12 |
|
12 | | -A simple, slightly opinionated, yet usable linter for [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/), written in Go. |
13 | | -This linter covers the convention essentials, contributions are wellcome but, no! I don't intend to support all kinds of variations and custom rules! |
| 13 | +A simple, slightly opinionated, but actually *usable* linter for [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), written in Go. |
| 14 | + |
| 15 | +--- |
14 | 16 |
|
15 | 17 | ## Motivation |
16 | 18 |
|
17 | | -I just wanted something simple that works, not configure all kinds of things just to get a linter working! |
| 19 | +I just wanted something that *works* out of the box. No over-configuration, no headaches—just simple commit linting! This being said, this linter covers the essentials. Contributions are welcome, but I don’t intend to support every possible variation or custom rule! |
| 20 | + |
| 21 | +--- |
18 | 22 |
|
19 | 23 | ## Features |
20 | 24 |
|
21 | | -* Checks for header syntax |
22 | | -* Checks for common typos on the most important keywords: fix, feat and BREAKING CHANGE |
23 | | -* Supports creating pull github pull request reviews |
24 | | - * Supports request for changes (default) |
25 | | - * Supports commenting only |
26 | | -* Supports linting only the current commit |
27 | | -* Supports linting all commits |
28 | | -* Supports linting only most recent commits from base branch |
| 25 | +- **Checks header syntax** |
| 26 | +- **Detects common typos** in key keywords: `fix`, `feat`, and `BREAKING CHANGE` |
| 27 | +- **GitHub Pull Request Reviews:** |
| 28 | + - Request changes (default) |
| 29 | + - Comment-only mode |
| 30 | +- **Lint Modes:** |
| 31 | + - Lint only the current commit |
| 32 | + - Lint all commits |
| 33 | + - Lint only recent commits from the base branch |
| 34 | +- **Full environment variable support** for all flags |
| 35 | +- **Cross-platform:** Linux, macOS, and Windows |
| 36 | +- **GitHub Action** support |
29 | 37 |
|
30 | | -## How it works |
| 38 | +--- |
31 | 39 |
|
32 | | -convcommitlint will check your commits against the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standard, and let you know if there are any issues, when running on github actions and if you enable creation of pull request reviews it will create a pull request review for you. |
| 40 | +## How It Works |
33 | 41 |
|
34 | | -## Installation |
| 42 | +`convcommitlint` checks your commits against the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. |
| 43 | +If you use it as a GitHub Action or enable PR review, it will comment or request changes directly on your pull requests, listing any issues it finds. |
35 | 44 |
|
36 | | -### Github action |
| 45 | +--- |
37 | 46 |
|
38 | | -Github action is available to use with your CI pipelines and most arguments from the CLI application are available. |
| 47 | +## Usage |
39 | 48 |
|
40 | 49 | ``` |
41 | | - convcommitlint: |
42 | | - runs-on: ubuntu-latest |
43 | | - steps: |
44 | | - - uses: actions/checkout@v4 |
45 | | - - uses: coolapso/convcommitlint@v0 |
| 50 | + convcommitlint [flags] |
| 51 | + convcommitlint [command] |
| 52 | +
|
| 53 | +Available Commands: |
| 54 | + completion Generate the autocompletion script for the specified shell |
| 55 | + help Help about any command |
| 56 | + version Print convcommitlint version |
| 57 | +
|
| 58 | +Flags: |
| 59 | + -b, --base-branch string The base branch to check commits from (default "main") |
| 60 | + --comment-only Pull request reviews will only comment instead of requesting changes |
| 61 | + -r, --create-review Creates review on github pull request |
| 62 | + -c, --current Lint only the current commit |
| 63 | + -h, --help help for convcommitlint |
| 64 | + -a, --lint-all Lint all repository commits |
| 65 | + -p, --path string Git repository path (default "./") |
| 66 | + --pr-number int The number of pull request to create the review |
| 67 | + --repository string The github repository in owner/name format ex: coolapso/convcommitlint |
| 68 | +
|
| 69 | +Use "convcommitlint [command] --help" for more information about a command. |
46 | 70 | ``` |
| 71 | +<p align="center"> |
| 72 | + <img src="https://raw.githubusercontent.com/coolapso/convcommitlint/refs/heads/main/images/demo.gif"> |
| 73 | +</p> |
47 | 74 |
|
48 | | -You can find the available inputs in the [action.yaml](action.yaml) file, if a input is not available you still should be able to use it by setting the associated ENV variable. |
49 | 75 |
|
50 | | -> [!IMPORTANT] |
51 | | -> Be sure to include the Checkout in your workflow, this action won't do it for you! |
| 76 | +### Environment Variables |
52 | 77 |
|
53 | | -### Docker |
| 78 | +Every flag can also be set with an environment variable, using the `CONVCOMMITLINT_` prefix, uppercase, and underscores. |
| 79 | +For example, the flag `--lint-all` becomes the variable `CONVCOMMITLINT_LINT_ALL`. |
| 80 | + |
| 81 | +--- |
54 | 82 |
|
55 | | -You can run convcommitlint with docker, containers are provided both on dockerhub and ghcr.io |
| 83 | +## GitHub Action |
56 | 84 |
|
57 | | -**ghcr.io** |
| 85 | +You can use `convcommitlint` as part of your CI pipeline. Most CLI arguments are supported as action inputs. |
58 | 86 |
|
| 87 | +```yaml |
| 88 | +convcommitlint: |
| 89 | + runs-on: ubuntu-latest |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v4 |
| 92 | + - uses: coolapso/convcommitlint@v0 |
59 | 93 | ``` |
60 | | -docker run -v $(pwd):/data --rm ghcr.io/coolapso/convcommitlint:latest |
| 94 | +
|
| 95 | +### Base Branch |
| 96 | +
|
| 97 | +By default, the base branch is `"main"`. If you use a different default branch, set the `base-branch` input: |
| 98 | + |
| 99 | +```yaml |
| 100 | +convcommitlint: |
| 101 | + runs-on: ubuntu-latest |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + - uses: coolapso/convcommitlint@v0 |
| 105 | + with: |
| 106 | + base-branch: develop |
61 | 107 | ``` |
62 | 108 |
|
63 | | -**dockerhub:** |
| 109 | +### Git History Depth |
| 110 | + |
| 111 | +By default, the action checks out the reference branch with full history. To limit this, use the `fetch-depth` input (commits beyond this depth will *not* be analyzed): |
64 | 112 |
|
| 113 | +```yaml |
| 114 | +convcommitlint: |
| 115 | + runs-on: ubuntu-latest |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@v4 |
| 118 | + - uses: coolapso/convcommitlint@v0 |
| 119 | + with: |
| 120 | + fetch-depth: 10 |
65 | 121 | ``` |
66 | | -docker run -v $(pwd):/data --rm coolapso/convcommitlint:latest |
| 122 | + |
| 123 | +### Disable Pull Request Reviews |
| 124 | + |
| 125 | +PR reviews are enabled by default. To disable them, set `create-review` to `"false"`: |
| 126 | + |
| 127 | +```yaml |
| 128 | +convcommitlint: |
| 129 | + runs-on: ubuntu-latest |
| 130 | + steps: |
| 131 | + - uses: actions/checkout@v4 |
| 132 | + - uses: coolapso/convcommitlint@v0 |
| 133 | + with: |
| 134 | + create-review: "false" |
67 | 135 | ``` |
68 | 136 |
|
69 | | -### Go Install |
| 137 | +### Use a Specific Version |
70 | 138 |
|
71 | | -#### Latest version |
| 139 | +The action uses the latest release by default. To pin a specific version: |
72 | 140 |
|
73 | | -`go install github.com/coolapso/convcommitlint@latest` |
| 141 | +```yaml |
| 142 | +convcommitlint: |
| 143 | + runs-on: ubuntu-latest |
| 144 | + steps: |
| 145 | + - uses: actions/checkout@v4 |
| 146 | + - uses: coolapso/convcommitlint@v0 |
| 147 | + with: |
| 148 | + version: v0.2.0 |
| 149 | +``` |
74 | 150 |
|
75 | | -#### Specific version |
| 151 | +### Other Features & Flags |
76 | 152 |
|
77 | | -`go install github.com/coolapso/convcommitlint@v1.0.0` |
| 153 | +The action supports all CLI features and flags. |
| 154 | +Check available inputs in [`action.yaml`](action.yaml). |
| 155 | +If an input is missing, you can always set the corresponding environment variable. |
78 | 156 |
|
79 | | -### AUR |
| 157 | +--- |
80 | 158 |
|
81 | | -On Arch linux you can use the AUR `convcommitlint-bin` |
| 159 | +## Installation |
82 | 160 |
|
83 | | -### Linux Script |
| 161 | +### Docker |
84 | 162 |
|
85 | | -It is also possible to install on any linux distro with the installation script |
| 163 | +Images are available on both DockerHub and GitHub Container Registry (ghcr.io): |
86 | 164 |
|
87 | | -#### Latest version |
| 165 | +**GitHub Container Registry:** |
88 | 166 |
|
| 167 | +```sh |
| 168 | +docker run -v $(pwd):/data --rm ghcr.io/coolapso/convcommitlint:latest |
89 | 169 | ``` |
90 | | -curl -L http://commitlint.coolapso.sh/install.sh | bash |
| 170 | + |
| 171 | +**DockerHub:** |
| 172 | + |
| 173 | +```sh |
| 174 | +docker run -v $(pwd):/data --rm coolapso/convcommitlint:latest |
91 | 175 | ``` |
92 | 176 |
|
93 | | -#### Specific version |
| 177 | +### Go Install |
| 178 | + |
| 179 | +#### Latest Version |
94 | 180 |
|
| 181 | +```sh |
| 182 | +go install github.com/coolapso/convcommitlint@latest |
95 | 183 | ``` |
96 | | -curl -L http://commitlint.coolapso.sh/install.sh | VERSION="v1.1.0" bash |
| 184 | + |
| 185 | +#### Specific Version |
| 186 | + |
| 187 | +```sh |
| 188 | +go install github.com/coolapso/convcommitlint@v1.0.0 |
97 | 189 | ``` |
98 | 190 |
|
99 | | -### Manual install |
| 191 | +### Arch Linux (AUR) |
100 | 192 |
|
101 | | -* Grab the binary from the [releases page](https://github.com/coolapso/convcommitlint/releases). |
102 | | -* Extract the binary |
103 | | -* Execute it |
| 193 | +On Arch Linux, use the AUR package: `convcommitlint-bin`. |
104 | 194 |
|
| 195 | +### Linux Install Script |
105 | 196 |
|
106 | | -## Usage |
| 197 | +Install on any Linux distro using the script: |
| 198 | + |
| 199 | +#### Latest Version |
107 | 200 |
|
| 201 | +```sh |
| 202 | +curl -L http://commitlint.coolapso.sh/install.sh | bash |
108 | 203 | ``` |
109 | | -Usage: |
110 | | - convcommitlint [flags] |
111 | | - convcommitlint [command] |
112 | 204 |
|
113 | | -Available Commands: |
114 | | - completion Generate the autocompletion script for the specified shell |
115 | | - help Help about any command |
116 | | - version Print convcommitlint version |
| 205 | +#### Specific Version |
117 | 206 |
|
118 | | -Flags: |
119 | | - -b, --base-branch string The base branch to check commits from (default "main") |
120 | | - --comment-only Pull request reviews will only comment instead of requesting changes |
121 | | - -r, --create-review Creates review on github pull request |
122 | | - -c, --current Lint only the current commit |
123 | | - -h, --help help for convcommitlint |
124 | | - -a, --lint-all Lint all repository commits |
125 | | - -p, --path string Git repository path (default "./") |
126 | | - --pr-number int The number of pull request to create the review |
127 | | - --repository string The github repository in owner/name format ex: coolapso/convcommitlint |
128 | | -
|
129 | | -Use "convcommitlint [command] --help" for more information about a command. |
| 207 | +```sh |
| 208 | +curl -L http://commitlint.coolapso.sh/install.sh | VERSION="v1.1.0" bash |
130 | 209 | ``` |
131 | 210 |
|
132 | | -## Build |
133 | 211 |
|
134 | | -`go build -o convcommitlint |
| 212 | +### Manual Install |
135 | 213 |
|
136 | | -# Contributions |
| 214 | +- Download the binary from the [releases page](https://github.com/coolapso/convcommitlint/releases) |
| 215 | +- Extract the binary |
| 216 | +- Run it |
137 | 217 |
|
138 | | -Improvements and suggestions are always welcome, feel free to check for any open issues, open a new Issue or Pull Request |
| 218 | +### Build |
139 | 219 |
|
140 | | -If you like this project and want to support / contribute in a different way you can always [:heart: Sponsor Me](https://github.com/sponsors/coolapso) or |
| 220 | +```sh |
| 221 | +go build -o convcommitlint |
| 222 | +``` |
141 | 223 |
|
142 | | -<a href="https://www.buymeacoffee.com/coolapso" target="_blank"> |
143 | | - <img src="https://cdn.buymeacoffee.com/buttons/default-yellow.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" /> |
144 | | -</a> |
| 224 | +--- |
145 | 225 |
|
| 226 | +## Contributions |
146 | 227 |
|
| 228 | +Improvements and suggestions are always welcome! |
| 229 | +Check open issues, or open a new Issue or Pull Request. |
147 | 230 |
|
148 | | -Also consider supporting [tapio/live-server](https://github.com/tapio/live-server) which inspired this project |
| 231 | +If you like this project and want to support or contribute in another way, you can [:heart: Sponsor Me](https://github.com/sponsors/coolapso) or: |
149 | 232 |
|
| 233 | +<a href="https://www.buymeacoffee.com/coolapso" target="_blank"> |
| 234 | + <img src="https://cdn.buymeacoffee.com/buttons/default-yellow.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" /> |
| 235 | +</a> |
0 commit comments