From 60068aff4ff95df7b98ea41dd04c680d7aa2f2a9 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Tue, 17 Mar 2026 16:34:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ci):=20=E9=87=8D=E6=9E=84=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=E9=85=8D=E7=BD=AE=E4=BB=A5=E5=88=86=E7=A6=BB?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F=E5=92=8C=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将原有的 test job 重命名为 code-quality,专注于代码质量与安全检查 - 添加构建和测试独立的 build-and-test job,实现并行执行 - 更新 MegaLinter 配置,优化缓存和报告上传流程 - 重新组织 CI 工作流结构,提升执行效率和可维护性 - 调整作业名称和描述,明确职责分工 --- .github/workflows/ci.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ec9bbe..a9604b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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