diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c8285e8..bd6207b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -49,6 +49,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: coolapso/convcommitlint@main - continue-on-error: true + - uses: ./ + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 555d899..465db63 100644 --- a/README.md +++ b/README.md @@ -3,147 +3,233 @@
# CONVCOMMITLINT + [](https://github.com/coolapso/convcommitlint/actions/workflows/release.yaml)  [](https://hub.docker.com/r/coolapso/convcommitlint) [](https://goreportcard.com/report/github.com/coolapso/convcommitlint)  -A simple, slightly opinionated, yet usable linter for [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/), written in Go. -This linter covers the convention essentials, contributions are wellcome but, no! I don't intend to support all kinds of variations and custom rules! +A simple, slightly opinionated, but actually *usable* linter for [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), written in Go. + +--- ## Motivation -I just wanted something simple that works, not configure all kinds of things just to get a linter working! +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! + +--- ## Features -* Checks for header syntax -* Checks for common typos on the most important keywords: fix, feat and BREAKING CHANGE -* Supports creating pull github pull request reviews - * Supports request for changes (default) - * Supports commenting only -* Supports linting only the current commit -* Supports linting all commits -* Supports linting only most recent commits from base branch +- **Checks header syntax** +- **Detects common typos** in key keywords: `fix`, `feat`, and `BREAKING CHANGE` +- **GitHub Pull Request Reviews:** + - Request changes (default) + - Comment-only mode +- **Lint Modes:** + - Lint only the current commit + - Lint all commits + - Lint only recent commits from the base branch +- **Full environment variable support** for all flags +- **Cross-platform:** Linux, macOS, and Windows +- **GitHub Action** support -## How it works +--- -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. +## How It Works -## Installation +`convcommitlint` checks your commits against the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. +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. -### Github action +--- -Github action is available to use with your CI pipelines and most arguments from the CLI application are available. +## Usage ``` - convcommitlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: coolapso/convcommitlint@v0 + convcommitlint [flags] + convcommitlint [command] + +Available Commands: + completion Generate the autocompletion script for the specified shell + help Help about any command + version Print convcommitlint version + +Flags: + -b, --base-branch string The base branch to check commits from (default "main") + --comment-only Pull request reviews will only comment instead of requesting changes + -r, --create-review Creates review on github pull request + -c, --current Lint only the current commit + -h, --help help for convcommitlint + -a, --lint-all Lint all repository commits + -p, --path string Git repository path (default "./") + --pr-number int The number of pull request to create the review + --repository string The github repository in owner/name format ex: coolapso/convcommitlint + +Use "convcommitlint [command] --help" for more information about a command. ``` +
+
+
-
+---
+## Contributions
+Improvements and suggestions are always welcome!
+Check open issues, or open a new Issue or Pull Request.
-Also consider supporting [tapio/live-server](https://github.com/tapio/live-server) which inspired this project
+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:
+
+
+
diff --git a/action.yaml b/action.yaml
index 3c4a9b1..6d62d78 100644
--- a/action.yaml
+++ b/action.yaml
@@ -1,30 +1,21 @@
-name: 'commit lint'
+name: 'convcommitlint'
description: 'Check if commits follow the conventional commits standard'
+branding:
+ icon: 'git-commit'
+ color: 'gray-dark'
inputs:
+ fetch-depth:
+ description: 'git fetch depth when checking out the repository'
+ required: false
+ default: "0"
base-branch: # id of input
description: 'base branch to lint from'
required: false
default: "main"
- comment-only:
- description: 'Do not request changes on pull requests'
- required: false
- default: "false"
create-review:
- description: 'Creates a pull request revie'
+ description: 'Creates a pull request review'
required: false
default: "true"
- current:
- description: 'Lints only current commit'
- required: false
- default: "false"
- lint-all:
- description: 'Lints all commits in the history'
- required: false
- default: "false"
- path:
- description: 'Path to the repository'
- required: false
- default: "./"
version:
description: 'go conventional commit version to run'
required: false
@@ -39,16 +30,17 @@ runs:
- name: "install conventional commit lint"
shell: bash
run: go install github.com/coolapso/convcommitlint@${{ inputs.version }}
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: ${{ inputs.fetch-depth }}
+ ref: ${{ github.head_ref }}
+ - name: 'get base branch last commit'
+ run: git fetch origin ${{ inputs.base-branch }}:${{ inputs.base-branch }} --depth 1
+ shell: bash
- name: "Lint commits"
shell: bash
run: |
- export CONVCOMLINT_BASE_BRANCH=${{ inputs.base-branch }}
- export CONVCOMLINT_COMMENT_ONLY=${{ inputs.comment-only }}
- export CONVCOMLINT_CREATE_REVIEW=${{ inputs.create-review }}
- export CONVCOMLINT_CURRENT=${{ inputs.current }}
- export CONVCOMLINT_LINT_ALL=${{ inputs.lint-all }}
- export CONVCOMLINT_PATH=${{ inputs.path }}
- convcommitlint
+ convcommitlint -b ${{ inputs.base-branch }} --create-review=${{ inputs.create-review }}
diff --git a/images/demo.gif b/images/demo.gif
index cee7e53..372027b 100644
Binary files a/images/demo.gif and b/images/demo.gif differ