diff --git a/README.md b/README.md index b074460..45a4490 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](/LICENSE) [![Coverage Status](https://coveralls.io/repos/github/thumbrise/commitlint-scope/badge.svg?branch=main)](https://coveralls.io/github/thumbrise/commitlint-scope?branch=main) [![Go Report Card](https://goreportcard.com/badge/github.com/thumbrise/commitlint-scope)](https://goreportcard.com/report/github.com/thumbrise/commitlint-scope) +[![Docker Image Size](https://img.shields.io/docker/image-size/thumbrise/commitlint-scope/latest-alpine?label=image%20size)](https://hub.docker.com/r/thumbrise/commitlint-scope) Git commit conventional scope linter. @@ -17,10 +18,20 @@ Git commit conventional scope linter. * [Purpose](#purpose) * [Quick start](#quick-start) * [Install](#install) + * [Docker Hub](#docker-hub) + * [Binaries](#binaries) * [Run](#run) + * [Binary](#binary) + * [Docker](#docker) * [Configuration file](#configuration-file) + * [Init](#init) + * [Overview](#overview) * [Zero Configuration](#zero-configuration) * [CI](#ci) + * [GitHub Actions](#github-actions) + * [GitLab CI](#gitlab-ci) + * [Bitbucket Pipelines](#bitbucket-pipelines) + * [Important Notes for All CI Systems](#important-notes-for-all-ci-systems) * [JSON schema](#json-schema) * [License](#license) @@ -34,17 +45,46 @@ Useful if your dev-flow requires strict scoped file changes control over CI proc ### Install +#### Docker Hub + +```shell +docker pull thumbrise/commitlint-scope:latest-alpine +``` + +#### Binaries + https://github.com/thumbrise/commitlint-scope/releases +
+ +No CGO + +Binaries are statically compiled (CGO_ENABLED=0) and work without external dependencies on Linux, macOS, and Windows. +
+ ### Run +Go to your repository root. + ```shell -commitlint-scope --from main --to feature +cd /path/to/your/repo/ +``` + +#### Binary + +```shell +commitlint-scope run --from main --to feature +``` + +#### Docker + +```bash +docker run --rm -v "$(pwd):/repo" -w /repo thumbrise/commitlint-scope:latest-alpine run --from main --to feature --verbose ``` ## Configuration file -**Init** +### Init Generate .commitlint-scope.yml file. @@ -52,7 +92,7 @@ Generate .commitlint-scope.yml file. commitlint-scope init ``` -**Overview** +### Overview ```yaml #$schema: https://github.com/thumbrise/commitlint-scope/blob/main/docs/schema/config.json @@ -70,19 +110,83 @@ patterns: ## Zero Configuration -Without configuration file - scopes are treated as file-glob matches, relative to repository root. +Without a configuration file, each scope is used as a glob pattern by appending /**. +For example, a commit with scope auth will check if any changed file matches auth/**. +This behaviour keeps things simple for repositories where directory names mirror commit scopes. + +For example: ```text feat(auth): Some subject ``` -Linter will compare changed files against glob pattern `auth/**` +Linter will compare changed files against glob pattern `auth/**`. ## CI -TODO: Add high-DX examples +### GitHub Actions + +```yaml +name: Lint Commit Scopes +on: + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout repository (full history) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Lint commit scopes + run: | + docker run --rm \ + -v "${{ github.workspace }}:/repo" \ + -w /repo \ + thumbrise/commitlint-scope:latest-alpine \ + run \ + --from ${{ github.event.pull_request.base.sha }} \ + --to ${{ github.event.pull_request.head.sha }} \ + --verbose +``` + +### GitLab CI + +```yaml +commitlint: + image: thumbrise/commitlint-scope:latest-alpine + stage: test + variables: + GIT_DEPTH: 0 + script: + - commitlint-scope run --from $CI_MERGE_REQUEST_DIFF_BASE_SHA --to $CI_COMMIT_SHA + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" +``` + +### Bitbucket Pipelines + +```yaml +pipelines: + pull-requests: + '**': + - step: + name: Lint commit scopes + image: thumbrise/commitlint-scope:latest-alpine # For production - use specific version + script: + - git fetch --unshallow || true + - commitlint-scope run --from $BITBUCKET_PR_DESTINATION_BRANCH --to $BITBUCKET_COMMIT +``` + +### Important Notes for All CI Systems +- Always do a full clone (`fetch-depth: 0` or equivalent) so `git rev-list` can find all commits. +- For shallow clones, use `git fetch --unshallow` or ensure the required commit range is available, otherwise `git rev-list` will fail. +- If your CI doesn't provide base/target commit variables, specify the SHAs manually. +- The image already includes safe directory configuration (`safe.directory '*'`) for smooth operation. --- ## JSON schema