refactor(ci): 重构工作流配置以分离代码质量和构建测试任务

- 将原有的 test job 重命名为 code-quality,专注于代码质量与安全检查
- 添加构建和测试独立的 build-and-test job,实现并行执行
- 更新 MegaLinter 配置,优化缓存和报告上传流程
- 重新组织 CI 工作流结构,提升执行效率和可维护性
- 调整作业名称和描述,明确职责分工
This commit is contained in:
GeWuYou 2026-03-17 16:34:09 +08:00
parent 9c69c4ec00
commit 60068aff4f

View File

@ -13,8 +13,9 @@ permissions:
security-events: write
jobs:
test:
name: Build and Test
# 代码质量检查 job并行执行不阻塞构建
code-quality:
name: Code Quality & Security
runs-on: ubuntu-latest
steps:
@ -23,9 +24,11 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0
# 校验C#命名空间与源码目录是否符合命名规范
- name: Validate C# naming
run: bash scripts/validate-csharp-naming.sh
# 缓存MegaLinter
- name: Cache MegaLinter
uses: actions/cache@v5
@ -34,8 +37,7 @@ jobs:
key: ${{ runner.os }}-megalinter-v9
restore-keys: |
${{ runner.os }}-megalinter-
# MegaLinter扫描步骤
# 执行代码质量检查和安全扫描生成SARIF格式报告
- name: MegaLinter
@ -44,11 +46,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FAIL_ON_ERROR: ${{ github.ref == 'refs/heads/main' }}
# 上传SARIF格式的安全和代码质量问题报告到GitHub安全中心
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: megalinter-reports/sarif
# 缓存TruffleHog
- name: Cache TruffleHog
uses: actions/cache@v5
@ -68,6 +72,18 @@ jobs:
base: ${{ github.event.before }}
# 当前提交哈希,作为扫描的目标版本
head: ${{ github.sha }}
# 构建和测试 job并行执行
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
# 检出源代码
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
# 安装和配置.NET SDK版本
- name: Setup .NET 8