Skip to content

ci: Add GH workflow to validate PR titles follow Conventional Commits.#1

Merged
kirkrodrigues merged 3 commits into
y-scope:mainfrom
kirkrodrigues:add-pr-title-workflow
Oct 23, 2024
Merged

ci: Add GH workflow to validate PR titles follow Conventional Commits.#1
kirkrodrigues merged 3 commits into
y-scope:mainfrom
kirkrodrigues:add-pr-title-workflow

Conversation

@kirkrodrigues

@kirkrodrigues kirkrodrigues commented Oct 23, 2024

Copy link
Copy Markdown
Member

Description

Convention Commits is a specification for writing commit messages (or in our case, PR titles) that makes it easy to see at a glance what change the commit makes which in turn makes it easier to generate release notes.

This PR adds a workflow to check PR titles match the spec.

Validation performed

  • Merged this PR into my fork.
  • Created a PR to kirkrodrigues/main, triggering the workflow.
  • Validated that changing the PR title triggered the workflow.
  • Validated that the workflow detected invalid PR titles (e.g., starting with a capital letter, using an unknown type, etc.).

Summary by CodeRabbit

  • New Features

    • Introduced a new GitHub Actions workflow for managing pull request titles, enhancing commit message standards.
  • Chores

    • Configured concurrency settings for improved job efficiency within the workflow.

@coderabbitai

coderabbitai Bot commented Oct 23, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

A new GitHub Actions workflow file named pr-title.yaml has been added to the repository. This workflow is triggered by pull request events such as edits, openings, or reopenings targeting the main branch. It includes a concurrency setting to manage job execution efficiently. The workflow defines a job called conventional-commits, which runs in an ubuntu-latest environment and utilizes a specific action to enforce semantic commit message standards.

Changes

File Path Change Summary
.github/workflows/pr-title.yaml Introduced a new workflow for pull request title checks, including job configuration and concurrency settings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub
    participant Action

    User->>GitHub: Open/Edit/Reopen PR
    GitHub->>Action: Trigger `pr-title` workflow
    Action->>Action: Check commit message standards
    Action->>GitHub: Return results
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2c776e8 and c145326.

📒 Files selected for processing (1)
  • .github/workflows/pr-title.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/pr-title.yaml

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
.github/workflows/pr-title.yaml (1)

17-23: Consider using major version tag

While pinning to a specific version (v5.5.3) provides stability, consider using the major version tag (v5) to automatically receive compatible updates, including security patches.

Apply this change:

-      - uses: "amannn/action-semantic-pull-request@v5.5.3"
+      - uses: "amannn/action-semantic-pull-request@v5"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 44e8f3f and 2c776e8.

