fix: Windows PowerShell syntax and MiniMax config #297
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will build a .NET project | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
| name: Pull requests Check | |
| on: | |
| pull_request: | |
| branches: [ "master" ] | |
| push: | |
| branches: [ "dev" ] | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Clear NuGet cache | |
| run: dotnet nuget locals all --clear | |
| - name: Restore dependencies | |
| run: dotnet restore --force --no-cache | |
| - name: Build | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Check code formatting | |
| if: matrix.os == 'windows-latest' | |
| run: dotnet format --verify-no-changes | |
| - name: Run security analysis | |
| if: matrix.os == 'windows-latest' | |
| run: dotnet list package --vulnerable --include-transitive | |
| - name: Test | |
| run: dotnet test --no-build --verbosity normal --configuration Release --collect:"XPlat Code Coverage" | |
| - name: Upload coverage to Codecov | |
| if: matrix.os == 'windows-latest' | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| file: ./TestResults/**/*.xml | |
| flags: pr-check | |
| name: pr-${{ github.event.number }}-${{ matrix.os }} | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.os }} | |
| path: TestResults/ | |
| report: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: always() && github.event_name == 'pull_request' | |
| steps: | |
| - name: Download all test results | |
| uses: actions/download-artifact@v4 | |
| - name: Generate PR report | |
| run: | | |
| echo "# 🔍 PR检查报告" > pr-report.md | |
| echo "" >> pr-report.md | |
| echo "## 📋 检查概览" >> pr-report.md | |
| echo "- **PR**: #${{ github.event.number }}" >> pr-report.md | |
| echo "- **分支**: ${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}" >> pr-report.md | |
| echo "- **触发事件**: ${{ github.event_name }}" >> pr-report.md | |
| echo "- **提交**: ${{ github.sha }}" >> pr-report.md | |
| echo "" >> pr-report.md | |
| echo "## 🧪 测试结果" >> pr-report.md | |
| echo "| 平台 | 状态 | 详情 |" >> pr-report.md | |
| echo "|------|------|------|" >> pr-report.md | |
| if [ -d "test-results-ubuntu-latest" ]; then | |
| echo "| Ubuntu | 🟢 已完成 | 查看测试结果 |" >> pr-report.md | |
| else | |
| echo "| Ubuntu | 🔴 失败 | 测试结果不可用 |" >> pr-report.md | |
| fi | |
| if [ -d "test-results-windows-latest" ]; then | |
| echo "| Windows | 🟢 已完成 | 查看测试结果 |" >> pr-report.md | |
| else | |
| echo "| Windows | 🔴 失败 | 测试结果不可用 |" >> pr-report.md | |
| fi | |
| echo "" >> pr-report.md | |
| echo "## 📊 代码质量" >> pr-report.md | |
| echo "- ✅ 代码格式化检查" >> pr-report.md | |
| echo "- ✅ 安全漏洞扫描" >> pr-report.md | |
| echo "- ✅ 依赖包分析" >> pr-report.md | |
| echo "- ✅ 代码覆盖率收集" >> pr-report.md | |
| echo "" >> pr-report.md | |
| echo "## 📁 测试产物" >> pr-report.md | |
| echo "- 测试结果文件已上传为artifacts" >> pr-report.md | |
| echo "- 代码覆盖率已上传到Codecov" >> pr-report.md | |
| echo "" >> pr-report.md | |
| echo "## 🔗 相关链接" >> pr-report.md | |
| echo "- [PR页面](${{ github.event.pull_request.html_url }})" >> pr-report.md | |
| echo "- [Actions日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> pr-report.md | |
| echo "" >> pr-report.md | |
| echo "---" >> pr-report.md | |
| echo "*此报告由GitHub Actions自动生成*" >> pr-report.md | |
| - name: Find existing comment | |
| if: always() | |
| uses: actions/github-script@v7 | |
| id: find-comment | |
| with: | |
| script: | | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('🔍 PR检查报告') | |
| ); | |
| return botComment?.id; | |
| - name: Create or update comment | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const reportPath = './pr-report.md'; | |
| const report = fs.readFileSync(reportPath, 'utf8'); | |
| const commentId = '${{ steps.find-comment.outputs.result }}'; | |
| if (commentId) { | |
| // 更新现有评论 | |
| await github.rest.issues.updateComment({ | |
| comment_id: commentId, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: report | |
| }); | |
| } else { | |
| // 创建新评论 | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: report | |
| }); | |
| } |