|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'src/**' |
| 8 | + - 'tests/**' |
| 9 | + - 'samples/**' |
| 10 | + - 'gen/**' |
| 11 | + - 'servicebus/**' |
| 12 | + - 'Directory.Packages.props' |
| 13 | + - 'docker-compose.yml' |
| 14 | + - '*.slnf' |
| 15 | + - '*.sln' |
| 16 | + - '.config/dotnet-tools.json' |
| 17 | + - '.github/workflows/CI.yml' |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - 'src/**' |
| 21 | + - 'tests/**' |
| 22 | + - 'samples/**' |
| 23 | + - 'gen/**' |
| 24 | + - 'servicebus/**' |
| 25 | + - 'Directory.Packages.props' |
| 26 | + - 'docker-compose.yml' |
| 27 | + - '*.slnf' |
| 28 | + - '*.sln' |
| 29 | + - '.config/dotnet-tools.json' |
| 30 | + - '.github/workflows/CI.yml' |
| 31 | + workflow_dispatch: |
| 32 | + |
| 33 | +concurrency: |
| 34 | + group: ci-${{ github.workflow }}-${{ github.ref }} |
| 35 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 36 | + |
| 37 | +permissions: |
| 38 | + contents: read |
| 39 | + |
| 40 | +jobs: |
| 41 | + build: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + timeout-minutes: 60 |
| 44 | + |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Start containers |
| 49 | + run: docker compose up -d |
| 50 | + |
| 51 | + - name: Setup .NET |
| 52 | + uses: actions/setup-dotnet@v4 |
| 53 | + with: |
| 54 | + dotnet-version: | |
| 55 | + 8.x |
| 56 | + 9.x |
| 57 | + 10.x |
| 58 | +
|
| 59 | + - name: Cache NuGet packages |
| 60 | + uses: actions/cache@v4 |
| 61 | + with: |
| 62 | + path: ~/.nuget/packages |
| 63 | + key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }} |
| 64 | + restore-keys: nuget-${{ runner.os }}- |
| 65 | + |
| 66 | + - name: Restore .NET tools |
| 67 | + run: dotnet tool restore |
| 68 | + |
| 69 | + - name: Restore (all) |
| 70 | + run: dotnet restore CoreEx.sln --verbosity minimal |
| 71 | + |
| 72 | + # --- Core --- |
| 73 | + |
| 74 | + - name: Build core |
| 75 | + run: dotnet build CoreEx.Core.slnf --no-restore --configuration Release |
| 76 | + |
| 77 | + - name: Test core (parallel) |
| 78 | + run: dotnet test CoreEx.Core.Test.Parallel.slnf --no-build --configuration Release --logger trx --collect "XPlat Code Coverage" --results-directory coverage/core |
| 79 | + |
| 80 | + - name: Test core (sequential) |
| 81 | + run: dotnet test CoreEx.Core.Test.Sequential.slnf --no-build --configuration Release --logger trx --collect "XPlat Code Coverage" --results-directory coverage/core -m:1 -p:TestTfmsInParallel=false -p:BuildInParallel=false |
| 82 | + |
| 83 | + - name: Upload core test results |
| 84 | + if: always() |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: core-test-results |
| 88 | + path: "coverage/core/**/*.trx" |
| 89 | + retention-days: 30 |
| 90 | + |
| 91 | + # --- Samples --- |
| 92 | + |
| 93 | + - name: Build samples |
| 94 | + run: dotnet build CoreEx.Samples.Build.slnf --no-restore --configuration Release |
| 95 | + |
| 96 | + - name: Database tool (samples/src/Contoso.Products.Database) |
| 97 | + working-directory: samples/src/Contoso.Products.Database |
| 98 | + run: dotnet run all --no-build --configuration Release -f net10.0 --expect-no-changes |
| 99 | + |
| 100 | + - name: Database tool (samples/src/Contoso.Shopping.Database) |
| 101 | + working-directory: samples/src/Contoso.Shopping.Database |
| 102 | + run: dotnet run all --no-build --configuration Release -f net10.0 --expect-no-changes |
| 103 | + |
| 104 | + - name: Database tool (samples/src/Contoso.Orders.Database) |
| 105 | + working-directory: samples/src/Contoso.Orders.Database |
| 106 | + run: dotnet run all --no-build --configuration Release -f net10.0 --expect-no-changes |
| 107 | + |
| 108 | + - name: Test samples |
| 109 | + run: dotnet test CoreEx.Samples.Test.slnf --no-build --configuration Release --logger trx --collect "XPlat Code Coverage" --results-directory coverage/samples -m:1 -p:TestTfmsInParallel=false -p:BuildInParallel=false |
| 110 | + |
| 111 | + - name: Upload samples test results |
| 112 | + if: always() |
| 113 | + uses: actions/upload-artifact@v4 |
| 114 | + with: |
| 115 | + name: samples-test-results |
| 116 | + path: "coverage/samples/**/*.trx" |
| 117 | + retention-days: 30 |
| 118 | + |
| 119 | + # --- Coverage --- |
| 120 | + |
| 121 | + - name: Merge and generate coverage report |
| 122 | + if: always() |
| 123 | + run: | |
| 124 | + dotnet tool run reportgenerator \ |
| 125 | + -reports:"coverage/**/coverage.cobertura.xml" \ |
| 126 | + -targetdir:"coverage/report" \ |
| 127 | + -reporttypes:"HtmlInline_AzurePipelines;Cobertura;Badges" \ |
| 128 | + -assemblyfilters:"-*Test*;-*E2E*" |
| 129 | +
|
| 130 | + - name: Upload coverage report |
| 131 | + if: always() |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: coverage-report |
| 135 | + path: coverage/report |
| 136 | + retention-days: 30 |
| 137 | + |
| 138 | + # --- Cleanup --- |
| 139 | + |
| 140 | + - name: Capture container logs on failure |
| 141 | + if: failure() |
| 142 | + run: docker compose logs --no-color > container-logs.txt 2>&1 |
| 143 | + |
| 144 | + - name: Upload container logs on failure |
| 145 | + if: failure() |
| 146 | + uses: actions/upload-artifact@v4 |
| 147 | + with: |
| 148 | + name: container-logs |
| 149 | + path: container-logs.txt |
| 150 | + retention-days: 30 |
| 151 | + |
| 152 | + - name: Stop containers |
| 153 | + if: always() |
| 154 | + run: docker compose down |
0 commit comments