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

fix: test & ci on 2x branch #2758

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

Alex-huxiyang
Copy link
Collaborator

@Alex-huxiyang Alex-huxiyang commented Nov 15, 2024

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 新功能
    • 新增了 GitHub Actions 工作流 add-label.yml,用于根据拉取请求的目标分支自动添加标签。
  • CI 流程改进
    • 修改了 CI 工作流触发事件,从 pull_request_target 更改为 pull_request
    • 移除了 add-label 作业,简化了 CI 流程。
    • 在构建作业中添加了条件执行,仅在分支为 next 时构建。

Copy link

coderabbitai bot commented Nov 15, 2024

Walkthrough

本次变更引入了一个新的GitHub Actions工作流文件add-label.yml,用于在特定的拉取请求事件触发时自动添加标签。该工作流在拉取请求被打开、同步、重新打开或手动触发时运行。与此同时,现有的CI工作流ci.yml进行了修改,移除了添加标签的作业,并调整了事件触发方式及构建步骤的条件执行。

Changes

文件路径 变更摘要
.github/workflows/add-label.yml 新增工作流文件add-label.yml,用于根据目标分支自动添加标签。
.github/workflows/ci.yml 修改事件触发为pull_request,移除add-label作业,调整构建步骤的条件执行。

Possibly related PRs

  • chore: ci #2678: 此PR修改了CI工作流,移除了workflow_dispatch触发器和dev-harmony分支,相关于本PR中引入的新标签工作流。
  • chore: ci auto branch label 【support current repo】 #2687: 此PR为CI工作流添加了一个新作业,自动根据基础分支标记拉取请求,直接与本PR中引入的功能相关。
  • chore: ci #2690: 此PR重命名了CI工作流中的标签添加作业,涉及本PR中关于新增标签工作流的变更。
  • chore: ci optimize #2692: 此PR优化了CI工作流,简化了添加标签的条件,连接到本PR中引入的标签添加功能。

Suggested labels

size/M, 2.x

Suggested reviewers

  • oasis-cloud

Poem

在兔子洞里忙碌跑,
新工作流来真是好。
标签添加真方便,
CI流程更流畅,
兔子欢跳乐无穷,
代码更新真美妙! 🐇✨


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.

@github-actions github-actions bot added the 2.x label Nov 15, 2024
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.07%. Comparing base (66e9d1b) to head (f6c8657).

Additional details and impacted files
@@            Coverage Diff            @@
##           next    #2758       +/-   ##
=========================================
+ Coverage      0   84.07%   +84.07%     
=========================================
  Files         0      217      +217     
  Lines         0    17831    +17831     
  Branches      0     2609     +2609     
=========================================
+ Hits          0    14992    +14992     
- Misses        0     2834     +2834     
- Partials      0        5        +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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: 2

🧹 Outside diff range and nitpick comments (2)
.github/workflows/add-label.yml (1)

28-33: 建议添加错误处理和文件结尾换行符

  1. 缺少对标签添加操作失败时的错误处理
  2. 文件末尾缺少换行符

建议修改为:

      - name: Add label to Pull Request
        if: env.label != ''
        uses: actions-ecosystem/action-add-labels@v1
+       continue-on-error: true
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
-         labels: ${{ env.label }}
+         labels: ${{ env.label }}
+
🧰 Tools
🪛 yamllint

[error] 33-33: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/ci.yml (1)

84-84: 建议:添加文件末尾的换行符

根据 POSIX 标准,每个文本文件都应该以换行符结束。

 if: github.ref == 'refs/heads/next'
-        run: npm run build:taro:site
+        run: npm run build:taro:site
+
🧰 Tools
🪛 yamllint

[error] 84-84: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 66e9d1b and f6c8657.

