|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + checks: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +env: |
| 20 | + DOTNET_VERSION: '9.0.x' |
| 21 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 22 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + name: Build and Analyze |
| 27 | + runs-on: ubuntu-latest |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 # Full history for better analysis |
| 34 | + |
| 35 | + - name: Setup .NET |
| 36 | + uses: actions/setup-dotnet@v4 |
| 37 | + with: |
| 38 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 39 | + |
| 40 | + - name: Cache NuGet packages |
| 41 | + uses: actions/cache@v4 |
| 42 | + with: |
| 43 | + path: ~/.nuget/packages |
| 44 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props', '**/Directory.Build.props') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-nuget- |
| 47 | +
|
| 48 | + - name: Restore dependencies |
| 49 | + run: dotnet restore ICTAce.FileHub.slnx |
| 50 | + |
| 51 | + - name: Build solution |
| 52 | + run: dotnet build ICTAce.FileHub.slnx --configuration Release --no-restore |
| 53 | + |
| 54 | + - name: Verify analyzer enforcement |
| 55 | + run: | |
| 56 | + echo "Verifying code quality analyzers are enabled..." |
| 57 | + echo "✓ SonarAnalyzer.CSharp" |
| 58 | + echo "✓ Meziantou.Analyzer" |
| 59 | + echo "✓ AsyncFixer" |
| 60 | + echo "✓ Roslynator.Analyzers" |
| 61 | + echo "Build completed with analyzer checks enforced" |
| 62 | +
|
| 63 | + test-server: |
| 64 | + name: Server Unit Tests (TUnit) |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: build |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Checkout code |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Setup .NET |
| 73 | + uses: actions/setup-dotnet@v4 |
| 74 | + with: |
| 75 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 76 | + |
| 77 | + - name: Cache NuGet packages |
| 78 | + uses: actions/cache@v4 |
| 79 | + with: |
| 80 | + path: ~/.nuget/packages |
| 81 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props', '**/Directory.Build.props') }} |
| 82 | + restore-keys: | |
| 83 | + ${{ runner.os }}-nuget- |
| 84 | +
|
| 85 | + - name: Restore dependencies |
| 86 | + run: dotnet restore Server.Tests/ICTAce.FileHub.Server.Tests.csproj |
| 87 | + |
| 88 | + - name: Build test project |
| 89 | + run: dotnet build Server.Tests/ICTAce.FileHub.Server.Tests.csproj --configuration Release --no-restore |
| 90 | + |
| 91 | + - name: Run server tests |
| 92 | + run: dotnet test Server.Tests/ICTAce.FileHub.Server.Tests.csproj --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=server-test-results.trx" |
| 93 | + continue-on-error: true |
| 94 | + |
| 95 | + - name: Upload server test results |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + if: always() |
| 98 | + with: |
| 99 | + name: server-test-results |
| 100 | + path: Server.Tests/TestResults/*.trx |
| 101 | + retention-days: 30 |
| 102 | + |
| 103 | + test-client: |
| 104 | + name: Client Component Tests (bUnit) |
| 105 | + runs-on: ubuntu-latest |
| 106 | + needs: build |
| 107 | + |
| 108 | + steps: |
| 109 | + - name: Checkout code |
| 110 | + uses: actions/checkout@v4 |
| 111 | + |
| 112 | + - name: Setup .NET |
| 113 | + uses: actions/setup-dotnet@v4 |
| 114 | + with: |
| 115 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 116 | + |
| 117 | + - name: Cache NuGet packages |
| 118 | + uses: actions/cache@v4 |
| 119 | + with: |
| 120 | + path: ~/.nuget/packages |
| 121 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props', '**/Directory.Build.props') }} |
| 122 | + restore-keys: | |
| 123 | + ${{ runner.os }}-nuget- |
| 124 | +
|
| 125 | + - name: Restore dependencies |
| 126 | + run: dotnet restore Client.Tests/ICTAce.FileHub.Client.Tests.csproj |
| 127 | + |
| 128 | + - name: Build test project |
| 129 | + run: dotnet build Client.Tests/ICTAce.FileHub.Client.Tests.csproj --configuration Release --no-restore |
| 130 | + |
| 131 | + - name: Run client component tests |
| 132 | + run: dotnet test Client.Tests/ICTAce.FileHub.Client.Tests.csproj --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=client-test-results.trx" |
| 133 | + continue-on-error: true |
| 134 | + |
| 135 | + - name: Upload client test results |
| 136 | + uses: actions/upload-artifact@v4 |
| 137 | + if: always() |
| 138 | + with: |
| 139 | + name: client-test-results |
| 140 | + path: Client.Tests/TestResults/*.trx |
| 141 | + retention-days: 30 |
| 142 | + |
| 143 | + test-summary: |
| 144 | + name: Test Summary |
| 145 | + runs-on: ubuntu-latest |
| 146 | + needs: [test-server, test-client] |
| 147 | + if: always() |
| 148 | + |
| 149 | + steps: |
| 150 | + - name: Check test results |
| 151 | + run: | |
| 152 | + echo "## Test Execution Summary" >> $GITHUB_STEP_SUMMARY |
| 153 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 154 | + echo "✅ Server Unit Tests: ${{ needs.test-server.result }}" >> $GITHUB_STEP_SUMMARY |
| 155 | + echo "✅ Client Component Tests: ${{ needs.test-client.result }}" >> $GITHUB_STEP_SUMMARY |
| 156 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 157 | + echo "### Code Quality Checks" >> $GITHUB_STEP_SUMMARY |
| 158 | + echo "- ✓ SonarAnalyzer.CSharp" >> $GITHUB_STEP_SUMMARY |
| 159 | + echo "- ✓ Meziantou.Analyzer" >> $GITHUB_STEP_SUMMARY |
| 160 | + echo "- ✓ AsyncFixer" >> $GITHUB_STEP_SUMMARY |
| 161 | + echo "- ✓ Roslynator.Analyzers" >> $GITHUB_STEP_SUMMARY |
| 162 | + echo "- ✓ BannedApiAnalyzers" >> $GITHUB_STEP_SUMMARY |
| 163 | + |
| 164 | + - name: Fail if any tests failed |
| 165 | + if: needs.test-server.result == 'failure' || needs.test-client.result == 'failure' |
| 166 | + run: | |
| 167 | + echo "❌ One or more test jobs failed" |
| 168 | + exit 1 |
0 commit comments