Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds commit lint to the CI #1784

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 9 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ First off, thank you for taking the time to contribute to Minder! :+1: :tada: Mi
- [Pull Request Process](#pull-request-process)
- [Contributing to docs](#contributing-to-docs)
- [Commit Message Guidelines](#commit-message-guidelines)


## Code of Conduct
This project adheres to the [Contributor Covenant](https://github.com/stacklok/minder/blob/main/CODE_OF_CONDUCT.md) code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].
Expand Down Expand Up @@ -48,4 +47,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: [
// Ignores Dependabot and WIP commits
(message) => message.includes('build(') || message.includes('WIP')
]
};
Loading