From ba398754c394650de34d9a7900cc1dea98a9253e Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 1 Jul 2026 08:54:45 -0600 Subject: [PATCH] ci: Use our own pr_title_lint.py instead of NPM commitlint [citest_skip] There are a few problems with the NPM commitlint * NPM is problematic * Having to install NPM and commitlint and dependencies is slow and heavyweight * commitlint is overkill for our simple use case We have our own pr_title_lint.py which is small and works exactly for our use case. Enhance coderabbit checks for PRs and test cleanup Signed-off-by: Rich Megginson --- .coderabbit.yaml | 38 +++++++- .commitlintrc.js | 141 ---------------------------- .github/workflows/pr-title-lint.yml | 8 +- 3 files changed, 40 insertions(+), 147 deletions(-) delete mode 100644 .commitlintrc.js diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 0f38b435..cdc68449 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -39,12 +39,14 @@ reviews: mode: "warning" requirements: | PR title MUST follow Conventional Commits format: - - Format: : or !: for breaking changes - - Valid types: Refer to the 'type-enum' rule in .commitlintrc.js file for the complete list of allowed types + - Format: : + - Valid types: Refer to https://github.com/linux-system-roles/auto-maintenance/blob/main/pr_title_lint.py#L23 - Examples: - "feat: Add backup functionality" - "fix: Correct OSTree package installation" - "fix!: Remove deprecated variable (breaking change)" + - "chore(formatting): Fix indentation in my_module.py" + - "refactor(python)!: Use new python library thispy which has breaking api changes" custom_checks: - mode: "warning" @@ -55,6 +57,8 @@ reviews: - Must contain "Reason:" section explaining why the change was needed - Must contain "Result:" section describing the outcome or impact - Can contain optional "Issue Tracker Tickets (Jira or BZ if any):" section + - Must contain "Signed-off-by:" section with your name and email address - use git commit -s + - Can contain optional "Assisted-by:" section with name of the AI coding assistant and models used Example: ``` @@ -65,6 +69,34 @@ reviews: Result: Users can now set certificate_secure_logging: false for debugging while maintaining secure defaults. Issue Tracker Tickets (Jira or BZ if any): RHEL-12345 + + Signed-off-by: John Doe john.doe@example.com + + Assisted-by: Fish 4.3 using model Swim 6.2 + ``` + + For PRs that are bug fixes, you can use the following template: + - Must contain "Cause:" section explaining the root cause of the bug + - Must contain "Consequences:" section explaining the impact of the bug and how it appears to users + - Must contain "Fix:" section explaining the fix for the bug and how it fixes the bug + - Must contain "Result:" section describing the outcome or impact of the fix + - Can contain optional "Issue Tracker Tickets (Jira or BZ if any):" section + - Must contain "Signed-off-by:" section with your name and email address - use git commit -s + - Can contain optional "Assisted-by:" section with name of the AI coding assistant and models used + + Example: + ``` + Cause: The variable rolename_user_name was being checked for a `none` value but was not being checked for string length greater than 0 if a string. + + Consequences: The role allowed empty user names to be configured which caused the daemon to report "User not found". + + Fix: The variable rolename_user_name is now checked for string length if not `none`, and will report an error in that case if the length is 0. + + Result: The role will not allow the user to provide an empty user name and will report an error if the rolename_user_name length is 0. + + Signed-off-by: John Doe john.doe@example.com + + Assisted-by: Fish 4.3 using model Swim 6.2 ``` path_instructions: @@ -180,6 +212,8 @@ reviews: - Tests should verify both success and failure scenarios - Use assert module to verify expected state after role execution - Include cleanup tasks to ensure tests are rerunnable + - Tests should be run in a block with an always section that runs the test cleanup to ensure that the cleanup is always run. + - The cleanup tasks should be tagged with `tests::cleanup` so that the cleanup can be skipped for debug purposes. - Tests should be idempotent - running twice should not cause failures - Example verification: ```yaml diff --git a/.commitlintrc.js b/.commitlintrc.js deleted file mode 100644 index f8a39ba2..00000000 --- a/.commitlintrc.js +++ /dev/null @@ -1,141 +0,0 @@ -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', - ['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', - 'ci', - 'docs', - 'feat', - 'fix', - 'perf', - 'refactor', - 'revert', - 'style', - 'test', - 'tests', - ], - ], - }, - 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: '🚨', - }, - tests: { - 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".)', - }, - }, - }, -}; diff --git a/.github/workflows/pr-title-lint.yml b/.github/workflows/pr-title-lint.yml index 6d183510..a1eeabca 100644 --- a/.github/workflows/pr-title-lint.yml +++ b/.github/workflows/pr-title-lint.yml @@ -22,11 +22,11 @@ jobs: with: fetch-depth: 0 - - name: Install conventional-commit linter - run: npm install @commitlint/config-conventional @commitlint/cli + - name: Install pr_title_lint.py + run: curl -o pr_title_lint.py https://raw.githubusercontent.com/linux-system-roles/auto-maintenance/main/pr_title_lint.py - - name: Run commitlint on PR title + - name: Run pr_title_lint.py on PR title env: PR_TITLE: ${{ github.event.pull_request.title }} # Echo from env variable to avoid bash errors with extra characters - run: echo "$PR_TITLE" | npx commitlint --verbose + run: python3 pr_title_lint.py "${PR_TITLE}"