Skip to content

ci(代码规范检查): 添加 Git Commit Angular 风格检查工作流#13

Merged
Frankoul merged 4 commits intoembyplus:mainfrom
linhemin:main
Feb 11, 2025
Merged

ci(代码规范检查): 添加 Git Commit Angular 风格检查工作流#13
Frankoul merged 4 commits intoembyplus:mainfrom
linhemin:main

Conversation

@linhemin
Copy link
Contributor

@linhemin linhemin commented Feb 10, 2025

  • 新增 GitHub Actions 工作流,检查 PR 中的提交信息是否符合 Angular 规范
  • 在 PR 创建、更新或重新打开时,以及推送至 main 分支时触发检查
  • 使用正则表达式验证提交信息的格式
  • 如果提交信息不符合规范,自动关闭 PR

好的,这是将 pull request 总结翻译成中文的结果:

Sourcery 总结

CI:

  • 添加一个 GitHub Actions 工作流来检查提交信息是否符合 Angular 提交信息规范。
Original summary in English

好的,这是翻译成中文的 pull request 总结:

Sourcery 总结

添加一个 GitHub Actions 工作流程来强制执行 Angular commit message 规范。

CI:

  • 强制执行 pull request 中所有 commit 的 Angular commit message 规范。

文档:

  • 在 README 中记录 Angular commit message 规范。
Original summary in English

Summary by Sourcery

Add a GitHub Actions workflow to enforce the Angular commit message convention.

CI:

  • Enforce Angular commit message convention on all commits in a pull request.

Documentation:

  • Document the Angular commit message convention in the README.

- 新增 GitHub Actions 工作流,检查 PR 中的提交信息是否符合 Angular 规范
- 在 PR 创建、更新或重新打开时,以及推送至 main 分支时触发检查
- 使用正则表达式验证提交信息的格式
- 如果提交信息不符合规范,自动关闭 PR
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 10, 2025

## Sourcery 评审员指南

此 Pull Request 添加了一个新的 GitHub Actions 工作流程,用于强制执行 Angular 提交消息标准,并更新了文档以包含贡献指南。 这些更改包括实施自动提交消息验证,并通过自动关闭不符合要求的 Pull Request 来强制执行该标准,以及更新项目 readme 文件,其中包含详细的贡献步骤。

#### GitHub Actions 提交检查工作流程的顺序图

```mermaid
sequenceDiagram
  actor Developer as Contributor
  participant PR_Event as "Pull Request Event"
  participant Workflow as "GitHub Actions Workflow"
  participant GitAPI as "GitHub API"

  Developer->>PR_Event: Opens/updates PR
  PR_Event->>Workflow: Trigger commit-check workflow
  Workflow->>Workflow: Checkout repository
  Workflow->>Workflow: Retrieve commit messages
  Workflow->>Workflow: Validate commit messages against Angular regex
  alt Commit messages are valid
    Workflow->>Workflow: Continue workflow (PR remains open)
  else Commit messages are invalid
    Workflow->>GitAPI: PATCH PR state to "closed"
  end

文件级别更改

变更 详情 文件
引入了用于 Angular 风格提交消息检查的 GitHub Actions 工作流程。
  • 添加了一个新的工作流程文件,该文件在 pull request 事件和推送到主分支时触发。
  • 实现了一个脚本,用于使用 Git 命令获取提交消息,并根据与 Angular 提交格式匹配的正则表达式对其进行验证。
  • 配置工作流程以在任何提交消息不符合所需格式时自动关闭 pull request。
.github/workflows/commit-check.yml
使用贡献指南更新了项目文档。
  • 在 readme 文件中添加了一个新部分,概述了贡献指南。
  • 详细说明了提交消息约定和支持的提交类型,强调遵守 Angular 提交消息风格。
readme.md

提示和命令

与 Sourcery 互动

  • 触发新的审查: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复审查评论,要求 Sourcery 从审查评论创建一个 issue。 您还可以回复带有 @sourcery-ai issue 的审查评论,以从中创建一个 issue。
  • 生成 pull request 标题: 在 pull request 标题中的任何位置写入 @sourcery-ai 以随时生成标题。 您也可以在 pull request 上评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中的任何位置写入 @sourcery-ai summary 以随时在你想要的任何位置生成 PR 摘要。 您也可以在 pull request 上评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成评审员指南: 在 pull request 上评论 @sourcery-ai guide 以随时(重新)生成评审员指南。
  • 解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。 如果您已经解决了所有评论并且不想再看到它们,这将非常有用。
  • 驳回所有 Sourcery 审查: 在 pull request 上评论 @sourcery-ai dismiss 以驳回所有现有的 Sourcery 审查。 如果你想用一个新的审查重新开始,这尤其有用 - 不要忘记评论 @sourcery-ai review 以触发一个新的审查!
  • 为 issue 生成行动计划: 在 issue 上评论 @sourcery-ai plan 以为其生成行动计划。

自定义您的体验

访问您的 仪表板 以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、评审员指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获得帮助

```
Original review guide in English

Reviewer's Guide by Sourcery

This pull request adds a new GitHub Actions workflow that enforces Angular commit message standards and updates the documentation to include contribution guidelines. The changes include implementing automated commit message validation and enforcing the standard by automatically closing non-compliant pull requests, as well as updating the project readme with detailed contribution steps.

Sequence diagram for GitHub Actions Commit Check Workflow

sequenceDiagram
  actor Developer as Contributor
  participant PR_Event as "Pull Request Event"
  participant Workflow as "GitHub Actions Workflow"
  participant GitAPI as "GitHub API"

  Developer->>PR_Event: Opens/updates PR
  PR_Event->>Workflow: Trigger commit-check workflow
  Workflow->>Workflow: Checkout repository
  Workflow->>Workflow: Retrieve commit messages
  Workflow->>Workflow: Validate commit messages against Angular regex
  alt Commit messages are valid
    Workflow->>Workflow: Continue workflow (PR remains open)
  else Commit messages are invalid
    Workflow->>GitAPI: PATCH PR state to "closed"
  end
Loading

File-Level Changes

Change Details Files
Introduced a GitHub Actions workflow for Angular-style commit message checking.
  • Added a new workflow file that triggers on pull request events and pushes to the main branch.
  • Implemented a script to fetch commit messages using Git commands and validate them against a regular expression matching the Angular commit format.
  • Configured the workflow to automatically close the pull request if any commit message does not conform to the required format.
.github/workflows/commit-check.yml
Updated the project documentation with contribution guidelines.
  • Added a new section in the readme outlining the contribution guidelines.
  • Detailed the commit message conventions and the supported commit types, emphasizing adherence to Angular commit message style.
readme.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @linhemin - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a pre-built action for commit message validation to simplify the workflow configuration.
  • The workflow currently closes the PR on invalid commits; consider adding a comment to the PR explaining why it was closed.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Replace deprecated echo "::set-output name=messages::$COMMITS" with
echo "messages=$COMMITS" >> $GITHUB_OUTPUT in the GitHub Actions workflow.
@linhemin
Copy link
Contributor Author

@sourcery-ai review

@linhemin
Copy link
Contributor Author

@sourcery-ai review

- 使用 EOF 标记替代单行输出,以正确处理多行提交信息
- 优化了 GitHub Actions 工作流中的变量输出方式
@linhemin
Copy link
Contributor Author

示例:linhemin#3 (comment)

@Frankoul Frankoul merged commit 1da2852 into embyplus:main Feb 11, 2025
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.

2 participants