Skip to content

Commit 4e3a18b

Browse files
committed
feat(ci): ??????????????
?? bootstrap-e2e?????????????????????????????????????????????????? Made-with: Cursor
1 parent 151f6b8 commit 4e3a18b

30 files changed

Lines changed: 1309 additions & 37 deletions

.github/dependabot.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "nuget"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 10
8+
labels:
9+
- "dependencies"
10+
- "backend"
11+
12+
- package-ecosystem: "npm"
13+
directory: "/frontend"
14+
schedule:
15+
interval: "weekly"
16+
open-pull-requests-limit: 10
17+
labels:
18+
- "dependencies"
19+
- "frontend"
20+
21+
- package-ecosystem: "github-actions"
22+
directory: "/"
23+
schedule:
24+
interval: "weekly"
25+
open-pull-requests-limit: 10
26+
labels:
27+
- "dependencies"
28+
- "ci"
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: bootstrap-e2e
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
- master
10+
11+
jobs:
12+
bootstrap-e2e:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os:
18+
- ubuntu-latest
19+
- windows-latest
20+
module-codes:
21+
- "order,crm"
22+
- "ops,inventory"
23+
24+
steps:
25+
- uses: actions/checkout@v6
26+
27+
- name: Setup .NET
28+
uses: actions/setup-dotnet@v5
29+
with:
30+
dotnet-version: "10.0.x"
31+
cache: true
32+
cache-dependency-path: |
33+
**/*.csproj
34+
global.json
35+
36+
- name: Validate PowerShell script syntax
37+
shell: pwsh
38+
run: ./scripts/validate-powershell-scripts.ps1 -Root . -IncludePaths new-project.ps1,scripts/bootstrap-smoke.ps1,scripts/bootstrap-e2e.ps1
39+
40+
- name: Run bootstrap e2e
41+
shell: pwsh
42+
run: ./scripts/bootstrap-e2e.ps1 -ModuleCodes "${{ matrix.module-codes }}"
43+
44+
- name: Publish bootstrap e2e summary
45+
if: always()
46+
shell: pwsh
47+
run: |
48+
$root = Join-Path $env:RUNNER_TEMP "bootstrap-e2e-artifacts"
49+
if (-not (Test-Path -LiteralPath $root)) {
50+
"## bootstrap-e2e" >> $env:GITHUB_STEP_SUMMARY
51+
"- No artifacts directory found: $root" >> $env:GITHUB_STEP_SUMMARY
52+
exit 0
53+
}
54+
55+
$summaryFiles = Get-ChildItem -Path $root -Recurse -Filter "summary.md" -File
56+
if ($summaryFiles.Count -eq 0) {
57+
"## bootstrap-e2e" >> $env:GITHUB_STEP_SUMMARY
58+
"- No summary files found under: $root" >> $env:GITHUB_STEP_SUMMARY
59+
exit 0
60+
}
61+
62+
foreach ($file in $summaryFiles) {
63+
Get-Content -LiteralPath $file.FullName >> $env:GITHUB_STEP_SUMMARY
64+
"" >> $env:GITHUB_STEP_SUMMARY
65+
}
66+
67+
- name: Upload bootstrap e2e logs
68+
if: always()
69+
uses: actions/upload-artifact@v7
70+
with:
71+
name: bootstrap-e2e-artifacts-${{ matrix.os }}-${{ replace(matrix.module-codes, ',', '-') }}
72+
path: ${{ runner.temp }}/bootstrap-e2e-artifacts/**
73+
if-no-files-found: warn

.github/workflows/codeql.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: codeql
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
- master
10+
11+
jobs:
12+
analyze:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
actions: read
16+
contents: read
17+
security-events: write
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
language:
23+
- csharp
24+
- javascript-typescript
25+
26+
steps:
27+
- uses: actions/checkout@v6
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v4
31+
with:
32+
languages: ${{ matrix.language }}
33+
build-mode: autobuild
34+
35+
- name: Autobuild
36+
uses: github/codeql-action/autobuild@v4
37+
38+
- name: Perform CodeQL Analysis
39+
uses: github/codeql-action/analyze@v4
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: scripts-quality
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
- master
10+
11+
jobs:
12+
pwsh-syntax-check:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os:
18+
- ubuntu-latest
19+
- windows-latest
20+
21+
steps:
22+
- uses: actions/checkout@v6
23+
24+
- name: Validate PowerShell scripts with pwsh parser
25+
shell: pwsh
26+
run: ./scripts/validate-powershell-scripts.ps1 -Root .
27+
28+
windows-powershell-syntax-check:
29+
runs-on: windows-latest
30+
31+
steps:
32+
- uses: actions/checkout@v6
33+
34+
- name: Validate PowerShell scripts with Windows PowerShell parser
35+
shell: powershell
36+
run: .\scripts\validate-powershell-scripts.ps1 -Root .

.github/workflows/sdk-sync-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
UNICORE_ADMIN_USERNAME: "admin"
6565
UNICORE_ADMIN_PASSWORD: "Ci_Admin_12345!"
6666
UNICORE_TENANT_ID: "default"
67-
run: pwsh -ExecutionPolicy Bypass -File ./scripts/check-module-contract-alignment.ps1 -OutputJson -JsonOutputPath ./artifacts/module-contract-alignment-report.json
67+
run: pwsh -ExecutionPolicy Bypass -File ./scripts/check-module-contract-alignment.ps1 -ProtocolVersion "1.0.0" -FailOnBreaking -OutputJson -JsonOutputPath ./artifacts/module-contract-alignment-report.json
6868

6969
- name: Check generated SDK is up to date
7070
working-directory: frontend/platform-admin

.github/workflows/supply-chain.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: supply-chain
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
- master
10+
11+
jobs:
12+
release-manifest:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v5
20+
with:
21+
dotnet-version: "10.0.x"
22+
23+
- name: Generate release manifest
24+
shell: pwsh
25+
run: ./scripts/generate-release-manifest.ps1 -OutputPath artifacts/release/release-manifest.json
26+
27+
- name: Upload release manifest
28+
uses: actions/upload-artifact@v7
29+
with:
30+
name: release-manifest
31+
path: artifacts/release/release-manifest.json
32+
if-no-files-found: error
33+
34+
sbom:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@v6
39+
40+
- name: Generate SBOM (CycloneDX JSON)
41+
uses: anchore/sbom-action@v0
42+
with:
43+
path: .
44+
format: cyclonedx-json
45+
output-file: sbom.cyclonedx.json
46+
47+
- name: Upload SBOM artifact
48+
uses: actions/upload-artifact@v7
49+
with:
50+
name: sbom-cyclonedx
51+
path: sbom.cyclonedx.json
52+
if-no-files-found: error

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22

33
所有重要变更记录在此文件中。
44

5+
## [0.0.8] - 2026-04-18
6+
7+
### 新增
8+
- 复用闭环 CI:新增 `.github/workflows/bootstrap-e2e.yml`,在 `ubuntu-latest``windows-latest` 矩阵下执行“临时项目创建 + 双模块挂载 + 合同检查 + smoke”,并上传 `bootstrap-e2e-artifacts-*` 工件与 Step Summary。
9+
- 脚本质量门禁:新增统一语法校验脚本 `scripts/validate-powershell-scripts.ps1` 与工作流 `.github/workflows/scripts-quality.yml`,覆盖 `pwsh`(Linux/Windows)与 Windows PowerShell 双解析器。
10+
- 供应链治理:新增 `.github/workflows/supply-chain.yml`,自动生成并归档 `artifacts/release/release-manifest.json``sbom.cyclonedx.json`
11+
- 安全静态分析:新增 `.github/workflows/codeql.yml`,对 `csharp``javascript-typescript` 进行 CodeQL 扫描。
12+
- 依赖治理自动化:新增 `.github/dependabot.yml`,对 NuGet、npm(frontend)与 GitHub Actions 按周自动升级。
13+
- 企业治理文档:新增 `docs/lts-support-policy.md``docs/slo-sli.md`,补齐 LTS 支持窗口、EOL、SLO/SLI 及告警分级基线。
14+
- 发布清单脚本:新增 `scripts/generate-release-manifest.ps1`,输出包含 commit、SDK 版本、后端项目清单与治理文档索引的发布清单。
15+
16+
### 变更
17+
- `scripts/bootstrap-e2e.ps1` 增强诊断能力:输出 `report.json``summary.md`、日志副本;支持失败保留临时项目与可选失败清理;支持 `ModuleCodes` 逗号/空格混合输入;摘要状态改为 ASCII(`[PASS]/[FAIL]`)以提升 Windows PowerShell 兼容性。
18+
- 关键脚本兼容性加固:`new-project.ps1``scripts/bootstrap-smoke.ps1``scripts/bootstrap-e2e.ps1` 统一按 UTF-8 BOM 处理,修复 Windows PowerShell 下的解析稳定性问题。
19+
- `scripts/validate-powershell-scripts.ps1` 支持 `-IncludePaths` 逗号分隔传参与 `node_modules` 排除,便于 CI 精准校验。
20+
- `docs/release-process.md` 纳入 LTS/SLO 校核要求,并补充 release manifest 与 SBOM 归档要求。
21+
- `README.md` 补充 `bootstrap-e2e``scripts-quality`、LTS 与 SLO/SLI 说明,统一企业级复用入口文档。
22+
23+
### 影响范围与回归关注点
24+
- CI 执行时长会增加(新增 CodeQL、供应链、双平台脚本与 e2e 校验),建议观察首周队列耗时与失败率。
25+
- `bootstrap-e2e` 失败时默认保留临时项目用于排障,需关注 runner 磁盘占用;若需强制清理可使用 `-CleanupOnFailure`
26+
- 建议重点回归:`new-project.ps1 -ListProfiles``scripts/bootstrap-e2e.ps1``scripts/validate-powershell-scripts.ps1 -Root .` 以及新增工作流在 PR 场景的触发与工件上传行为。
27+
528
## [0.0.7] - 2026-04-18
629

730
### 变更

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ flowchart LR
578578
.\new-project.ps1 -ProjectName AcmeOpsPlatform -Profile erp -DestinationRoot e:\Projects
579579
.\new-project.ps1 -ListProfiles
580580
.\new-project.ps1 -ConfigFile .\new-project.config.sample.json
581+
.\new-project.ps1 -ProjectName AcmeOpsPlatform -DestinationRoot e:\Projects -ModuleCodes order,crm -RunSmoke
581582
```
582583

583584
参数说明:
@@ -593,6 +594,7 @@ flowchart LR
593594
- `Profile`:可选,加载预置场景模块组合(如 `erp``crm``ops`
594595
- `ListProfiles`:可选,列出当前仓库内置的场景配置
595596
- `SkipTemplateInstall`:可选,跳过模板安装(本机已安装模板时可用)
597+
- `RunSmoke`:可选,项目创建后自动执行 `scripts/bootstrap-smoke.ps1` 进行基础验收
596598

597599
该脚本会自动完成:
598600

@@ -604,6 +606,10 @@ flowchart LR
604606
配置文件示例见:`new-project.config.sample.json`
605607
预置场景配置目录:`bootstrap-profiles/`
606608
场景说明文档:`bootstrap-profiles/README.md`
609+
发布与回滚流程:`docs/release-process.md`
610+
版本兼容矩阵:`docs/compatibility-matrix.md`
611+
LTS 支持策略:`docs/lts-support-policy.md`
612+
SLO/SLI 基线:`docs/slo-sli.md`
607613

608614
参数覆盖优先级(高 -> 低):
609615

@@ -616,6 +622,35 @@ flowchart LR
616622
- `ModuleCodes` 同时支持两种写法:`-ModuleCodes order,crm,inventory``-ModuleCodes order crm inventory`
617623
- Windows PowerShell 环境下建议直接运行仓库内脚本文件(不要复制到会改编码的编辑器后另存),避免中文提示乱码
618624

625+
### bootstrap-e2e(CI 端到端复用闭环)
626+
627+
仓库内置工作流:`.github/workflows/bootstrap-e2e.yml`,用于在 CI 自动完成:
628+
629+
- 创建临时平台项目
630+
- 自动挂载至少两个业务模块(默认 `order` + `crm`
631+
- 启动临时后端并执行模块合同检查(含 breaking 校验)
632+
- 执行 `bootstrap-smoke` 基础验收
633+
634+
本地手动复现可执行:
635+
636+
```powershell
637+
.\scripts\bootstrap-e2e.ps1
638+
.\scripts\bootstrap-e2e.ps1 -ModuleCodes order crm inventory
639+
.\scripts\bootstrap-e2e.ps1 -KeepTemporaryProject
640+
```
641+
642+
CI 中该工作流会在 `always()` 场景上传 `bootstrap-e2e-artifacts-*` 工件(含 `report.json``summary.md`、后端日志),并自动写入 GitHub Step Summary,便于快速定位失败原因。
643+
工作流默认在 `ubuntu-latest``windows-latest` 双平台矩阵执行,并在运行前对 `new-project.ps1``scripts/bootstrap-smoke.ps1``scripts/bootstrap-e2e.ps1` 进行语法预检,降低跨平台脚本兼容风险。
644+
645+
### scripts-quality(脚本质量门禁)
646+
647+
仓库内置 `.github/workflows/scripts-quality.yml`,用于在 CI 中校验仓库 PowerShell 脚本语法:
648+
649+
- `pwsh` 解析器:`ubuntu-latest` + `windows-latest`
650+
- Windows PowerShell 解析器:`windows-latest`
651+
652+
统一校验脚本:`scripts/validate-powershell-scripts.ps1`
653+
619654
## 审计导出异步任务
620655

621656
详细说明见:`docs/audit-export.md`

docs/compatibility-matrix.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# 兼容矩阵(平台复用)
2+
3+
## 目标
4+
5+
明确平台协议、后端模块、前端模块与 SDK 的兼容关系,避免跨项目升级时出现隐性 breaking change。
6+
7+
## 版本对象
8+
9+
- 协议版本:模块契约协议(示例:`1.0.0`
10+
- 后端模块版本:`Platform.*` 与业务模块 `moduleVersion`
11+
- 前端模块版本:`frontend/modules/*``package.json version`
12+
- SDK 版本:`frontend/platform-admin/src/api/sdk/unicore-sdk.ts` 对应生成产物版本
13+
14+
## 兼容规则
15+
16+
- `major` 相同:允许兼容升级(仍需通过契约校验)
17+
- `minor` 升级:允许新增能力,不允许删除既有字段语义
18+
- `patch` 升级:仅修复,不改变接口语义
19+
- `major` 不同:默认视为 breaking,必须显式评审并执行迁移方案
20+
21+
## 校验要求
22+
23+
- 后端契约报告:
24+
- `GET /api/modules/contracts/report?protocolVersion=<x.y.z>&failOnBreaking=true`
25+
- 前后端契约对齐:
26+
- `npm run -w platform-admin modules:check-contracts`
27+
- SDK 同步校验:
28+
- `npm run -w platform-admin sdk:check`
29+
30+
## 发布门禁(建议)
31+
32+
- 必须满足:
33+
- 契约校验无错误
34+
- `failOnBreaking=true` 时无 breaking 结果
35+
- SDK 校验通过且无未提交差异
36+
- 如涉及 breaking:
37+
- 升级协议 major
38+
-`CHANGELOG.md` 标注影响范围和迁移步骤
39+
- 预置回滚目标版本

0 commit comments

Comments
 (0)