Skip to content

Commit b233321

Browse files
committed
chore: 更新项目配置和文档
- 在 package.json 中添加构建、发布和安全审计相关的脚本 - 更新 README.md,增加对 Remote-SSH 开发环境的支持说明 - 新增 GitHub Actions 工作流配置,包括 CI、PR 检查、夜间构建和发布流程 - 在数据收集器中添加 Remote-SSH 特定信息的输出 - 更新 VSCodeEdition 枚举,增加对 Remote-SSH 的支持 - 优化 VSCode 环境获取逻辑以支持 Remote-SSH
0 parents  commit b233321

37 files changed

+8635
-0
lines changed

.github/cicd.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# GitHub 工作流说明
2+
3+
本项目包含以下 GitHub Actions 工作流:
4+
5+
## 📋 工作流概览
6+
7+
### 1. CI (`ci.yml`)
8+
**触发条件**: PR 和推送到 main/master 分支
9+
**功能**:
10+
- 多平台测试 (Ubuntu, Windows, macOS)
11+
- 多 Node.js 版本测试 (18, 20)
12+
- 类型检查、代码检查、编译、测试
13+
- 安全检查 (仅 PR)
14+
- 构建产物上传
15+
16+
### 2. PR Check (`pr-check.yml`)
17+
**触发条件**: 仅 PR
18+
**功能**:
19+
- 代码质量检查
20+
- 依赖检查
21+
- 安全检查
22+
- 多平台构建测试
23+
24+
### 3. Release (`release.yml`)
25+
**触发条件**: 推送 tag (格式: v*)
26+
**功能**:
27+
- 自动发布到 GitHub Releases
28+
- 发布到 VS Code Marketplace
29+
- 更新 CHANGELOG.md
30+
31+
### 4. Nightly Build (`nightly.yml`)
32+
**触发条件**: 每日凌晨 2 点 + 手动触发
33+
**功能**:
34+
- 每日构建测试
35+
- 依赖更新检查
36+
- 安全漏洞扫描
37+
- 构建报告生成
38+
39+
## 🔧 配置要求
40+
41+
### 必需的 Secrets
42+
43+
在 GitHub 仓库设置中添加以下 secrets:
44+
45+
1. **VSCODE_MARKETPLACE_TOKEN** (可选)
46+
- 用于自动发布到 VS Code Marketplace
47+
- 获取方式: https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token
48+
49+
### 可选配置
50+
51+
1. **分支保护规则**
52+
- 建议为 main/master 分支启用保护
53+
- 要求 PR 通过所有检查
54+
55+
2. **自动合并**
56+
- 可配置自动合并满足条件的 PR
57+
58+
## 🚀 使用方法
59+
60+
### 发布新版本
61+
62+
1. 更新 `package.json` 中的版本号
63+
2. 创建并推送 tag:
64+
```bash
65+
git tag v1.0.0
66+
git push origin v1.0.0
67+
```
68+
3. 工作流会自动:
69+
- 运行所有测试
70+
- 创建 GitHub Release
71+
- 发布到 VS Code Marketplace (如果配置了 token)
72+
73+
### 手动触发夜间构建
74+
75+
1. 进入 GitHub Actions 页面
76+
2. 选择 "Nightly Build" 工作流
77+
3. 点击 "Run workflow"
78+
79+
### 查看构建产物
80+
81+
1. 进入 GitHub Actions 页面
82+
2. 选择任意工作流运行
83+
3. 在 "Artifacts" 部分下载构建产物
84+
85+
## 📊 工作流状态徽章
86+
87+
可以在 README.md 中添加以下徽章:
88+
89+
```markdown
90+
![CI](https://github.com/{owner}/{repo}/workflows/CI/badge.svg)
91+
![PR Check](https://github.com/{owner}/{repo}/workflows/PR%20Check/badge.svg)
92+
![Release](https://github.com/{owner}/{repo}/workflows/Release/badge.svg)
93+
```
94+
95+
## 🔍 故障排除
96+
97+
### 常见问题
98+
99+
1. **构建失败**
100+
- 检查 Node.js 版本兼容性
101+
- 确认所有依赖都已安装
102+
- 查看详细的错误日志
103+
104+
2. **发布失败**
105+
- 确认 VSCODE_MARKETPLACE_TOKEN 已正确配置
106+
- 检查版本号格式是否正确
107+
- 确认扩展 ID 和发布者信息正确
108+
109+
3. **测试失败**
110+
- 检查测试环境配置
111+
- 确认测试文件路径正确
112+
- 查看测试输出日志
113+
114+
### 调试技巧
115+
116+
1. **本地测试**
117+
```bash
118+
# 运行所有检查
119+
pnpm run check-types
120+
pnpm run lint
121+
pnpm run test
122+
pnpm run package
123+
```
124+
125+
2. **查看工作流日志**
126+
- 在 GitHub Actions 页面查看详细日志
127+
- 使用 `echo` 命令添加调试信息
128+
129+
3. **重新运行失败的工作流**
130+
- 在 GitHub Actions 页面点击 "Re-run jobs"
131+
132+
## 📝 自定义配置
133+
134+
### 修改触发条件
135+
136+
编辑对应工作流文件的 `on` 部分:
137+
138+
```yaml
139+
on:
140+
push:
141+
branches: [ main, develop ] # 添加更多分支
142+
pull_request:
143+
branches: [ main, develop ] # 添加更多分支
144+
```
145+
146+
### 添加新的检查步骤
147+
148+
在工作流文件中添加新的 step:
149+
150+
```yaml
151+
- name: Custom Check
152+
run: |
153+
echo "Running custom check..."
154+
# 你的检查命令
155+
```
156+
157+
### 修改缓存策略
158+
159+
调整 pnpm 缓存配置:
160+
161+
```yaml
162+
- name: Setup pnpm cache
163+
uses: actions/cache@v4
164+
with:
165+
path: ${{ env.STORE_PATH }}
166+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
167+
restore-keys: |
168+
${{ runner.os }}-pnpm-store-
169+
```
170+
171+
## 🤝 贡献指南
172+
173+
1. Fork 项目
174+
2. 创建功能分支
175+
3. 提交更改
176+
4. 创建 Pull Request
177+
5. 等待 CI 检查通过
178+
6. 请求代码审查
179+
7. 合并到主分支
180+
181+
---
182+
183+
如有问题,请查看 [GitHub Actions 文档](https://docs.github.com/en/actions) 或创建 Issue。

.github/dependabot.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: 2
2+
updates:
3+
# 启用 npm 依赖更新
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
open-pull-requests-limit: 10
11+
reviewers:
12+
- "sunerpy"
13+
assignees:
14+
- "sunerpy"
15+
commit-message:
16+
prefix: "deps"
17+
include: "scope"
18+
labels:
19+
- "dependencies"
20+
- "npm"
21+
ignore:
22+
# 忽略开发依赖的破坏性更新
23+
- dependency-name: "@types/*"
24+
update-types: ["version-update:semver-major"]
25+
- dependency-name: "eslint*"
26+
update-types: ["version-update:semver-major"]
27+
- dependency-name: "@typescript-eslint/*"
28+
update-types: ["version-update:semver-major"]
29+
30+
# 启用 GitHub Actions 更新
31+
- package-ecosystem: "github-actions"
32+
directory: "/"
33+
schedule:
34+
interval: "weekly"
35+
day: "monday"
36+
time: "09:00"
37+
open-pull-requests-limit: 5
38+
reviewers:
39+
- "sunerpy"
40+
assignees:
41+
- "sunerpy"
42+
commit-message:
43+
prefix: "ci"
44+
include: "scope"
45+
labels:
46+
- "dependencies"
47+
- "github-actions"

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ main, master ]
6+
push:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
node-version: [18, 20]
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v4
30+
with:
31+
version: latest
32+
33+
- name: Get pnpm store directory
34+
shell: bash
35+
run: |
36+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
37+
38+
- name: Setup pnpm cache
39+
uses: actions/cache@v4
40+
with:
41+
path: ${{ env.STORE_PATH }}
42+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
43+
restore-keys: |
44+
${{ runner.os }}-pnpm-store-
45+
46+
- name: Install dependencies
47+
run: pnpm install --frozen-lockfile
48+
49+
- name: Check types
50+
run: pnpm run check-types
51+
52+
- name: Lint
53+
run: pnpm run lint
54+
55+
- name: Compile
56+
run: pnpm run compile
57+
58+
- name: Run tests
59+
run: pnpm run test
60+
61+
- name: Package extension
62+
run: pnpm run package:vsix
63+
64+
- name: Upload build artifacts
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: vscode-syncing-${{ matrix.os }}-${{ matrix.node-version }}
68+
path: |
69+
*.vsix
70+
dist/
71+
retention-days: 7
72+
73+
security:
74+
name: Security Check
75+
runs-on: ubuntu-latest
76+
if: github.event_name == 'pull_request'
77+
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
82+
- name: Setup Node.js
83+
uses: actions/setup-node@v4
84+
with:
85+
node-version: 20
86+
87+
- name: Setup pnpm
88+
uses: pnpm/action-setup@v4
89+
with:
90+
version: latest
91+
92+
- name: Install dependencies
93+
run: pnpm install --frozen-lockfile
94+
95+
- name: Run security audit
96+
run: pnpm audit --audit-level moderate
97+
98+
- name: Check for secrets
99+
uses: trufflesecurity/trufflehog@main
100+
with:
101+
path: .
102+
base: ${{ github.event.pull_request.base.sha }}
103+
head: ${{ github.event.pull_request.head.sha }}

0 commit comments

Comments
 (0)