Bump dorny/test-reporter from 2.6.0 to 3.0.0 #83
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
| name: Server Test | |
| # ============================================ | |
| # サーバーテストワークフロー | |
| # - 単体テスト(xUnit) | |
| # - 統合テスト(Testcontainers + PostgreSQL) | |
| # - コードカバレッジレポート | |
| # - 脆弱性パッケージ検査 | |
| # ============================================ | |
| on: | |
| # 手動実行 | |
| workflow_dispatch: | |
| # PR 時に自動実行(サーバー関連ファイル変更時) | |
| pull_request: | |
| branches: [main, develop] | |
| paths: | |
| - 'src/Game.Server/**' | |
| - 'src/Game.Shared/**' | |
| - 'src/Game.Realtime/**' | |
| - 'test/Game.Server.Tests/**' | |
| - 'test/Game.Realtime.Tests/**' | |
| - '.github/workflows/server-test.yml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| DOTNET_VERSION: '9.0.x' | |
| DOTNET_NOLOGO: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| jobs: | |
| # ============================================ | |
| # 脆弱性パッケージ検査 | |
| # ============================================ | |
| vulnerability-check: | |
| name: Vulnerability Check | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore packages | |
| run: dotnet restore src/Game.Server/Game.Server.csproj | |
| - name: Check for vulnerable packages | |
| run: | | |
| OUTPUT=$(dotnet list src/Game.Server/Game.Server.csproj package --vulnerable --include-transitive 2>&1) | |
| echo "$OUTPUT" | |
| if echo "$OUTPUT" | grep -q "has the following vulnerable packages"; then | |
| echo "" | |
| echo "::error::Vulnerable packages detected. Update affected packages or review the vulnerabilities." | |
| exit 1 | |
| fi | |
| echo "No vulnerable packages found." | |
| # ============================================ | |
| # 単体テスト(高速・Dockerなし) | |
| # ============================================ | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Cache NuGet packages | |
| uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: | | |
| dotnet restore test/Game.Server.Tests/Game.Server.Tests.csproj | |
| dotnet restore test/Game.Realtime.Tests/Game.Realtime.Tests.csproj | |
| - name: Build | |
| run: | | |
| dotnet build test/Game.Server.Tests/Game.Server.Tests.csproj --no-restore --configuration Release | |
| dotnet build test/Game.Realtime.Tests/Game.Realtime.Tests.csproj --no-restore --configuration Release | |
| - name: Run unit tests | |
| run: | | |
| dotnet test test/Game.Server.Tests/Game.Server.Tests.csproj \ | |
| --no-build \ | |
| --configuration Release \ | |
| --filter "FullyQualifiedName!~Integration" \ | |
| --logger "trx;LogFileName=unit-test-results.trx" \ | |
| --results-directory TestResults \ | |
| --collect:"XPlat Code Coverage" \ | |
| -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover | |
| dotnet test test/Game.Realtime.Tests/Game.Realtime.Tests.csproj \ | |
| --no-build \ | |
| --configuration Release \ | |
| --filter "FullyQualifiedName!~Integration" \ | |
| --logger "trx;LogFileName=realtime-unit-test-results.trx" \ | |
| --results-directory TestResults \ | |
| --collect:"XPlat Code Coverage" \ | |
| -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover | |
| - name: Upload test results | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| if: always() | |
| with: | |
| name: Unit-Test-Results | |
| path: TestResults/ | |
| retention-days: 7 | |
| - name: Publish test results | |
| uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 | |
| if: always() | |
| with: | |
| name: Unit Test Report | |
| path: TestResults/*.trx | |
| reporter: dotnet-trx | |
| # ============================================ | |
| # 統合テスト(Testcontainers + PostgreSQL) | |
| # ============================================ | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| # 単体テスト成功後に実行 | |
| needs: unit-tests | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Cache NuGet packages | |
| uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore test/Game.Server.Tests/Game.Server.Tests.csproj | |
| - name: Build | |
| run: dotnet build test/Game.Server.Tests/Game.Server.Tests.csproj --no-restore --configuration Release | |
| - name: Run integration tests | |
| run: | | |
| dotnet test test/Game.Server.Tests/Game.Server.Tests.csproj \ | |
| --no-build \ | |
| --configuration Release \ | |
| --filter "FullyQualifiedName~Integration" \ | |
| --logger "trx;LogFileName=integration-test-results.trx" \ | |
| --results-directory TestResults \ | |
| --collect:"XPlat Code Coverage" \ | |
| -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover | |
| env: | |
| # Testcontainers 設定 | |
| TESTCONTAINERS_RYUK_DISABLED: false | |
| DOCKER_HOST: unix:///var/run/docker.sock | |
| - name: Upload test results | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| if: always() | |
| with: | |
| name: Integration-Test-Results | |
| path: TestResults/ | |
| retention-days: 7 | |
| - name: Publish test results | |
| uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 | |
| if: always() | |
| with: | |
| name: Integration Test Report | |
| path: TestResults/*.trx | |
| reporter: dotnet-trx | |
| # ============================================ | |
| # コードカバレッジレポート | |
| # ============================================ | |
| coverage-report: | |
| name: Coverage Report | |
| runs-on: ubuntu-latest | |
| needs: [unit-tests, integration-tests] | |
| if: always() && (needs.unit-tests.result == 'success' || needs.integration-tests.result == 'success') | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Download unit test coverage | |
| uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 | |
| with: | |
| name: Unit-Test-Results | |
| path: TestResults/Unit | |
| continue-on-error: true | |
| - name: Download integration test coverage | |
| uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 | |
| with: | |
| name: Integration-Test-Results | |
| path: TestResults/Integration | |
| continue-on-error: true | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Install ReportGenerator | |
| run: dotnet tool install --global dotnet-reportgenerator-globaltool | |
| - name: Generate coverage report | |
| run: | | |
| # カバレッジファイルを検索 | |
| coverage_files=$(find TestResults -name "coverage.opencover.xml" -o -name "coverage.cobertura.xml" | tr '\n' ';') | |
| if [ -n "$coverage_files" ]; then | |
| reportgenerator \ | |
| -reports:"$coverage_files" \ | |
| -targetdir:CoverageReport \ | |
| -reporttypes:"Html;MarkdownSummaryGithub;Badges" \ | |
| -assemblyfilters:"+Game.Server;+Game.Shared;+Game.Realtime;+Game.Realtime.Shared" \ | |
| -classfilters:"-*Migrations*" | |
| # サマリーを GitHub Step Summary に出力 | |
| if [ -f "CoverageReport/SummaryGithub.md" ]; then | |
| cat CoverageReport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY | |
| fi | |
| else | |
| echo "No coverage files found" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| if: always() | |
| with: | |
| name: Coverage-Report | |
| path: CoverageReport/ | |
| retention-days: 7 | |
| # ============================================ | |
| # サマリーレポート | |
| # ============================================ | |
| summary: | |
| name: Test Summary | |
| runs-on: ubuntu-latest | |
| needs: [unit-tests, integration-tests, coverage-report, vulnerability-check] | |
| if: always() | |
| steps: | |
| - name: Generate summary | |
| run: | | |
| echo "## Server Test Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Test Suite | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|------------|--------|" >> $GITHUB_STEP_SUMMARY | |
| # Unit Tests | |
| if [ "${{ needs.unit-tests.result }}" == "success" ]; then | |
| echo "| Unit Tests | ✅ Passed |" >> $GITHUB_STEP_SUMMARY | |
| elif [ "${{ needs.unit-tests.result }}" == "skipped" ]; then | |
| echo "| Unit Tests | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "| Unit Tests | ❌ Failed |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| # Integration Tests | |
| if [ "${{ needs.integration-tests.result }}" == "success" ]; then | |
| echo "| Integration Tests | ✅ Passed |" >> $GITHUB_STEP_SUMMARY | |
| elif [ "${{ needs.integration-tests.result }}" == "skipped" ]; then | |
| echo "| Integration Tests | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "| Integration Tests | ❌ Failed |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| # Coverage Report | |
| if [ "${{ needs.coverage-report.result }}" == "success" ]; then | |
| echo "| Coverage Report | ✅ Generated |" >> $GITHUB_STEP_SUMMARY | |
| elif [ "${{ needs.coverage-report.result }}" == "skipped" ]; then | |
| echo "| Coverage Report | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "| Coverage Report | ⚠️ Issues |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| # Vulnerability Check | |
| if [ "${{ needs.vulnerability-check.result }}" == "success" ]; then | |
| echo "| Vulnerability Check | ✅ No Issues |" >> $GITHUB_STEP_SUMMARY | |
| elif [ "${{ needs.vulnerability-check.result }}" == "skipped" ]; then | |
| echo "| Vulnerability Check | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "| Vulnerability Check | ❌ Vulnerable Packages Found |" >> $GITHUB_STEP_SUMMARY | |
| fi |