From c9c5840d61b13e6fb4db72c3bdf095e04bd1c799 Mon Sep 17 00:00:00 2001 From: Mario Constanti Date: Mon, 11 Dec 2023 12:14:38 +0100 Subject: [PATCH] chore: enable PR title validation (#33) as we squash all commits from a PR into one commit with the PR title as commit message together with the description we do not need to validate every singel commit Signed-off-by: Mario Constanti --- .github/workflows/build.yml | 13 --- .github/workflows/pull-request-lint.yml | 22 ++++ commitlint.config.js | 131 ------------------------ 3 files changed, 22 insertions(+), 144 deletions(-) create mode 100644 .github/workflows/pull-request-lint.yml delete mode 100644 commitlint.config.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 631f099..5afc1a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,16 +35,3 @@ jobs: - name: make test run: make test - - - name: Install commitlint - run: | - npm install conventional-changelog-conventionalcommits - npm install commitlint@latest - - - name: Validate current commit (last commit) with commitlint - if: github.event_name == 'push' - run: npx commitlint --from HEAD~1 --to HEAD --verbose - - - name: Validate PR commits with commitlint - if: github.event_name == 'pull_request' - run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose diff --git a/.github/workflows/pull-request-lint.yml b/.github/workflows/pull-request-lint.yml new file mode 100644 index 0000000..979b6ae --- /dev/null +++ b/.github/workflows/pull-request-lint.yml @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: MIT + +name: "lint Pull Request title" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index 5338a42..0000000 --- a/commitlint.config.js +++ /dev/null @@ -1,131 +0,0 @@ -// SPDX-License-Identifier: MIT -module.exports = { - parserPreset: 'conventional-changelog-conventionalcommits', - rules: { - 'body-leading-blank': [1, 'always'], - 'body-max-line-length': [2, 'always', 100], - 'footer-leading-blank': [1, 'always'], - 'footer-max-line-length': [2, 'always', 100], - 'header-max-length': [2, 'always', 100], - 'subject-case': [ - 2, - 'never', - ['sentence-case', 'start-case', 'pascal-case', 'upper-case'], - ], - 'subject-empty': [2, 'never'], - 'subject-full-stop': [2, 'never', '.'], - 'type-case': [2, 'always', 'lower-case'], - 'type-empty': [2, 'never'], - 'type-enum': [ - 2, - 'always', - [ - 'build', - 'chore', - 'docs', - 'feat', - 'fix', - 'test', - ], - ], - }, - prompt: { - questions: { - type: { - description: "Select the type of change that you're committing", - enum: { - feat: { - description: 'A new feature', - title: 'Features', - emoji: '✨', - }, - fix: { - description: 'A bug fix', - title: 'Bug Fixes', - emoji: '🐛', - }, - docs: { - description: 'Documentation only changes', - title: 'Documentation', - emoji: '📚', - }, - style: { - description: - 'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)', - title: 'Styles', - emoji: '💎', - }, - refactor: { - description: - 'A code change that neither fixes a bug nor adds a feature', - title: 'Code Refactoring', - emoji: '📦', - }, - perf: { - description: 'A code change that improves performance', - title: 'Performance Improvements', - emoji: '🚀', - }, - test: { - description: 'Adding missing tests or correcting existing tests', - title: 'Tests', - emoji: '🚨', - }, - build: { - description: - 'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)', - title: 'Builds', - emoji: '🛠', - }, - ci: { - description: - 'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)', - title: 'Continuous Integrations', - emoji: '⚙️', - }, - chore: { - description: "Other changes that don't modify src or test files", - title: 'Chores', - emoji: '♻️', - }, - revert: { - description: 'Reverts a previous commit', - title: 'Reverts', - emoji: '🗑', - }, - }, - }, - scope: { - description: - 'What is the scope of this change (e.g. component or file name)', - }, - subject: { - description: - 'Write a short, imperative tense description of the change', - }, - body: { - description: 'Provide a longer description of the change', - }, - isBreaking: { - description: 'Are there any breaking changes?', - }, - breakingBody: { - description: - 'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself', - }, - breaking: { - description: 'Describe the breaking changes', - }, - isIssueAffected: { - description: 'Does this change affect any open issues?', - }, - issuesBody: { - description: - 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself', - }, - issues: { - description: 'Add issue references (e.g. "fix #123", "re #123".)', - }, - }, - }, -}; \ No newline at end of file