⛔ Files ignored due to path filters (2)
  • src/packages/range/__test__/__snapshots__/range.spec.tsx.snap is excluded by !**/*.snap
  • src/packages/textarea/__test__/__snapshots__/textarea.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • .github/workflows/add-label.yml (1 hunks)
  • .github/workflows/ci.yml (2 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/add-label.yml

18-18: shellcheck reported issue in this script: SC2086:info:3:23: Double quote to prevent globbing and word splitting

(shellcheck)


18-18: shellcheck reported issue in this script: SC2086:info:5:23: Double quote to prevent globbing and word splitting

(shellcheck)


18-18: shellcheck reported issue in this script: SC2086:info:7:20: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint
.github/workflows/add-label.yml

[error] 33-33: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/ci.yml

[error] 84-84: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (3)
.github/workflows/add-label.yml (1)

1-33: 验证工作流程的完整性

需要验证此工作流是否正确集成到现有的 CI/CD 流程中。

✅ Verification successful

工作流程集成验证完成

工作流程已正确集成,原因如下:

  • 标签操作没有冲突:仅在 add-label.yml 中使用 action-add-labels 进行 PR 标签管理,其他工作流中的标签操作(如 issue-reply.ymlissue-close.yml)都是针对 issues 的不同场景。

  • 触发器设置合理:

    • add-label.yml 使用 pull_request_target 是独特的,没有与其他工作流冲突
    • 其他工作流使用不同的触发器(如 pushscheduleissues),各司其职
  • 完整性良好:工作流职责划分清晰,add-label.yml 专注于 PR 分支标签管理,与其他 CI/CD 工作流(如 ci.ymlsync-*.yml)形成互补。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查其他工作流程文件中是否存在重复的标签操作

# 搜索其他工作流程文件中的标签相关操作
echo "检查其他工作流程文件中的标签操作..."
rg -l "action-add-labels" .github/workflows/ | grep -v "add-label.yml"

# 检查是否有其他工作流使用相同的触发器
echo "检查触发器重复..."
rg "pull_request_target" .github/workflows/ | grep -v "add-label.yml"

Length of output: 471


Script:

#!/bin/bash
# 检查工作流程文件的完整性

# 列出所有工作流程文件
echo "所有工作流程文件:"
fd -e yml -e yaml . .github/workflows/

# 检查是否有其他标签相关的操作
echo -e "\n查找标签相关操作:"
rg -i "labels?" .github/workflows/ -A 2 -B 2

# 检查所有工作流程的触发器
echo -e "\n所有工作流程的触发器:"
rg "^on:" .github/workflows/ -A 5

Length of output: 5681

🧰 Tools
🪛 actionlint

18-18: shellcheck reported issue in this script: SC2086:info:3:23: Double quote to prevent globbing and word splitting

(shellcheck)


18-18: shellcheck reported issue in this script: SC2086:info:5:23: Double quote to prevent globbing and word splitting

(shellcheck)


18-18: shellcheck reported issue in this script: SC2086:info:7:20: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint

[error] 33-33: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/ci.yml (2)

8-8: 从 pull_request_target 切换到 pull_request 事件是一个很好的安全改进!

这个改动提高了工作流的安全性,因为 pull_request 事件在隔离的环境中运行,不会暴露仓库的敏感信息。


83-84: 验证 Taro H5 演示构建的条件执行

构建步骤的条件限制看起来合理,但建议验证这个改动不会影响其他分支的部署需求。

✅ Verification successful

Taro H5 演示构建条件验证已完成

经过验证,当前的构建配置是合理的:

  • build:taro:site 脚本仅在 next 分支的工作流中被调用
  • 其他分支(如 V3.0)的工作流中没有使用此构建步骤
  • 这个条件限制不会影响其他分支的部署需求
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证其他分支是否需要构建 Taro H5 演示

# 检查其他分支的部署配置
rg -l "build:taro:site" --type yaml

Length of output: 35


Script:

#!/bin/bash
# 检查 package.json 中的 build:taro:site 脚本定义
cat package.json | jq -r '.scripts["build:taro:site"]'

# 检查所有工作流文件中的构建步骤
fd -e yml -e yaml . .github/workflows/ --exec cat {}

Length of output: 7948

🧰 Tools
🪛 yamllint

[error] 84-84: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/add-label.yml Show resolved Hide resolved
Comment on lines +16 to +26
- name: Determine label based on target branch
id: determine-label
run: |
echo "${{github.event_name}}"
if [[ "${{ github.event.pull_request.base.ref }}" == "next" ]]; then
echo "label=2.x" >> $GITHUB_ENV
elif [[ "${{ github.event.pull_request.base.ref }}" == "V3.0" ]]; then
echo "label=3.x" >> $GITHUB_ENV
else
echo "label=" >> $GITHUB_ENV
fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

优化标签判断逻辑的实现

当前实现存在以下问题:

  1. 缺少对 github.event.pull_request 是否存在的检查
  2. shell 脚本中的变量引用没有使用双引号
  3. 调试信息 echo "${{github.event_name}}" 应该移除

建议修改为:

      - name: Determine label based on target branch
        id: determine-label
        run: |
-         echo "${{github.event_name}}"
+         if [[ "${{ github.event_name }}" == "pull_request_target" && -n "${{ github.event.pull_request.base.ref }}" ]]; then
            if [[ "${{ github.event.pull_request.base.ref }}" == "next" ]]; then
              echo "label=2.x" >> "$GITHUB_ENV"
            elif [[ "${{ github.event.pull_request.base.ref }}" == "V3.0" ]]; then
              echo "label=3.x" >> "$GITHUB_ENV"
            else
              echo "label=" >> "$GITHUB_ENV"
            fi
+         else
+           echo "label=" >> "$GITHUB_ENV"
+         fi
📝 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
- name: Determine label based on target branch
id: determine-label
run: |
echo "${{github.event_name}}"
if [[ "${{ github.event.pull_request.base.ref }}" == "next" ]]; then
echo "label=2.x" >> $GITHUB_ENV
elif [[ "${{ github.event.pull_request.base.ref }}" == "V3.0" ]]; then
echo "label=3.x" >> $GITHUB_ENV
else
echo "label=" >> $GITHUB_ENV
fi
- name: Determine label based on target branch
id: determine-label
run: |
if [[ "${{ github.event_name }}" == "pull_request_target" && -n "${{ github.event.pull_request.base.ref }}" ]]; then
if [[ "${{ github.event.pull_request.base.ref }}" == "next" ]]; then
echo "label=2.x" >> "$GITHUB_ENV"
elif [[ "${{ github.event.pull_request.base.ref }}" == "V3.0" ]]; then
echo "label=3.x" >> "$GITHUB_ENV"
else
echo "label=" >> "$GITHUB_ENV"
fi
else
echo "label=" >> "$GITHUB_ENV"
fi
🧰 Tools
🪛 actionlint

18-18: shellcheck reported issue in this script: SC2086:info:3:23: Double quote to prevent globbing and word splitting

(shellcheck)


18-18: shellcheck reported issue in this script: SC2086:info:5:23: Double quote to prevent globbing and word splitting

(shellcheck)


18-18: shellcheck reported issue in this script: SC2086:info:7:20: Double quote to prevent globbing and word splitting

(shellcheck)

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

Successfully merging this pull request may close these issues.

1 participant