|
| 1 | +name: GeoSharPlus CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master, develop, template-cleanup ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master, develop ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + DOTNET_VERSION: '8.0.x' |
| 12 | + |
| 13 | +jobs: |
| 14 | + # ============================================ |
| 15 | + # Build and Test .NET Projects |
| 16 | + # ============================================ |
| 17 | + build-and-test-dotnet: |
| 18 | + name: Build & Test (.NET) |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 23 | + fail-fast: false |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + submodules: recursive |
| 30 | + |
| 31 | + - name: Setup .NET |
| 32 | + uses: actions/setup-dotnet@v4 |
| 33 | + with: |
| 34 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 35 | + |
| 36 | + - name: Cache NuGet packages |
| 37 | + uses: actions/cache@v4 |
| 38 | + with: |
| 39 | + path: ~/.nuget/packages |
| 40 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} |
| 41 | + restore-keys: | |
| 42 | + ${{ runner.os }}-nuget- |
| 43 | +
|
| 44 | + - name: Restore dependencies |
| 45 | + run: dotnet restore GeoSharPlusNET.Tests/GeoSharPlusNET.Tests.csproj |
| 46 | + |
| 47 | + - name: Build test project |
| 48 | + run: dotnet build GeoSharPlusNET.Tests/GeoSharPlusNET.Tests.csproj --configuration Release --no-restore |
| 49 | + |
| 50 | + - name: Run tests |
| 51 | + run: dotnet test GeoSharPlusNET.Tests/GeoSharPlusNET.Tests.csproj --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" |
| 52 | + |
| 53 | + - name: Upload test results |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + if: always() |
| 56 | + with: |
| 57 | + name: test-results-${{ matrix.os }} |
| 58 | + path: '**/TestResults/*.trx' |
| 59 | + |
| 60 | + # ============================================ |
| 61 | + # Build GeoSharPlusNET Library |
| 62 | + # ============================================ |
| 63 | + build-library: |
| 64 | + name: Build Library |
| 65 | + runs-on: windows-latest |
| 66 | + needs: build-and-test-dotnet |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Checkout repository |
| 70 | + uses: actions/checkout@v4 |
| 71 | + with: |
| 72 | + submodules: recursive |
| 73 | + |
| 74 | + - name: Setup .NET |
| 75 | + uses: actions/setup-dotnet@v4 |
| 76 | + with: |
| 77 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 78 | + |
| 79 | + - name: Cache NuGet packages |
| 80 | + uses: actions/cache@v4 |
| 81 | + with: |
| 82 | + path: ~/.nuget/packages |
| 83 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} |
| 84 | + restore-keys: | |
| 85 | + ${{ runner.os }}-nuget- |
| 86 | +
|
| 87 | + - name: Restore GeoSharPlusNET |
| 88 | + run: dotnet restore GeoSharPlusNET/GeoSharPlusNET.csproj |
| 89 | + |
| 90 | + - name: Build GeoSharPlusNET (Release) |
| 91 | + run: dotnet build GeoSharPlusNET/GeoSharPlusNET.csproj --configuration Release --no-restore |
| 92 | + |
| 93 | + - name: Upload build artifacts |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: GeoSharPlusNET-build |
| 97 | + path: GeoSharPlusNET/bin/Release/ |
| 98 | + |
| 99 | + # ============================================ |
| 100 | + # Code Quality Checks |
| 101 | + # ============================================ |
| 102 | + code-quality: |
| 103 | + name: Code Quality |
| 104 | + runs-on: ubuntu-latest |
| 105 | + |
| 106 | + steps: |
| 107 | + - name: Checkout repository |
| 108 | + uses: actions/checkout@v4 |
| 109 | + |
| 110 | + - name: Setup .NET |
| 111 | + uses: actions/setup-dotnet@v4 |
| 112 | + with: |
| 113 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 114 | + |
| 115 | + - name: Restore dependencies |
| 116 | + run: dotnet restore GeoSharPlusNET.Tests/GeoSharPlusNET.Tests.csproj |
| 117 | + |
| 118 | + - name: Check code formatting |
| 119 | + run: dotnet format GeoSharPlusNET.Tests/GeoSharPlusNET.Tests.csproj --verify-no-changes --verbosity diagnostic |
| 120 | + continue-on-error: true |
| 121 | + |
| 122 | + # ============================================ |
| 123 | + # Test Coverage Report |
| 124 | + # ============================================ |
| 125 | + coverage: |
| 126 | + name: Test Coverage |
| 127 | + runs-on: ubuntu-latest |
| 128 | + needs: build-and-test-dotnet |
| 129 | + |
| 130 | + steps: |
| 131 | + - name: Checkout repository |
| 132 | + uses: actions/checkout@v4 |
| 133 | + |
| 134 | + - name: Setup .NET |
| 135 | + uses: actions/setup-dotnet@v4 |
| 136 | + with: |
| 137 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 138 | + |
| 139 | + - name: Restore dependencies |
| 140 | + run: dotnet restore GeoSharPlusNET.Tests/GeoSharPlusNET.Tests.csproj |
| 141 | + |
| 142 | + - name: Run tests with coverage |
| 143 | + run: | |
| 144 | + dotnet test GeoSharPlusNET.Tests/GeoSharPlusNET.Tests.csproj \ |
| 145 | + --configuration Release \ |
| 146 | + --collect:"XPlat Code Coverage" \ |
| 147 | + --results-directory ./coverage |
| 148 | +
|
| 149 | + - name: Upload coverage reports |
| 150 | + uses: actions/upload-artifact@v4 |
| 151 | + with: |
| 152 | + name: coverage-report |
| 153 | + path: coverage/**/coverage.cobertura.xml |
0 commit comments