|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["master", "develop", "feature/**", "release/**", "hotfix/**"] |
| 6 | + tags: ["*"] |
| 7 | + pull_request: |
| 8 | + branches: ["master", "develop"] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ci-${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + # Keep the Windows build separate so we still validate the .NET Framework target |
| 20 | + # and the packaging prerequisites that only exist on Windows runners. |
| 21 | + build-windows: |
| 22 | + name: Build (Windows) |
| 23 | + runs-on: windows-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v6 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + submodules: recursive |
| 31 | + |
| 32 | + - name: Setup .NET SDKs |
| 33 | + uses: actions/setup-dotnet@v5 |
| 34 | + with: |
| 35 | + dotnet-version: | |
| 36 | + 6.0.x |
| 37 | + 8.0.x |
| 38 | + 9.0.x |
| 39 | + 10.0.x |
| 40 | +
|
| 41 | + - name: Cache NuGet packages |
| 42 | + uses: actions/cache@v5 |
| 43 | + with: |
| 44 | + path: ~/.nuget/packages |
| 45 | + key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets', '.config/dotnet-tools.json') }} |
| 46 | + restore-keys: | |
| 47 | + nuget-${{ runner.os }}- |
| 48 | +
|
| 49 | + - name: Restore .NET tools |
| 50 | + run: dotnet tool restore |
| 51 | + |
| 52 | + - name: Restore solution |
| 53 | + run: dotnet restore ./src/NEventStore.Persistence.MongoDB.Core.sln --verbosity m |
| 54 | + |
| 55 | + - name: Run GitVersion and patch assembly info |
| 56 | + id: gitversion |
| 57 | + shell: pwsh |
| 58 | + run: | |
| 59 | + $gitVersion = dotnet tool run dotnet-gitversion /output json /updateAssemblyInfo | ConvertFrom-Json |
| 60 | + dotnet tool run dotnet-gitversion ".\dependencies\NEventStore" /updateAssemblyInfo | Out-Null |
| 61 | + "semver=$($gitVersion.SemVer)" >> $env:GITHUB_OUTPUT |
| 62 | +
|
| 63 | + - name: Build solution |
| 64 | + run: dotnet build ./src/NEventStore.Persistence.MongoDB.Core.sln -c Release --no-restore /p:ContinuousIntegrationBuild=True |
| 65 | + |
| 66 | + # Tests run on Linux because this repository needs a live MongoDB instance and |
| 67 | + # GitHub Actions service containers are only available on Linux runners. |
| 68 | + # The matrix is therefore per target framework instead of per OS. |
| 69 | + test-modern-tfm-linux: |
| 70 | + name: Test (Linux, ${{ matrix.tfm }}) |
| 71 | + runs-on: ubuntu-24.04 |
| 72 | + strategy: |
| 73 | + fail-fast: false |
| 74 | + matrix: |
| 75 | + # Run each modern TFM independently so failures are isolated and easy to read. |
| 76 | + tfm: |
| 77 | + - net8.0 |
| 78 | + - net9.0 |
| 79 | + - net10.0 |
| 80 | + |
| 81 | + services: |
| 82 | + # The test project reads NEventStore.MongoDB from the environment and expects |
| 83 | + # a real MongoDB server. This sidecar provides that dependency for each matrix leg. |
| 84 | + mongodb: |
| 85 | + image: mongo:7.0 |
| 86 | + ports: |
| 87 | + - 27017:27017 |
| 88 | + options: >- |
| 89 | + --health-cmd "mongosh --eval \"db.adminCommand('ping')\"" |
| 90 | + --health-interval 10s |
| 91 | + --health-timeout 5s |
| 92 | + --health-retries 10 |
| 93 | +
|
| 94 | + env: |
| 95 | + # Match the connection-string convention used by the acceptance tests. |
| 96 | + NEventStore.MongoDB: mongodb://127.0.0.1:27017/NEventStore |
| 97 | + |
| 98 | + steps: |
| 99 | + - name: Checkout |
| 100 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 |
| 101 | + with: |
| 102 | + submodules: recursive |
| 103 | + |
| 104 | + - name: Setup .NET SDKs |
| 105 | + uses: actions/setup-dotnet@v5 |
| 106 | + with: |
| 107 | + dotnet-version: | |
| 108 | + 6.0.x |
| 109 | + 8.0.x |
| 110 | + 9.0.x |
| 111 | + 10.0.x |
| 112 | +
|
| 113 | + - name: Cache NuGet packages |
| 114 | + uses: actions/cache@v5 |
| 115 | + with: |
| 116 | + path: ~/.nuget/packages |
| 117 | + key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets', '.config/dotnet-tools.json') }} |
| 118 | + restore-keys: | |
| 119 | + nuget-${{ runner.os }}- |
| 120 | +
|
| 121 | + - name: Run tests for ${{ matrix.tfm }} |
| 122 | + # Only the test project is executed here. It pulls in the production project and |
| 123 | + # linked acceptance coverage from the NEventStore submodule. |
| 124 | + run: dotnet test ./src/NEventStore.Persistence.MongoDB.Tests/NEventStore.Persistence.MongoDB.Core.Tests.csproj -c Release -f ${{ matrix.tfm }} --logger "trx;LogFileName=test-results-${{ matrix.tfm }}.trx" |
| 125 | + |
| 126 | + - name: Upload test results |
| 127 | + uses: actions/upload-artifact@v7 |
| 128 | + with: |
| 129 | + name: test-results-${{ matrix.tfm }} |
| 130 | + path: "**/test-results-${{ matrix.tfm }}.trx" |
| 131 | + if-no-files-found: error |
| 132 | + retention-days: 14 |
0 commit comments