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

wip chore: 🔧 try macos and windows #1480

Closed
wants to merge 21 commits into from
Closed

Conversation

stormslowly
Copy link
Member

@stormslowly stormslowly commented Aug 8, 2024

Summary by CodeRabbit

  • 新功能

    • CI工作流现在支持多个操作系统(包括Windows),提高了测试的兼容性和稳健性。
    • 新增了处理Windows文件路径的工具函数,增强了跨平台兼容性。
  • 修复

    • 更新了脚本逻辑,以确保跨平台路径构造的一致性。
  • 样式

    • 改善了CI配置文件的格式,增加了可读性和一致性。
  • 调试

    • 在编译器实现中增加了调试输出,提升了对处理过程的可视化能力。

Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Walkthrough

此次更改主要集中在 CI 工作流的配置上,特别是扩展了操作系统矩阵,增加了对 windows-latest 的支持,从而提升了跨平台兼容性。此外,引入了处理 Windows 路径的功能,改进了路径构造逻辑,并在多个脚本中进行了统一优化。这些改动增强了构建和测试的可读性与一致性,同时为调试提供了更好的支持。

Changes

文件 更改摘要
.github/workflows/ci.yml 扩展操作系统矩阵,包含 windows-latest,并进行了格式化调整。
crates/mako/src/ast/file.rs 新增函数 win_path,改进 Windows 路径处理,增强兼容性。
scripts/path.mjs 新增 winPathwinJoin,统一处理 Windows 路径。
scripts/test-e2e.mjs 使用 winJoin 替代 path.join,改进路径构造,确保 Node.js 环境运行。
scripts/test-hmr.mjs 替换多个 path.join 调用为 winJoin,增强跨平台兼容性。
crates/mako/src/generate/group_chunk.rs 增加调试信息,输出当前处理的值与条目 ID,改善调试能力。

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Contributor

@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: 0

Outside diff range, codebase verification and nitpick comments (4)
.github/workflows/ci.yml (4)

6-6: 格式化改进

branches 数组中添加空格提升了可读性。


10-10: 格式化改进

types 数组中添加空格提升了可读性。


51-51: 扩展操作系统矩阵

os 数组扩展为包括 windows-latestmacos-latest,使 CI 管道能够在多个平台上运行测试。这提高了兼容性和健壮性。


63-63: 在缓存键中包含操作系统

在缓存键中加入操作系统信息确保了缓存根据操作系统正确分割,这对于跨平台构建非常重要。

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 711611d and f3e65ed.

Files selected for processing (1)
  • .github/workflows/ci.yml (7 hunks)
Additional comments not posted (2)
.github/workflows/ci.yml (2)

85-85: 确保上传工件时文件存在

添加 if-no-files-found: error 参数确保在上传工件时如果未找到文件将引发错误,这有助于及早发现潜在问题。


94-94: 验证 E2E 测试的操作系统限制

test_e2e 作业仅限于 ubuntu-latest,这可能是为了减少复杂性或由于平台特定的依赖关系。请确认此限制是否符合预期。

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f3e65ed and 35db800.