📒 Files selected for processing (1)
  • .github/workflows/pr-title.yaml (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
.github/workflows/pr-title.yaml (3)

3-6: LGTM! Safe usage of pull_request_target

The trigger configuration is appropriate for this use case. Using pull_request_target instead of pull_request is correct here since:

  1. We're only using a trusted action
  2. We need the workflow to run on PRs from forks
  3. We're not checking out or executing any code from the PR

8-9: LGTM! Follows principle of least privilege

The permissions are correctly configured to the minimum required level (read) for pull requests.


21-23: Verify conventional commit configuration requirements

The action is using default settings for allowed types, scopes, and other validation rules. Consider if you need to customize these to match your project's commit message guidelines.

Let's check if the repository has existing commit message guidelines:

✅ Verification successful

Let me check for any other conventional commit configuration or guidelines in the repository:


Let me do one final check to see if there are any existing commit messages that might indicate the project's conventions:


Default conventional commit configuration is appropriate for this project

Based on the investigation:

  • This is a new project with only initial commits
  • The PR title validation workflow was just added
  • No existing commit message guidelines or configurations were found
  • The commit messages already follow conventional commit format (e.g., "ci: Add GH workflow...")

Using the default configuration of action-semantic-pull-request is actually a good starting point as it enforces the standard conventional commit types without being overly restrictive. As the project evolves, the team can add custom configurations if needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Look for commit message guidelines in common locations

echo "Checking for commit message guidelines..."
rg -i "commit.*(message|style|convention)" README.md || true
rg -i "conventional.?commit" README.md || true

echo "Checking for commit-related configuration..."
fd "commitlint" --type f
fd "commit-msg" --type f

Length of output: 451


Script:

#!/bin/bash
# Look for other common locations and formats of commit conventions

# Check for package.json commitlint config
echo "Checking package.json for commit-related configs..."
fd "package.json" --type f --exec grep -l "commit\|conventional" {} \; --exec cat {} \;

# Check for any other potential config files
echo -e "\nChecking for other config files..."
fd -e yml -e yaml -e json -e js -e config.js --exec grep -l "commit\|conventional" {} \;

# Check for PR templates that might contain commit guidelines
echo -e "\nChecking PR templates..."
fd "pull_request_template" --type f
fd "PULL_REQUEST_TEMPLATE" --type f

Length of output: 522


Script:

#!/bin/bash
# Check recent commit messages for patterns
echo "Analyzing recent commit messages..."
git log -n 10 --pretty=format:"%s"

# Check if semantic PR action is used elsewhere
echo -e "\nChecking for other semantic PR configurations..."
rg "amannn/action-semantic-pull-request" -A 5 -B 5

Length of output: 419

Comment on lines +11 to +15
concurrency:
group: "${{github.workflow}}-${{github.ref}}"

# Cancel in-progress jobs for efficiency
cancel-in-progress: true

@coderabbitai coderabbitai Bot Oct 23, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix YAML indentation

The cancel-in-progress key should be aligned with the group key under concurrency.

Apply this fix:

 concurrency:
   group: "${{github.workflow}}-${{github.ref}}"
-
-  # Cancel in-progress jobs for efficiency
-  cancel-in-progress: true
+  cancel-in-progress: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
concurrency:
group: "${{github.workflow}}-${{github.ref}}"
# Cancel in-progress jobs for efficiency
cancel-in-progress: true
concurrency:
group: "${{github.workflow}}-${{github.ref}}"
cancel-in-progress: true

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are aligned, but you're suggesting removing the comment, which doesn't make sense.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirkrodrigues, you're absolutely right. I apologize for the confusion. The keys are correctly aligned, and my previous suggestion was incorrect. Please disregard it.


✏️ Learnings added
Learnt from: kirkrodrigues
PR: y-scope/spider#1
File: .github/workflows/pr-title.yaml:11-15
Timestamp: 2024-10-23T02:23:12.040Z
Learning: Ensure to carefully check YAML indentation before suggesting fixes, and avoid removing comments unless necessary.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@kirkrodrigues

Copy link
Copy Markdown
Member Author

@coderabbitai configuration

@coderabbitai

coderabbitai Bot commented Oct 23, 2024

Copy link
Copy Markdown
Contributor
CodeRabbit configuration
language: en-CA
tone_instructions: ''
early_access: false
enable_free_tier: true
reviews:
  profile: chill
  request_changes_workflow: false
  high_level_summary: true
  high_level_summary_placeholder: '@coderabbitai summary'
  auto_title_placeholder: '@coderabbitai'
  review_status: true
  commit_status: true
  poem: false
  collapse_walkthrough: false
  sequence_diagrams: true
  changed_files_summary: true
  labeling_instructions: []
  path_filters: []
  path_instructions: []
  abort_on_close: true
  auto_review:
    enabled: true
    auto_incremental_review: true
    ignore_title_keywords: []
    labels: []
    drafts: false
    base_branches: []
  tools:
    shellcheck:
      enabled: true
    ruff:
      enabled: true
    markdownlint:
      enabled: true
    github-checks:
      enabled: true
      timeout_ms: 90000
    languagetool:
      enabled: true
      enabled_only: false
      level: default
    biome:
      enabled: true
    hadolint:
      enabled: true
    swiftlint:
      enabled: true
    phpstan:
      enabled: true
      level: default
    golangci-lint:
      enabled: true
    yamllint:
      enabled: true
    gitleaks:
      enabled: true
    checkov:
      enabled: true
    detekt:
      enabled: true
    eslint:
      enabled: true
    rubocop:
      enabled: true
    buf:
      enabled: true
    regal:
      enabled: true
    actionlint:
      enabled: true
    pmd:
      enabled: true
    cppcheck:
      enabled: true
    semgrep:
      enabled: true
    circleci:
      enabled: true
chat:
  auto_reply: true
knowledge_base:
  opt_out: false
  learnings:
    scope: auto
  issues:
    scope: auto
  jira:
    project_keys: []
  linear:
    team_keys: []
  pull_requests:
    scope: auto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant