|
| 1 | +name: CI (.NET) |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ master ] |
| 6 | + push: |
| 7 | + branches: [ master ] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + lint-and-format: |
| 15 | + name: Lint and Format Check |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 10 |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup .NET 8.0.x |
| 23 | + uses: actions/setup-dotnet@v4 |
| 24 | + with: |
| 25 | + dotnet-version: 8.0.x |
| 26 | + |
| 27 | + - name: Restore |
| 28 | +run: dotnet restore AiDotNet.sln |
| 29 | + - name: Verify code style (dotnet format) |
| 30 | + run: | |
| 31 | + dotnet tool update -g dotnet-format || dotnet tool install -g dotnet-format |
| 32 | + export PATH="$PATH:$HOME/.dotnet/tools" |
| 33 | + dotnet format AiDotNet.sln --verify-no-changes || (echo "Run 'dotnet format' locally to fix style issues." && exit 1) |
| 34 | +build: |
| 35 | + name: Build |
| 36 | + strategy: |
| 37 | + matrix: |
| 38 | + dotnet: ['6.0.x', '8.0.x'] |
| 39 | + fail-fast: false |
| 40 | + runs-on: ubuntu-latest |
| 41 | + timeout-minutes: 15 |
| 42 | + steps: |
| 43 | + - name: Checkout code |
| 44 | + uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Setup .NET 8.0.x |
| 47 | + uses: actions/setup-dotnet@v4 |
| 48 | + with: |
| 49 | + dotnet-version: 8.0.x |
| 50 | + |
| 51 | + - name: Restore |
| 52 | +run: dotnet restore AiDotNet.sln |
| 53 | + - name: Build |
| 54 | + run: dotnet build AiDotNet.sln --configuration Release --no-restore |
| 55 | + |
| 56 | + - name: Publish core library (sanity) |
| 57 | + run: | |
| 58 | + if [ -f "src/AiDotNet.csproj" ]; then |
| 59 | + dotnet publish src/AiDotNet.csproj -c Release -o out |
| 60 | + else |
| 61 | + echo "AiDotNet.csproj not found, skipping publish sanity" |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Upload build artifacts |
| 65 | + uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + name: build-${{ github.sha }} |
| 68 | + path: | |
| 69 | + out/ |
| 70 | + **/bin/Release/ |
| 71 | + if-no-files-found: ignore |
| 72 | + retention-days: 7 |
| 73 | + |
| 74 | + test: |
| 75 | + name: Test (.NET ${{ matrix.dotnet }}) |
| 76 | + runs-on: ubuntu-latest |
| 77 | + timeout-minutes: 20 |
| 78 | + strategy: |
| 79 | + matrix: |
| 80 | + dotnet: ['6.0.x', '8.0.x'] |
| 81 | + fail-fast: false |
| 82 | + steps: |
| 83 | + - name: Checkout code |
| 84 | + uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - name: Setup .NET 8.0.x |
| 87 | + uses: actions/setup-dotnet@v4 |
| 88 | + with: |
| 89 | + dotnet-version: 8.0.x |
| 90 | + |
| 91 | + - name: Restore |
| 92 | +run: dotnet restore AiDotNet.sln |
| 93 | + - name: Run tests with coverage |
| 94 | + run: | |
| 95 | + dotnet test AiDotNet.sln --configuration Release --collect:"XPlat Code Coverage" --results-directory ./TestResults |
| 96 | +
|
| 97 | + - name: Upload coverage to Codecov (only uploads if secret set)\n uses: codecov/codecov-action@v4 |
| 98 | + with: |
| 99 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 100 | + files: | |
| 101 | + ./TestResults/**/coverage.cobertura.xml |
| 102 | + flags: unittests |
| 103 | + fail_ci_if_error: false |
| 104 | + |
| 105 | + integration-test: |
| 106 | + name: Integration Tests |
| 107 | + runs-on: ubuntu-latest |
| 108 | + timeout-minutes: 15 |
| 109 | + needs: build |
| 110 | + steps: |
| 111 | + - name: Checkout code |
| 112 | + uses: actions/checkout@v4 |
| 113 | + |
| 114 | + - name: Setup .NET 8.0.x |
| 115 | + uses: actions/setup-dotnet@v4 |
| 116 | + with: |
| 117 | + dotnet-version: 8.0.x |
| 118 | + |
| 119 | + - name: Run integration console (if present) |
| 120 | + run: | |
| 121 | + if [ -f "testconsole/AiDotNetTestConsole.csproj" ]; then |
| 122 | + dotnet run -c Release -p testconsole/AiDotNetTestConsole.csproj || exit 1 |
| 123 | + else |
| 124 | + echo "No integration console project found; skipping" |
| 125 | + fi |
| 126 | +
|
| 127 | + status-check: |
| 128 | + name: All Checks Passed |
| 129 | + runs-on: ubuntu-latest |
| 130 | + if: always() |
| 131 | + needs: [lint-and-format, build, build-netfx, test, integration-test] |
| 132 | + steps: |
| 133 | + - name: Verify job outcomes |
| 134 | + run: | |
| 135 | + [ "${{ needs.lint-and-format.result }}" = "success" ] || (echo "Lint/format failed" && exit 1) |
| 136 | + [ "${{ needs.build.result }}" = "success" ] || (echo "Build failed" && exit 1) |
| 137 | + [ "${{ needs.test.result }}" = "success" ] || (echo "Tests failed" && exit 1) |
| 138 | + [ "${{ needs.integration-test.result }}" = "success" ] || (echo "Integration tests failed" && exit 1) |
| 139 | + echo "All checks passed!" |
| 140 | +
|
| 141 | +
|
| 142 | +
|
| 143 | +
|
| 144 | +
|
| 145 | +
|
| 146 | +
|
| 147 | + build-netfx: |
| 148 | + name: Build (.NET Framework 4.6) |
| 149 | + runs-on: windows-latest |
| 150 | + timeout-minutes: 15 |
| 151 | + steps: |
| 152 | + - name: Checkout code |
| 153 | + uses: actions/checkout@v4 |
| 154 | + |
| 155 | + - name: Setup .NET SDK |
| 156 | + uses: actions/setup-dotnet@v4 |
| 157 | + with: |
| 158 | + dotnet-version: 8.0.x |
| 159 | + |
| 160 | + - name: Restore |
| 161 | + shell: pwsh |
| 162 | + run: | |
| 163 | + dotnet restore |
| 164 | +
|
| 165 | + - name: Build (Windows MSBuild) |
| 166 | + shell: pwsh |
| 167 | + run: | |
| 168 | + # Build all projects; if multi-targeting includes net46, MSBuild will build it on Windows |
| 169 | + dotnet build -c Release --no-restore |
| 170 | +
|
| 171 | + - name: Upload netfx build artifacts |
| 172 | + if: always() |
| 173 | + uses: actions/upload-artifact@v4 |
| 174 | + with: |
| 175 | + name: netfx-build-${{ github.sha }} |
| 176 | + path: | |
| 177 | + **/bin/Release/ |
| 178 | + if-no-files-found: ignore |
| 179 | + retention-days: 7 |
| 180 | + |
| 181 | + |
0 commit comments