Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/add-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Add Label

on:
pull_request_target:
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
add-label:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- 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
Comment on lines +16 to +26
Copy link
Copy Markdown

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)


- name: Add label to Pull Request
if: env.label != ''
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: ${{ env.label }}
31 changes: 3 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- next
- V3.0
pull_request_target:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

Expand Down Expand Up @@ -80,30 +80,5 @@ jobs:
run: npm run build:site

- name: Build NutUI-React Taro H5 Demo
run: npm run build:taro:site

add-label:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- 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: Add label to Pull Request
if: env.label != ''
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: ${{ env.label }}
if: github.ref == 'refs/heads/next'
run: npm run build:taro:site
47 changes: 0 additions & 47 deletions src/packages/range/__test__/__snapshots__/range.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,55 +41,8 @@ exports[`range props test 1`] = `
</div>
`;

exports[`range props test 2`] = `
<div>
<div
class="nut-range-container test-range"
>
<div
class="min"
>
0
</div>
<div
class="nut-range"
>
<div
class="nut-range-bar"
style="width: 40%; left: 0%; transition: none;"
>
<div
class="nut-range-button-wrapper"
>
<div
class="nut-range-button"
>
<div
class="number"
>
40
</div>
</div>
</div>
</div>
</div>
<div
class="max"
>
100
</div>
</div>
</div>
`;

exports[`range test 1`] = `
"<div><div class="nut-range-container"><div class="min">0</div><div class="nut-range"><div class="nut-range-bar" style="width: 30%; left: 30%; transition: none;"><div class="nut-range-button-wrapper-left
"><div class="nut-range-button"><div class="number">30</div></div></div><div class="
nut-range-button-wrapper-right"><div class="nut-range-button"><div class="number">60</div></div></div></div></div><div class="max">100</div></div></div>"
`;

exports[`range test 2`] = `
"<div><div class="nut-range-container"><div class="min">0</div><div class="nut-range"><div class="nut-range-bar" style="width: 30%; left: 30%; transition: none;"><div class="nut-range-button-wrapper-left
"><div class="nut-range-button"><div class="number">30</div></div></div><div class="
nut-range-button-wrapper-right"><div class="nut-range-button"><div class="number">60</div></div></div></div></div><div class="max">100</div></div></div>"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`textarea props test 1`] = `
<textarea
class="nut-textarea-textarea"
maxlength="20"
placeholder="请输入内容"
placeholder=""
rows="2"
>
基础用法
Expand Down