rust-node-ci
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRust+Node.js CI/CD
Rust+Node.js CI/CD
GitHub Actions workflows and composite actions for Rust+Node.js hybrid projects.
适用于Rust+Node.js混合项目的GitHub Actions工作流与复合Action。
When to Use This Skill
适用场景
Activate when any of the following are true:
- Working with in a repo with both
.github/workflows/andCargo.tomlpackage.json - Setting up, fixing, or extending CI/CD pipelines
- Installing composite actions into a project
- User mentions "CI", "workflow", "GitHub Actions", "cross-build", or "artifact"
当满足以下任一条件时启用:
- 在同时包含和
Cargo.toml的仓库中操作package.json目录.github/workflows/ - 搭建、修复或扩展CI/CD流水线
- 向项目中安装复合Action
- 用户提及「CI」「workflow」「GitHub Actions」「cross-build」或「artifact」
Decision Tree
决策树
What does the user need?
Set up CI from scratch?
→ Copy templates/workflows/ into .github/workflows/
→ Install composite actions from templates/actions/ into .github/actions/
→ Customize platform matrix for your targets
Fix a failing CI job?
→ Node job → CI Jobs section
→ Rust build/cross-compile → Composite Actions section + references/troubleshooting.md
→ Publish workflow → see rust-npm-publish skill
Add a new platform to the build matrix?
→ Publish Workflow Matrix section
→ Full platform reference → see rust-npm-publish skill
Understand dev vs release versioning in CI?
→ Dev Versioning section用户需求是什么?
从零搭建CI?
→ 将templates/workflows/中的内容复制到.github/workflows/
→ 将templates/actions/中的复合Action安装到.github/actions/
→ 根据目标自定义平台构建矩阵
修复失败的CI任务?
→ Node任务 → 查看CI任务章节
→ Rust构建/交叉编译 → 查看复合Action章节 + references/troubleshooting.md
→ 发布工作流 → 查看rust-npm-publish技能文档
为构建矩阵添加新平台?
→ 查看发布工作流矩阵章节
→ 完整平台参考 → 查看rust-npm-publish技能文档
了解CI中的开发版与正式版版本管理?
→ 查看开发版本管理章节Workflow Architecture
工作流架构
┌─────────────┐ ┌──────────────────┐
│ Node Build │ │ Rust Build │
│ (test/lint) │ │ (per platform) │
└──────┬──────┘ └────────┬─────────┘
│ │
│ ┌─────────────┐ │
└──►│ Artifacts │◄──┘
└──────┬──────┘
│
┌──────▼──────┐
│ Publish │
└─────────────┘┌─────────────┐ ┌──────────────────┐
│ Node Build │ │ Rust Build │
│ (test/lint) │ │ (per platform) │
└──────┬──────┘ └────────┬─────────┘
│ │
│ ┌─────────────┐ │
└──►│ Artifacts │◄──┘
└──────┬──────┘
│
┌──────▼──────┐
│ Publish │
└─────────────┘Workflows
工作流列表
| Workflow | Trigger | What It Does |
|---|---|---|
| PR, push to main | Node build+test+lint, Rust fmt+clippy+test |
| Release, dispatch | Cross-build → publish to npm |
| repository_dispatch | Copilot agent onboarding |
Templates: templates/workflows/
| 工作流 | 触发条件 | 功能 |
|---|---|---|
| PR、推送到main分支 | Node构建+测试+代码检查,Rust格式化+Clippy检查+测试 |
| 发布事件、手动触发 | 交叉构建 → 发布到npm |
| repository_dispatch | Copilot Agent入门配置 |
模板地址:templates/workflows/
CI Jobs
CI任务
Node Job
Node任务
yaml
steps:
- uses: ./.github/actions/setup-workspace
- run: pnpm build
- run: pnpm test
- run: pnpm typecheckyaml
steps:
- uses: ./.github/actions/setup-workspace
- run: pnpm build
- run: pnpm test
- run: pnpm typecheckRust Job
Rust任务
yaml
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- run: cargo fmt --all -- --check
- run: cargo clippy --workspace -- -D warnings
- run: cargo test --workspaceyaml
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- run: cargo fmt --all -- --check
- run: cargo clippy --workspace -- -D warnings
- run: cargo test --workspaceComposite Actions
复合Action
Install into in your project, then reference as .
.github/actions/<name>/action.ymluses: ./.github/actions/<name>Templates: templates/actions/
| Action | Install path | Purpose |
|---|---|---|
| | Checkout + pnpm + Node.js + cache + install |
| | Build Rust binaries for a target platform |
| | Compute dev/release version + npm tag |
| | Poll npm until platform packages are visible |
安装到项目的路径下,然后通过引用。
.github/actions/<name>/action.ymluses: ./.github/actions/<name>模板地址:templates/actions/
| Action | 安装路径 | 用途 |
|---|---|---|
| | 代码检出 + pnpm + Node.js + 缓存 + 依赖安装 |
| | 为目标平台构建Rust二进制文件 |
| | 计算开发版/正式版版本号 + npm标签 |
| | 轮询npm直到平台包可见 |
Publish Workflow Matrix
发布工作流矩阵
yaml
strategy:
matrix:
include:
- { os: macos-latest, target: x86_64-apple-darwin, platform: darwin-x64 }
- { os: macos-latest, target: aarch64-apple-darwin, platform: darwin-arm64 }
- { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu, platform: linux-x64 }
- { os: windows-latest, target: x86_64-pc-windows-msvc, platform: windows-x64 }Each matrix entry runs and uploads the binary as an artifact.
rust-cross-buildyaml
strategy:
matrix:
include:
- { os: macos-latest, target: x86_64-apple-darwin, platform: darwin-x64 }
- { os: macos-latest, target: aarch64-apple-darwin, platform: darwin-arm64 }
- { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu, platform: linux-x64 }
- { os: windows-latest, target: x86_64-pc-windows-msvc, platform: windows-x64 }每个矩阵条目都会执行并将二进制文件作为工件上传。
rust-cross-buildArtifact Flow
工件流转
yaml
undefinedyaml
undefinedUpload from build job (one per platform)
从构建任务上传(每个平台一个)
- uses: actions/upload-artifact@v4 with: name: binary-${{ matrix.platform }} path: target/${{ matrix.target }}/release/my-cli${{ matrix.platform == 'windows-x64' && '.exe' || '' }} retention-days: 1
- uses: actions/upload-artifact@v4 with: name: binary-${{ matrix.platform }} path: target/${{ matrix.target }}/release/my-cli${{ matrix.platform == 'windows-x64' && '.exe' || '' }} retention-days: 1
Download in publish job (all platforms)
在发布任务中下载(所有平台)
- uses: actions/download-artifact@v4 with: pattern: binary-* path: artifacts/ merge-multiple: false
undefined- uses: actions/download-artifact@v4 with: pattern: binary-* path: artifacts/ merge-multiple: false
undefinedCaching
缓存策略
| Tool | How |
|---|---|
| pnpm | |
| Rust | |
| Turbo | |
| 工具 | 配置方式 |
|---|---|
| pnpm | 使用 |
| Rust | 使用 |
| Turbo | 使用 |
Dev Versioning in CI
CI中的开发版本管理
Non-release builds compute a unique pre-release version:
base version: 0.2.15
compute-version (is-release: false) → 0.2.16-dev.{github_run_id}
npm-tag: devUse the action:
compute-versionyaml
- uses: ./.github/actions/compute-version
id: version
with:
base-version: ${{ steps.pkg.outputs.version }}
is-release: ${{ github.event_name == 'release' }}非发布构建会生成唯一的预发布版本号:
基础版本:0.2.15
compute-version (is-release: false) → 0.2.16-dev.{github_run_id}
npm标签: dev使用 Action:
compute-versionyaml
- uses: ./.github/actions/compute-version
id: version
with:
base-version: ${{ steps.pkg.outputs.version }}
is-release: ${{ github.event_name == 'release' }}outputs: version, npm-tag, is-dev
输出:version, npm-tag, is-dev
undefinedundefinedTroubleshooting
故障排查
| Problem | Fix |
|---|---|
| Rust build fails on macOS ARM | Use |
| pnpm lockfile mismatch | |
| Cargo cache too large | Add |
| Artifact not found downstream | Check |
See references/troubleshooting.md for detailed diagnostics.
| 问题 | 解决方案 |
|---|---|
| macOS ARM上Rust构建失败 | 使用 |
| pnpm锁文件不匹配 | CI中使用 |
| Cargo缓存过大 | 为rust-cache添加 |
| 下游任务找不到工件 | 检查 |
详细诊断请查看references/troubleshooting.md。
Templates
模板目录
| Directory | Contents |
|---|---|
| templates/workflows/ | |
| templates/actions/ | 4 composite actions with |
| 目录 | 内容 |
|---|---|
| templates/workflows/ | |
| templates/actions/ | 4个带 |
Setup & Activation
安装与激活
bash
npx skills add -g onsager-ai/dev-skills --skill rust-node-ci -a claude-code -yAuto-activates when: directory exists in a Rust+Node.js repo, or user mentions "CI", "workflow", "GitHub Actions", "cross-build".
.github/workflows/bash
npx skills add -g onsager-ai/dev-skills --skill rust-node-ci -a claude-code -y自动激活条件:Rust+Node.js仓库中存在目录,或用户提及「CI」「workflow」「GitHub Actions」「cross-build」。
.github/workflows/