diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a513c35b1..a37c234ecc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000000..51d2eb5d7c --- /dev/null +++ b/commitlint.config.js @@ -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;