Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Dec 12, 2024

Conversation

davemarco
Copy link
Contributor

@davemarco davemarco commented Dec 11, 2024

This PR is a copy of log viewer PR

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.

Validation performed
success: https://github.com/davemarco/clp-ffi-js-fork/actions/runs/12279470331/job/34263582133?pr=5
failed: https://github.com/davemarco/clp-ffi-js-fork/actions/runs/12279398120/job/34263345957?pr=4

Summary by CodeRabbit

  • New Features

    • Introduced a new GitHub Actions workflow to enforce conventional commit message standards for pull requests.
    • Updated the pull request template to clarify title formatting requirements, including an example of a compliant commit message.
  • Documentation

    • Enhanced instructions in the pull request template for setting the PR title.

Copy link

coderabbitai bot commented Dec 11, 2024

Walkthrough

The pull request introduces modifications to the pull request template and adds a new GitHub Actions workflow. The template now emphasizes the need for pull request titles to conform to the Conventional Commits specification, including an example for clarity. Additionally, the new workflow, pr-title-checks.yaml, is designed to enforce these title standards by validating the format of pull request titles upon specific events.

Changes

File Change Summary
.github/PULL_REQUEST_TEMPLATE.md Updated instructions for PR title formatting to include adherence to Conventional Commits, with an example provided.
.github/workflows/pr-title-checks.yaml Introduced a new workflow that checks pull request titles for compliance with Conventional Commits upon PR events.

Suggested reviewers

  • junhaoliao

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0fa7cdc and 0ac984c.

📒 Files selected for processing (1)
  • .github/workflows/pr-title-checks.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/pr-title-checks.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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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.

@davemarco davemarco requested a review from junhaoliao December 11, 2024 15:25
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

16-26: Consider adding custom validation configuration

The basic setup is good, but consider enhancing it with custom configuration options provided by the action:

  • Custom error messages for better user experience
  • Specific commit type scopes for your project
  • Custom commit types if needed

Here's a suggested enhancement:

 - uses: "amannn/action-semantic-pull-request@v5"
   env:
     GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
+    with:
+      # Add custom types beyond conventional commit types
+      types: |
+        feat
+        fix
+        docs
+        style
+        refactor
+        perf
+        test
+        build
+        ci
+        chore
+        revert
+      # Custom error message
+      errorComment: |
+        Please ensure your pull request title follows the Conventional Commits specification:
+        https://www.conventionalcommits.org/
+
+        Example: feat(parser): add ability to parse arrays
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 01aa3a5 and b12d8a0.

📒 Files selected for processing (2)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • .github/workflows/pr-title-checks.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/PULL_REQUEST_TEMPLATE.md
🔇 Additional comments (2)
.github/workflows/pr-title-checks.yaml (2)

8-15: LGTM! Well-configured permissions and concurrency settings

The configuration follows security best practices:

  • Minimal permissions following principle of least privilege
  • Efficient concurrency handling to prevent redundant runs

3-6: Verify security implications of using pull_request_target

The use of pull_request_target is acceptable here since the workflow only reads PR metadata and doesn't check out or execute PR code. However, be cautious about future modifications to this workflow.

Run this check to verify no risky actions are present:

✅ Verification successful

Use of pull_request_target is secure in this workflow

The workflow is properly configured and secure:

  • No checkout action is present
  • Only uses amannn/action-semantic-pull-request which reads PR metadata
  • Minimal permissions are set (permissions: {} with only pull-requests: read)
  • No script execution or PR code access
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potentially risky actions in the workflow
# Look for checkout actions or script execution
rg -i "uses:\s+actions/checkout@|run:" .github/workflows/pr-title-checks.yaml

Length of output: 79


Script:

#!/bin/bash
# Let's view the entire workflow file content to verify all actions used
cat .github/workflows/pr-title-checks.yaml

Length of output: 598

@junhaoliao junhaoliao changed the title ci: Add GH workflow to validate PR titles follow Conventional Commits. ci: Add GH workflow to validate PR titles follow Conventional Commits. Dec 11, 2024
junhaoliao
junhaoliao previously approved these changes Dec 11, 2024
Copy link
Member

@junhaoliao junhaoliao left a comment

Choose a reason for hiding this comment

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

compared with y-scope/yscope-log-viewer#121 and this lgtm

@kirkrodrigues
Copy link
Member

Sorry, can we update it to follow https://github.com/y-scope/clp-loglib-py/blob/main/.github/workflows/pr-title-checks.yaml? That's the latest version of this that we should propagate across all repos.

@davemarco davemarco merged commit d2556b2 into y-scope:main Dec 12, 2024
3 checks passed
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.

3 participants