Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
ci: add commitlint in CI (starkware-libs#1313)
Browse files Browse the repository at this point in the history
Signed-off-by: Dori Medini <dori@starkware.co>
  • Loading branch information
dorimedini-starkware committed Jan 22, 2024
1 parent 7caa8c2 commit 22f9c14
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ on:
- edited

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install commitlint
run: npm install --global @commitlint/cli @commitlint/config-conventional

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

- name: Validate PR title with commitlint
if: github.event_name != 'merge_group' && github.event_name != 'push'
run: echo "${{ github.event.pull_request.title }}" | commitlint --verbose

format:
runs-on: ubuntu-latest
steps:
Expand Down
57 changes: 57 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const Configuration = {
/*
* Resolve and load @commitlint/config-conventional from node_modules.
* Referenced packages must be installed.
* See [the README](https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-conventional/README.md)
* for applied rules.
*/
extends: ['@commitlint/config-conventional'],
/*
* Resolve and load conventional-changelog-atom from node_modules.
* Referenced packages must be installed
*/
// parserPreset: 'conventional-changelog-atom',
/*
* Resolve and load @commitlint/format from node_modules.
* Referenced package must be installed
*/
formatter: '@commitlint/format',
/*
* Any rules defined here will override rules from @commitlint/config-conventional
*/
rules: {
'scope-enum': [2, 'always', [
'execution',
'fee',
'native_blockifier',
'state',
'transaction',
]],
},
/*
* Functions that return true if commitlint should ignore the given message.
*/
ignores: [(commit) => commit === ''],
/*
* Whether commitlint uses the default ignore rules.
*/
defaultIgnores: true,
/*
* Custom URL to show upon failure
*/
helpUrl:
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
/*
* Custom prompt configs, not used currently.
*/
prompt: {
messages: {},
questions: {
type: {
description: 'please input type:',
},
},
},
};

module.exports = Configuration;

0 comments on commit 22f9c14

Please sign in to comment.