Skip to content

Commit

Permalink
Add commit lint 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 6619482
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 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
46 changes: 46 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// 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
},
};

0 comments on commit 6619482

Please sign in to comment.