Skip to content

Commit

Permalink
Add commitlint to the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgalante committed Dec 1, 2023
1 parent f9016c7 commit 9fceca3
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 10 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Lint Commit Messages

on:
workflow_call:

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ jobs:
uses: ./.github/workflows/security.yml
compose-migrate:
uses: ./.github/workflows/compose-migrate.yml
commit-lint:
uses: ./.github/workflows/commit-lint.yml
30 changes: 20 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
First off, thank you for taking the time to contribute to Minder! :+1: :tada: Minder is released under the Apache 2.0 license. If you would like to contribute something or want to hack on the code, this document should help you get started. You can find some hints for starting development in Minder's [README](https://github.com/stacklok/minder/blob/main/README.md).

## Table of contents
- [Code of Conduct](#code-of-conduct)
- [Reporting Security Vulnerabilities](#reporting-security-vulnerabilities)
- [How to Contribute](#how-to-contribute)
- [Sign the Contributor License Agreement](#sign-the-contributor-license-agreement)
- [Using GitHub Issues](#using-github-issues)
- [Not sure how to start contributing...](#not-sure-how-to-start-contributing)
- [Pull Request Process](#pull-request-process)
- [Contributing to docs](#contributing-to-docs)
- [Commit Message Guidelines](#commit-message-guidelines)
- [Contributing to Minder](#contributing-to-minder)
- [Table of contents](#table-of-contents)
- [Code of Conduct](#code-of-conduct)
- [Reporting Security Vulnerabilities](#reporting-security-vulnerabilities)
- [How to Contribute](#how-to-contribute)
- [Using GitHub Issues](#using-github-issues)
- [Sign the Contributor License Agreement](#sign-the-contributor-license-agreement)
- [Not sure how to start contributing...](#not-sure-how-to-start-contributing)
- [Pull Request Process](#pull-request-process)
- [Contributing to docs](#contributing-to-docs)
- [Commit Message Guidelines](#commit-message-guidelines)


## Code of Conduct
Expand Down Expand Up @@ -48,4 +50,12 @@ PRs to resolve existing issues are greatly appreciated and issues labeled as ["g
Follow [this guide](https://github.com/stacklok/minder/blob/main/docs/README.md) for instructions on building, running, and previewing Miner's documentation.

### Commit Message Guidelines
We follow the commit formatting recommendations found on [Chris Beams' How to Write a Git Commit Message article](https://chris.beams.io/posts/git-commit/).
We follow the commit formatting recommendations found on [Chris Beams' How to Write a Git Commit Message article](https://chris.beams.io/posts/git-commit/):

1. Separate subject from body with a blank line
1. Limit the subject line to 50 characters
1. Capitalize the subject line
1. Do not end the subject line with a period
1. Use the imperative mood in the subject line
1. Wrap the body at 72 characters
1. Use the body to explain what and why vs. how
49 changes: 49 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Copyright 2023 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

module.exports = {

// This config should help enforce Chris Bean's commit message recommendations


rules: {

// Separate subject from body with a blank line
'body-leading-blank': [2, 'always'],

// - Limit the subject line to 50 characters
'header-max-length': [2, 'always', 50],

// Capitalize the subject line
'header-case': [2, 'always', 'sentence-case'],
'subject-case': [2, 'always', 'sentence-case'],

// Do not end the subject line with a period
'header-full-stop': [2, 'never'],
'subject-full-stop': [0, 'never'],

// Wrap the body at 72 characters
'body-max-line-length': [2, 'always', 75],

'type-empty': [2, 'always'], // Disallow types

// TODO: write plugins to check for:
// Use the imperative mood in the subject line
// Use the body to explain what and why vs. how
},
ignores: [
(message) => message.includes('build(') || message.includes('WIP')
]
};

0 comments on commit 9fceca3

Please sign in to comment.