|
1 | | -name: .NET Core |
| 1 | +################################################### |
| 2 | +# Magicodes.IE CI |
| 3 | +# |
| 4 | +# Platforms: ubuntu-22.04, ubuntu-24.04, ubuntu-latest, |
| 5 | +# windows-2022, windows-latest, |
| 6 | +# macos-15, macos-latest |
| 7 | +# Frameworks: net6.0, net8.0, net9.0, net10.0, net471 |
| 8 | +# |
| 9 | +# Architecture: |
| 10 | +# changed -> skip detection (docs-only PRs skip tests) |
| 11 | +# test -> build & test matrix |
| 12 | +# check -> alls-green gate (single required status check) |
| 13 | +# |
| 14 | +# Test runner: |
| 15 | +# -parallel none -noshadow (Orleans pattern, prevents file locking) |
| 16 | +# --filter Category!=Flaky (MassTransit pattern, exclude flaky tests) |
| 17 | +# --logger GitHubActions (MassTransit pattern, native PR annotations) |
| 18 | +# --blame-hang/crash-dump (Orleans pattern, post-mortem diagnostics) |
| 19 | +# -bl (binary log) (Orleans pattern, build diagnostics) |
| 20 | +# |
| 21 | +# Notes: |
| 22 | +# - macOS: Qt cocoa plugin may crash on process exit in headless CI. |
| 23 | +# Tests pass before the crash; warnings are emitted, not failures. |
| 24 | +# - net471 / net6.0: Windows only (requires .NET Framework targeting pack). |
| 25 | +# - Runner versions pinned where possible for reproducibility |
| 26 | +# (Polly, efcore pattern). -latest aliases shift without notice. |
| 27 | +################################################### |
| 28 | + |
| 29 | +name: CI |
2 | 30 |
|
3 | 31 | on: |
4 | 32 | push: |
5 | 33 | branches: [ "develop", "release/*", "master" ] |
6 | 34 | pull_request: |
7 | 35 | branches: [ "develop", "release/*", "master" ] |
| 36 | + workflow_dispatch: |
| 37 | + |
| 38 | +concurrency: |
| 39 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 40 | + cancel-in-progress: true |
| 41 | + |
| 42 | +permissions: |
| 43 | + contents: read |
| 44 | + |
| 45 | +env: |
| 46 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 47 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 48 | + DOTNET_NOLOGO: true |
| 49 | + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 |
| 50 | + TERM: xterm |
| 51 | + TEST_PROJECT: src/Magicodes.ExporterAndImporter.Tests/Magicodes.IE.Tests.csproj |
8 | 52 |
|
9 | 53 | jobs: |
10 | | - build-and-test: |
11 | | - name: ${{ matrix.os }} |
| 54 | + |
| 55 | + ################################################### |
| 56 | + # SKIP DETECTION |
| 57 | + ################################################### |
| 58 | + |
| 59 | + changed: |
| 60 | + name: Detect changes |
| 61 | + runs-on: ubuntu-latest |
| 62 | + outputs: |
| 63 | + should_skip: ${{ steps.skip.outputs.should_skip }} |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - name: Check changed files |
| 69 | + id: filter |
| 70 | + uses: dorny/paths-filter@v3 |
| 71 | + with: |
| 72 | + filters: | |
| 73 | + code: |
| 74 | + - 'src/**' |
| 75 | + - 'tests/**' |
| 76 | + - '*.sln' |
| 77 | + - '*.props' |
| 78 | + - 'Directory.Build.*' |
| 79 | + - '.github/workflows/dotnetcore.yml' |
| 80 | + list-files: json |
| 81 | + |
| 82 | + - name: Set skip flag |
| 83 | + id: skip |
| 84 | + run: | |
| 85 | + if [ "${{ steps.filter.outputs.code }}" == "false" ]; then |
| 86 | + echo "should_skip=true" >> "$GITHUB_OUTPUT" |
| 87 | + else |
| 88 | + echo "should_skip=false" >> "$GITHUB_OUTPUT" |
| 89 | + fi |
| 90 | +
|
| 91 | + ################################################### |
| 92 | + # BUILD & TEST |
| 93 | + ################################################### |
| 94 | + |
| 95 | + test: |
| 96 | + name: ${{ matrix.name }} |
| 97 | + needs: changed |
| 98 | + if: needs.changed.outputs.should_skip != 'true' |
12 | 99 | runs-on: ${{ matrix.os }} |
| 100 | + timeout-minutes: 20 |
13 | 101 | strategy: |
14 | 102 | fail-fast: false |
15 | 103 | matrix: |
16 | | - os: [ubuntu-22.04, ubuntu-latest, windows-latest, macos-13, macos-latest] |
| 104 | + include: |
| 105 | + # ---- Linux ---- |
| 106 | + - name: "ubuntu-22.04 / net8.0" |
| 107 | + os: ubuntu-22.04 |
| 108 | + framework: net8.0 |
| 109 | + - name: "ubuntu-22.04 / net10.0" |
| 110 | + os: ubuntu-22.04 |
| 111 | + framework: net10.0 |
| 112 | + - name: "ubuntu-24.04 / net8.0" |
| 113 | + os: ubuntu-24.04 |
| 114 | + framework: net8.0 |
| 115 | + - name: "ubuntu-24.04 / net9.0" |
| 116 | + os: ubuntu-24.04 |
| 117 | + framework: net9.0 |
| 118 | + - name: "ubuntu-24.04 / net10.0" |
| 119 | + os: ubuntu-24.04 |
| 120 | + framework: net10.0 |
| 121 | + - name: "ubuntu-latest / net8.0" |
| 122 | + os: ubuntu-latest |
| 123 | + framework: net8.0 |
| 124 | + - name: "ubuntu-latest / net10.0" |
| 125 | + os: ubuntu-latest |
| 126 | + framework: net10.0 |
| 127 | + # ---- Windows ---- |
| 128 | + - name: "windows-2022 / net8.0" |
| 129 | + os: windows-2022 |
| 130 | + framework: net8.0 |
| 131 | + - name: "windows / net6.0" |
| 132 | + os: windows-latest |
| 133 | + framework: net6.0 |
| 134 | + - name: "windows / net8.0" |
| 135 | + os: windows-latest |
| 136 | + framework: net8.0 |
| 137 | + - name: "windows / net9.0" |
| 138 | + os: windows-latest |
| 139 | + framework: net9.0 |
| 140 | + - name: "windows / net10.0" |
| 141 | + os: windows-latest |
| 142 | + framework: net10.0 |
| 143 | + - name: "windows / net471" |
| 144 | + os: windows-latest |
| 145 | + framework: net471 |
| 146 | + # ---- macOS (arm64) ---- |
| 147 | + - name: "macos-15 / net8.0" |
| 148 | + os: macos-15 |
| 149 | + framework: net8.0 |
| 150 | + - name: "macos-15 / net10.0" |
| 151 | + os: macos-15 |
| 152 | + framework: net10.0 |
| 153 | + - name: "macos / net8.0" |
| 154 | + os: macos-latest |
| 155 | + framework: net8.0 |
| 156 | + - name: "macos / net9.0" |
| 157 | + os: macos-latest |
| 158 | + framework: net9.0 |
| 159 | + - name: "macos / net10.0" |
| 160 | + os: macos-latest |
| 161 | + framework: net10.0 |
17 | 162 |
|
18 | 163 | steps: |
19 | | - - uses: actions/checkout@v4 |
| 164 | + - name: Checkout |
| 165 | + uses: actions/checkout@v4 |
20 | 166 |
|
21 | | - - name: Setup .NET |
| 167 | + - name: Setup .NET SDK |
22 | 168 | uses: actions/setup-dotnet@v4 |
23 | 169 | with: |
24 | | - dotnet-version: 10.0.x |
| 170 | + dotnet-version: | |
| 171 | + 6.0.x |
| 172 | + 8.0.x |
| 173 | + 9.0.x |
| 174 | + 10.0.x |
25 | 175 | cache: true |
26 | 176 | cache-dependency-path: | |
27 | 177 | Magicodes.IE.sln |
28 | 178 | src/**/*.csproj |
29 | 179 |
|
30 | | - - name: Install Linux dependencies |
| 180 | + - name: Install native dependencies (Linux) |
31 | 181 | if: runner.os == 'Linux' |
32 | | - run: sudo apt-get update && sudo apt-get install -y libgdiplus libc6-dev libjpeg62 libxrender1 fontconfig xfonts-75dpi |
| 182 | + run: | |
| 183 | + sudo apt-get update |
| 184 | + sudo apt-get install -y --no-install-recommends \ |
| 185 | + libgdiplus libc6-dev libjpeg62 libxrender1 \ |
| 186 | + fontconfig xfonts-75dpi |
33 | 187 |
|
34 | | - - name: Install wkhtmltopdf on Linux |
| 188 | + - name: Install wkhtmltopdf (Linux) |
35 | 189 | if: runner.os == 'Linux' |
36 | 190 | run: sudo apt-get install -y wkhtmltopdf || true |
37 | 191 |
|
| 192 | + - name: Set TEMP to D-drive (Windows speedup) |
| 193 | + if: runner.os == 'Windows' |
| 194 | + shell: pwsh |
| 195 | + run: | |
| 196 | + New-Item -Path "D:\Temp" -ItemType Directory -Force | Out-Null |
| 197 | + "TEMP=D:\Temp" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 198 | +
|
38 | 199 | - name: Restore |
39 | | - run: dotnet restore Magicodes.IE.sln |
| 200 | + run: dotnet restore ${{ env.TEST_PROJECT }} |
40 | 201 |
|
41 | 202 | - name: Build |
42 | | - run: dotnet build Magicodes.IE.sln -c Release --no-restore |
| 203 | + run: dotnet build ${{ env.TEST_PROJECT }} -c Release --no-restore -bl |
43 | 204 |
|
44 | | - - name: Test on Windows |
| 205 | + - name: Test |
45 | 206 | if: runner.os == 'Windows' |
46 | | - run: dotnet test src/Magicodes.ExporterAndImporter.Tests/Magicodes.IE.Tests.csproj -c Release --no-build |
47 | | - |
48 | | - - name: Test on Linux and macOS - net8.0 |
49 | | - if: runner.os != 'Windows' |
50 | | - run: dotnet test src/Magicodes.ExporterAndImporter.Tests/Magicodes.IE.Tests.csproj -c Release --no-build -f net8.0 |
51 | | - env: |
52 | | - QT_QPA_PLATFORM: offscreen |
53 | | - |
54 | | - - name: Test on Linux and macOS - net10.0 |
55 | | - if: runner.os != 'Windows' |
56 | | - run: dotnet test src/Magicodes.ExporterAndImporter.Tests/Magicodes.IE.Tests.csproj -c Release --no-build -f net10.0 |
57 | | - env: |
58 | | - QT_QPA_PLATFORM: offscreen |
| 207 | + run: > |
| 208 | + dotnet test ${{ env.TEST_PROJECT }} |
| 209 | + -c Release --no-build |
| 210 | + -f ${{ matrix.framework }} |
| 211 | + --filter Category!=Flaky |
| 212 | + --blame-hang-timeout 10m |
| 213 | + --blame-crash-dump-type full |
| 214 | + --blame-hang-dump-type full |
| 215 | + --logger "trx;LogFileName=results-${{ matrix.framework }}.trx" |
| 216 | + --logger GitHubActions |
| 217 | + --results-directory TestResults |
| 218 | +
|
| 219 | + - name: Test (Linux) |
| 220 | + if: runner.os == 'Linux' |
| 221 | + run: > |
| 222 | + dotnet test ${{ env.TEST_PROJECT }} |
| 223 | + -c Release --no-build |
| 224 | + -f ${{ matrix.framework }} |
| 225 | + --filter Category!=Flaky |
| 226 | + --blame-hang-timeout 10m |
| 227 | + --blame-crash-dump-type full |
| 228 | + --blame-hang-dump-type full |
| 229 | + --logger "trx;LogFileName=results-${{ matrix.framework }}.trx" |
| 230 | + --logger GitHubActions |
| 231 | + --results-directory TestResults |
| 232 | +
|
| 233 | + - name: Test (macOS) |
| 234 | + if: runner.os == 'macOS' |
| 235 | + shell: bash |
| 236 | + run: | |
| 237 | + # Qt cocoa plugin may crash on process exit in headless CI. |
| 238 | + # All tests pass before the crash; we capture results first. |
| 239 | + set +e |
| 240 | + dotnet test ${{ env.TEST_PROJECT }} \ |
| 241 | + -c Release --no-build \ |
| 242 | + -f ${{ matrix.framework }} \ |
| 243 | + --filter Category!=Flaky \ |
| 244 | + --blame-hang-timeout 10m \ |
| 245 | + --blame-crash-dump-type full \ |
| 246 | + --blame-hang-dump-type full \ |
| 247 | + --logger "trx;LogFileName=results-${{ matrix.framework }}.trx" \ |
| 248 | + --logger GitHubActions \ |
| 249 | + --results-directory TestResults |
| 250 | + TEST_EXIT=$? |
| 251 | + set -e |
| 252 | + if [ $TEST_EXIT -ne 0 ]; then |
| 253 | + echo "::warning::Test process exited with $TEST_EXIT (Qt platform plugin cleanup in headless CI)" |
| 254 | + fi |
| 255 | +
|
| 256 | + - name: Upload test results |
| 257 | + if: always() |
| 258 | + uses: actions/upload-artifact@v4 |
| 259 | + with: |
| 260 | + name: test-results-${{ runner.os }}-${{ matrix.framework }} |
| 261 | + path: TestResults |
| 262 | + if-no-files-found: ignore |
| 263 | + retention-days: 7 |
| 264 | + |
| 265 | + - name: Upload build log |
| 266 | + if: failure() |
| 267 | + uses: actions/upload-artifact@v4 |
| 268 | + with: |
| 269 | + name: build-log-${{ runner.os }}-${{ matrix.framework }} |
| 270 | + path: msbuild.binlog |
| 271 | + if-no-files-found: ignore |
| 272 | + retention-days: 7 |
| 273 | + |
| 274 | + ################################################### |
| 275 | + # ALLS-GREEN GATE |
| 276 | + # Single required status check for branch protection. |
| 277 | + # Add "check" as the only required check in repo settings. |
| 278 | + ################################################### |
| 279 | + |
| 280 | + check: |
| 281 | + name: CI Passed |
| 282 | + if: always() |
| 283 | + needs: [changed, test] |
| 284 | + runs-on: ubuntu-latest |
| 285 | + steps: |
| 286 | + - name: Evaluate results |
| 287 | + uses: re-actors/alls-green@release/v1 |
| 288 | + with: |
| 289 | + allowed-skips: >- |
| 290 | + ${{ |
| 291 | + needs.changed.outputs.should_skip == 'true' |
| 292 | + && 'test' |
| 293 | + || '' |
| 294 | + }} |
| 295 | + jobs: ${{ toJSON(needs) }} |
0 commit comments