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

chore: add npm test ver #166

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions .github/workflows/test-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: react component workflow

on: [workflow_call]

jobs:
react-component-workflow:
name: react component workflow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: npm i --legacy-peer-deps
Copy link

@coderabbitai coderabbitai bot Dec 6, 2024

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

建议移除 Bun 设置并解决依赖问题

根据分析,发现以下问题:

  • 代码库中没有任何 Bun 相关的配置或使用场景
  • package.json 中存在 React 的对等依赖(peerDependencies)要求 >=16.9.0
  • 项目直接依赖(dependencies)使用 React ^18.0.0
  • 没有发现使用 --legacy-peer-deps 的必要性说明

建议修改:

  • 移除不必要的 Bun 设置步骤
  • 移除 --legacy-peer-deps 标志,因为项目的依赖版本要求是兼容的
-      - uses: oven-sh/setup-bun@v2
-      - run: npm i --legacy-peer-deps
+      - run: npm i
🔗 Analysis chain

验证 Bun 设置的必要性

既然这是一个专门用于 npm 测试的工作流程,建议移除 Bun 的设置步骤,除非有特殊需求。另外,使用 --legacy-peer-deps 标志可能会掩盖实际的依赖问题。

建议以下修改:

  1. 移除 Bun 设置
  2. 考虑移除 --legacy-peer-deps 标志,或添加说明注释解释其必要性
-      - uses: oven-sh/setup-bun@v2
-      - run: npm i --legacy-peer-deps
+      - run: npm i

运行以下脚本验证依赖关系:


Let me gather more information about potential Bun usage in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查 package.json 中的 peerDependencies
cat package.json | jq '.peerDependencies'

# 检查是否存在多个 React 版本声明
rg -g "package*.json" "\"react\": \".*\""

Length of output: 209


Script:

#!/bin/bash
# Check for Bun related configurations
rg -g "package*.json" "bun"
rg -g "*.yml" "bun"

# Check for any build or test scripts that might require Bun
cat package.json | jq '.scripts'

# Check if there are any specific comments about legacy-peer-deps necessity
rg -g "package*.json" "legacy-peer-deps"
rg -g "*.md" -i "legacy.?peer.?deps"

Length of output: 509

Copy link
Member

Choose a reason for hiding this comment

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

不需要 bun 了吧

Copy link

Choose a reason for hiding this comment

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

@afc163,是的,我们不需要 Bun,可以移除相关的设置步骤。更新后的 .github/workflows/test-npm.yml 文件如下:

name: react component workflow

on: [workflow_call]

jobs:
  react-component-workflow:
    name: react component workflow
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm i
      - run: npm run lint
      - run: npx tsc --noEmit
      - run: npm run compile
      - run: npm run test -- --coverage
      - uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}

Copy link
Member Author

Choose a reason for hiding this comment

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

bun 比 npm 快,其他 rc 库不涉及 React 19 的还能继续用着。

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Member

Choose a reason for hiding this comment

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

这个 workflow 里没用到 bun。

Copy link
Member Author

Choose a reason for hiding this comment

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

哦,我误会你的意思了。可以删

- run: npm run lint
- run: npx tsc --noEmit
- run: npm run compile
- run: npm run test -- --coverage
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}