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