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

chore: add npm test ver #166

merged 2 commits into from
Dec 6, 2024

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Dec 6, 2024

bun 在多版本下,会错误提升 React 版本。加个 npm 纯血版测试:

截屏2024-12-06 17 37 56

Summary by CodeRabbit

  • 新功能
    • 引入了新的 GitHub Actions 工作流 test-npm.yml,用于测试 React 组件。
    • 该工作流自动执行代码检查、类型检查、编译和测试,确保代码质量和覆盖率。

Copy link

coderabbitai bot commented Dec 6, 2024

Warning

Rate limit exceeded

@zombieJ has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4aa3cf7 and d770d89.

Walkthrough

在此次更改中,新增了一个名为 test-npm.yml 的 GitHub Actions 工作流文件,用于测试 React 组件。该工作流通过 workflow_call 事件触发,允许其他工作流调用。工作流定义了一个名为 react-component-workflow 的作业,运行在最新版本的 Ubuntu 上,包含多个步骤,如检查出代码库、设置 Bun 包管理器、安装 npm 依赖、代码 linting、类型检查、项目编译、执行测试及上传覆盖率报告到 Codecov。

Changes

文件路径 更改摘要
.github/workflows/test-npm.yml 新增 GitHub Actions 工作流,用于测试 React 组件

Poem

在兔子洞中忙碌的我,
新工作流如春风拂过。
测试组件,确保无误,
代码覆盖,报告送到。
让我们欢庆这变化,
兔子们跳跃,乐无穷! 🐇✨


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.

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

🧹 Outside diff range and nitpick comments (3)
.github/workflows/test-npm.yml (3)

1-3: 建议优化工作流程名称以更好地反映其用途

当前名称 "react component workflow" 过于笼统,建议修改为更具体的名称,例如 "npm test workflow" 或 "npm compatibility test",以便更清晰地表明这是一个专门用于 npm 测试的工作流程。

-name: react component workflow
+name: npm compatibility test workflow

6-8: 建议添加 Node.js 版本矩阵测试

为确保在不同 Node.js 版本下的兼容性,建议添加版本矩阵测试。这对于验证包管理器行为特别重要。

 jobs:
   react-component-workflow:
     name: react component workflow
     runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        node-version: [16.x, 18.x, 20.x]
     steps:
+      - name: Setup Node.js ${{ matrix.node-version }}
+        uses: actions/setup-node@v4
+        with:
+          node-version: ${{ matrix.node-version }}

13-19: 建议保存测试结果和覆盖率报告

当前配置已经包含了完整的测试流程,但建议添加步骤来保存测试结果和覆盖率报告作为工作流程构件,这样可以更方便地查看历史记录。

       - run: npm run test -- --coverage
       - uses: codecov/codecov-action@v5
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
+      - name: Upload test results
+        if: always()
+        uses: actions/upload-artifact@v3
+        with:
+          name: test-results
+          path: |
+            coverage/
+            test-results/
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9ed38b0 and 4aa3cf7.

📒 Files selected for processing (1)
  • .github/workflows/test-npm.yml (1 hunks)

Comment on lines 11 to 12
- 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.

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

@zombieJ zombieJ merged commit 789ce98 into main Dec 6, 2024
4 checks passed
@afc163 afc163 deleted the npm-test branch December 6, 2024 09:59
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