voxpupuli/commitlint

Sponsored OSS

By voxpupuli

Updated 4 months ago

Vox Pupuli Container for commitlint

Image

44

Vox Pupuli Commitlint Container

CILicenseSponsored by betadots GmbH

This container can be used to lint commits. It encapsulates commitlint and all necessary plugins. See package.json for details. This is a npm application running in an alpine container.

Usage

Lint last commit only
podman run -it --rm -v $PWD:/data ghcr.io/voxpupuli/commitlint:latest
# or (but thats the default)
podman run -it --rm -v $PWD:/data ghcr.io/voxpupuli/commitlint:latest --last
Lint all commits from a branch
podman run -it --rm -v $PWD:/data ghcr.io/voxpupuli/commitlint:latest \
  --from $(git merge-base $(git symbolic-ref refs/remotes/origin/HEAD --short) HEAD) \
  --to HEAD
More options

For more options see:

podman run -it --rm -v $PWD:/data ghcr.io/voxpupuli/commitlint:latest --help
Example commitlint config

See .commitlint.yaml

---
# The rules below have been manually copied from @commitlint/config-conventional
# and match the v1.0.0 specification:
# https://www.conventionalcommits.org/en/v1.0.0/#specification
#
# You can remove them and uncomment the config below when the following issue is
# fixed: https://github.com/conventional-changelog/commitlint/issues/613
#
# extends:
#   - '@commitlint/config-conventional'
rules:
  body-leading-blank: [1, always]
  body-max-line-length: [2, always, 100]
  footer-leading-blank: [1, always]
  footer-max-line-length: [2, always, 100]
  header-max-length: [2, always, 100]
  subject-case:
    - 2
    - never
    - [sentence-case, start-case, pascal-case, upper-case]
  subject-empty: [2, never]
  subject-full-stop: [2, never, "."]
  type-case: [2, always, lower-case]
  type-empty: [2, never]
  type-enum:
    - 2
    - always
    - [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]
Example GitLab CI Job
commitlint:
  stage: .pre # Default Stage of gitlab-ci. Runs before every other pipeline
  image:
    name: ghcr.io/voxpupuli/commitlint:latest
    entrypoint: [""] # overwrite entrypoint
  interruptible: true
  variables:
    # Checkout entire repo and use clone
    GIT_DEPTH: 0
    GIT_STRATEGY: clone
  script:
    # switch to MR  branch instead of detached HEAD
    - git switch $CI_COMMIT_REF_NAME
    - commitlint --from $(git merge-base origin/$CI_DEFAULT_BRANCH HEAD) --to HEAD
  rules:
    # only run on merge request pipelines
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

Docker Pull Command

docker pull voxpupuli/commitlint