Files selected for processing (1)
  • .github/workflows/ci.yml (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 35db800 and 75fdf5e.

Files selected for processing (1)
  • scripts/test-e2e.mjs (1 hunks)
Additional comments not posted (1)
scripts/test-e2e.mjs (1)

43-43: 确保脚本在 Node.js 环境中运行

将脚本执行命令更改为使用 node,这有助于确保在不同操作系统上运行时的一致性和兼容性。这是一个很好的改进,特别是在处理跨平台问题时。

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75fdf5e and 8b9378e.

Files selected for processing (1)
  • scripts/test-e2e.mjs (4 hunks)
Additional comments not posted (3)
scripts/test-e2e.mjs (3)

4-11: 代码更改通过审核!

winPath 函数正确地处理了 Windows 路径的转换,确保了路径格式的兼容性。


13-15: 代码更改通过审核!

winJoin 函数通过使用 winPath 确保了路径连接后的格式一致性,适用于 Windows 环境。


Line range hint 25-69: 代码更改通过审核!

通过使用 winJoin 函数,脚本中的路径操作现在更加一致,提升了跨平台的兼容性,尤其是对 Windows 用户。

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8b9378e and a74da14.

Files selected for processing (2)
  • scripts/mako.js (1 hunks)
  • scripts/test-e2e.mjs (1 hunks)
Files skipped from review due to trivial changes (1)
  • scripts/test-e2e.mjs
Additional comments not posted (1)
scripts/mako.js (1)

6-6: 改进的工作目录初始化

cwd 变量现在有一个回退机制,使用 process.cwd() 作为默认值。这提高了脚本的健壮性,确保了在未提供命令行参数时仍有有效的工作目录。

Copy link
Contributor

@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: 0

Outside diff range, codebase verification and nitpick comments (1)
.github/workflows/ci.yml (1)

6-6: 调整分支和事件类型的格式。

pushpull_request 触发器中添加了空格以提高可读性,这是一个良好的实践。

Also applies to: 10-10

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a74da14 and bfc49b8.

Files selected for processing (2)
  • .github/workflows/ci.yml (6 hunks)
  • scripts/test-e2e.mjs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • scripts/test-e2e.mjs
Additional comments not posted (5)
.github/workflows/ci.yml (5)

48-50: 为 Windows 设置默认 shell 为 PowerShell。

build 作业中为 Windows 设置默认 shell 为 PowerShell,有助于确保在 Windows 环境下命令的兼容性。


54-54: 扩展操作系统矩阵。

build 作业中扩展了操作系统矩阵,包括 windows-latestmacos-latest,这将提高跨平台的兼容性和测试覆盖率。


92-94: 为 Windows 设置默认 shell 为 PowerShell。

test_e2e 作业中为 Windows 设置默认 shell 为 PowerShell,这与 build 作业中的设置保持一致。


99-99: 扩展操作系统矩阵。

test_e2e 作业中扩展了操作系统矩阵,包括 windows-latestmacos-latest,这将提高跨平台的兼容性和测试覆盖率。


119-119: 确保下载绑定文件的路径正确。

test_e2e 作业中,下载绑定文件的路径设置为 packages/mako/,请确保该路径在所有操作系统上都有效。

请确认路径在所有操作系统上都正确设置。

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bfc49b8 and 8df81f2.

Files selected for processing (1)
  • .github/workflows/ci.yml (6 hunks)
Additional comments not posted (6)
.github/workflows/ci.yml (6)

6-6: 样式改进:branches 数组的格式化

push 事件中对 branches 数组的格式进行了改进,增加了空格以提高可读性。这是一个样式上的改进,不影响功能。


10-10: 样式改进:types 数组的格式化

pull_request 事件中对 types 数组的格式进行了改进,增加了空格以提高可读性。这是一个样式上的改进,不影响功能。


51-51: 增强:扩展操作系统矩阵

build 任务中,操作系统矩阵现在包括 windows-latestmacos-latest。这项更改有助于提高跨平台兼容性,确保在更多环境中进行测试。


93-94: 增强:扩展操作系统矩阵

test_e2e 任务中,操作系统矩阵现在包括 windows-latestmacos-latest。这项更改扩展了端到端测试的范围,提升了测试的全面性。


63-63: 环境标准化:设置默认 shell 为 powershell

build 任务中,默认 shell 设置为 powershell,这有助于标准化 Windows 操作的环境。


117-117: 环境标准化:设置默认 shell 为 pwsh

test_e2e 任务中,默认 shell 设置为 pwsh,确保了 Windows 端到端测试环境的一致性。

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8df81f2 and 74c4873.

Files selected for processing (4)
  • .github/workflows/ci.yml (5 hunks)
  • scripts/path.js (1 hunks)
  • scripts/test-e2e.mjs (3 hunks)
  • scripts/test-hmr.mjs (5 hunks)
Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/ci.yml
  • scripts/test-e2e.mjs
Additional comments not posted (7)
scripts/path.js (2)

1-8: 确保路径转换的全面性

winPath 函数将 Windows 路径中的反斜杠替换为正斜杠,这在跨平台开发中很常见。然而,对于扩展长度路径的处理仅仅是简单返回路径,建议确认这种处理方式是否符合预期的所有用例。

请验证此函数在所有可能的 Windows 路径场景中的表现是否符合预期。


10-12: 路径连接的跨平台处理

winJoin 函数通过先使用 path.join 连接路径,然后使用 winPath 转换路径分隔符,确保路径的跨平台兼容性。这种处理方式是合理的。

scripts/test-hmr.mjs (5)

7-7: 引入跨平台路径处理

通过引入 winJoin,确保在不同操作系统上路径处理的一致性。这是一个很好的改进,特别是在 Windows 环境中。


12-13: 路径定义的跨平台改进

tmptmpPackages 的路径定义改为使用 winJoin,确保在不同操作系统上路径的一致性。这是一个重要的改进。


1100-1100: Git 路径处理的跨平台改进

在处理 Git 目录路径时,使用 winJoin 来确保路径的一致性。这是一个很好的实践,确保脚本在 Windows 上正常运行。

Also applies to: 1155-1155


1696-1696: 文件操作的路径处理

在文件写入和删除操作中使用 winJoin,确保路径的正确性和一致性。这是一个重要的改进,特别是在跨平台开发中。

Also applies to: 1704-1704, 1711-1711


1723-1723: 启动命令的路径处理

在启动 Mako 开发服务器时,使用 winJoin 来构建命令路径,确保在不同操作系统上的一致性。这是一个很好的改进。

Copy link
Contributor

@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, codebase verification and nitpick comments (1)
scripts/path.mjs (1)

1-8: 建议添加输入验证

函数 winPath 假设输入路径总是字符串。建议在处理之前验证输入类型,以确保函数的鲁棒性。

function winPath(path) {
+  if (typeof path !== 'string') {
+    throw new TypeError('Expected a string');
+  }
  const isExtendedLengthPath = /^\\\\\?\\/.test(path);
  if (isExtendedLengthPath) {
    return path;
  }

  return path.replace(/\\/g, '/');
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 74c4873 and 12bc0ba.

Files selected for processing (4)
  • .github/workflows/ci.yml (6 hunks)
  • scripts/path.mjs (1 hunks)
  • scripts/test-e2e.mjs (4 hunks)
  • scripts/test-hmr.mjs (5 hunks)
Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/ci.yml
  • scripts/test-e2e.mjs
  • scripts/test-hmr.mjs

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 12bc0ba and 08732da.

Files selected for processing (1)
  • .github/workflows/ci.yml (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 08732da and 3d0ec6b.

Files selected for processing (2)
  • crates/mako/src/ast/file.rs (1 hunks)
  • scripts/path.mjs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • scripts/path.mjs
Additional comments not posted (2)
crates/mako/src/ast/file.rs (2)

336-343: 验证 win_path 函数的正确性

请确保 win_path 函数能够正确处理各种路径格式,特别是混合斜杠的情况。建议添加单元测试来覆盖这些场景。

您可以通过以下脚本来验证函数的正确性:


Line range hint 344-359: 验证 parse_path 函数的集成和正确性

parse_path 函数现在使用 win_path 来处理路径格式。请确保此集成不会影响现有逻辑,并验证函数对所有 URL 组件的处理是否正确。

您可以通过以下脚本来验证函数的集成和正确性:

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3d0ec6b and ff9c29c.

Files selected for processing (1)
  • crates/mako/src/generate/group_chunk.rs (1 hunks)
Files skipped from review due to trivial changes (1)
  • crates/mako/src/generate/group_chunk.rs

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ff9c29c and 84a30ff.

Files selected for processing (2)
  • crates/mako/src/generate/group_chunk.rs (1 hunks)
  • scripts/test-e2e.mjs (3 hunks)
Files skipped from review due to trivial changes (1)
  • crates/mako/src/generate/group_chunk.rs
Files skipped from review as they are similar to previous changes (1)
  • scripts/test-e2e.mjs

Copy link
Contributor

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 84a30ff and d51557f.

Files selected for processing (3)
  • crates/mako/src/ast/file.rs (1 hunks)
  • packages/mako/binding.d.ts (1 hunks)
  • scripts/test-e2e.mjs (4 hunks)
Files skipped from review due to trivial changes (1)
  • packages/mako/binding.d.ts
Files skipped from review as they are similar to previous changes (2)
  • crates/mako/src/ast/file.rs
  • scripts/test-e2e.mjs

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