-
Notifications
You must be signed in to change notification settings - Fork 263
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
chore: ci auto branch label 【support current repo】 #2687
Conversation
Walkthrough此次更改在GitHub Actions CI工作流中新增了一个名为 Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2687 +/- ##
=======================================
Coverage 84.07% 84.07%
=======================================
Files 217 217
Lines 17830 17830
Branches 2608 2608
=======================================
Hits 14991 14991
Misses 2834 2834
Partials 5 5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (1)
.github/workflows/ci.yml (1)
96-106
: 建议优化构建流程当前构建步骤是顺序执行的,可以考虑优化以提高效率。
建议考虑以下优化方案:
- 将不同的构建任务拆分为独立的作业,实现并行构建
- 使用构建缓存来加速重复构建
- 考虑使用 build matrix 来并行处理不同的构建目标
如果需要具体的实现方案,我可以提供详细的配置示例。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/ci.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/ci.yml
24-24: shellcheck reported issue in this script: SC2086:info:2:23: Double quote to prevent globbing and word splitting
(shellcheck)
24-24: shellcheck reported issue in this script: SC2086:info:4:23: Double quote to prevent globbing and word splitting
(shellcheck)
- uses: actions/checkout@v4 | ||
|
||
- name: Install pnpm | ||
run: corepack enable pnpm | ||
- name: Install pnpm | ||
run: corepack enable pnpm | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'pnpm' | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run linter | ||
run: npm run lint | ||
- name: Run linter | ||
run: npm run lint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
建议优化缓存配置以提升 CI 性能
当前的缓存配置仅使用了基本的 pnpm 缓存。建议添加更多缓存策略以提升构建速度。
建议应用以下优化:
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
+ cache-dependency-path: '**/pnpm-lock.yaml'
- name: Install dependencies
run: pnpm install
+ env:
+ HUSKY: '0'
📝 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.
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
run: corepack enable pnpm | |
- name: Install pnpm | |
run: corepack enable pnpm | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'pnpm' | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run linter | |
run: npm run lint | |
- name: Run linter | |
run: npm run lint | |
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
run: corepack enable pnpm | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'pnpm' | |
cache-dependency-path: '**/pnpm-lock.yaml' | |
- name: Install dependencies | |
run: pnpm install | |
env: | |
HUSKY: '0' | |
- name: Run linter | |
run: npm run lint |
- name: Upload coverage reports to Codecov | ||
if: ${{ always() }} | ||
uses: codecov/codecov-action@v4 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
建议增强测试报告配置
当前的 Codecov 配置可以进一步优化以提供更好的测试覆盖率报告。
建议添加以下配置:
- name: Upload coverage reports to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v4
+ with:
+ fail_ci_if_error: true
+ verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
📝 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.
- name: Upload coverage reports to Codecov | |
if: ${{ always() }} | |
uses: codecov/codecov-action@v4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
- name: Upload coverage reports to Codecov | |
if: ${{ always() }} | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
verbose: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
label: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Determine label | ||
id: determine_label | ||
run: | | ||
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 | ||
fi | ||
|
||
- name: Add label to PR | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: ${{ env.label }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要改进自动标签工作流的健壮性
当前实现存在以下问题:
- 没有处理基础分支不是 'next' 或 'V3.0' 的情况
- 在 push 事件时也会运行,但此时没有 PR 上下文
- Shell 脚本中的变量引用需要加引号以提高安全性
建议应用以下修改:
label:
runs-on: ubuntu-latest
+ if: github.event_name == 'pull_request'
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Determine label
id: determine_label
run: |
if [[ "${{ github.event.pull_request.base.ref }}" == "next" ]]; then
- echo "label=2.x" >> $GITHUB_ENV
+ echo "label=2.x" >> "$GITHUB_ENV"
elif [[ "${{ github.event.pull_request.base.ref }}" == "V3.0" ]]; then
- echo "label=3.x" >> $GITHUB_ENV
+ echo "label=3.x" >> "$GITHUB_ENV"
+ else
+ echo "label=pending-review" >> "$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.
label: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Determine label | |
id: determine_label | |
run: | | |
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 | |
fi | |
- name: Add label to PR | |
uses: actions-ecosystem/action-add-labels@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
labels: ${{ env.label }} | |
label: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Determine label | |
id: determine_label | |
run: | | |
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=pending-review" >> "$GITHUB_ENV" | |
fi | |
- name: Add label to PR | |
uses: actions-ecosystem/action-add-labels@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
labels: ${{ env.label }} |
🧰 Tools
🪛 actionlint
24-24: shellcheck reported issue in this script: SC2086:info:2:23: Double quote to prevent globbing and word splitting
(shellcheck)
24-24: shellcheck reported issue in this script: SC2086:info:4:23: Double quote to prevent globbing and word splitting
(shellcheck)
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit
label
作业,以根据拉取请求的基础分支自动添加标签。lint
、test
和build
作业进行了格式和缩进的调整,以提高可读性。