|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + security-events: write # CodeQL needs this to upload SARIF results |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ci-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-test: |
| 20 | + name: Build & Test |
| 21 | + runs-on: windows-latest |
| 22 | + timeout-minutes: 20 |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Setup .NET (from global.json) |
| 29 | + uses: actions/setup-dotnet@v4 |
| 30 | + with: |
| 31 | + global-json-file: global.json |
| 32 | + |
| 33 | + - name: Cache NuGet packages |
| 34 | + uses: actions/cache@v4 |
| 35 | + with: |
| 36 | + path: ~/.nuget/packages |
| 37 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props', '**/*.csproj') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-nuget- |
| 40 | +
|
| 41 | + - name: Restore |
| 42 | + run: dotnet restore Mouse2Joy.sln |
| 43 | + |
| 44 | + - name: Verify formatting |
| 45 | + run: dotnet format Mouse2Joy.sln --verify-no-changes --no-restore --verbosity diagnostic |
| 46 | + |
| 47 | + - name: Build (Release, warnings-as-errors) |
| 48 | + run: dotnet build Mouse2Joy.sln -c Release --no-restore |
| 49 | + |
| 50 | + - name: Test (with coverage) |
| 51 | + run: dotnet test Mouse2Joy.sln -c Release --no-build --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" --results-directory ./TestResults |
| 52 | + |
| 53 | + - name: Upload test results |
| 54 | + if: always() |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: test-results |
| 58 | + path: ./TestResults/**/*.trx |
| 59 | + if-no-files-found: warn |
| 60 | + |
| 61 | + - name: Upload coverage |
| 62 | + if: always() |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: coverage |
| 66 | + path: ./TestResults/**/coverage.cobertura.xml |
| 67 | + if-no-files-found: warn |
| 68 | + |
| 69 | + codeql: |
| 70 | + name: CodeQL |
| 71 | + runs-on: windows-latest |
| 72 | + timeout-minutes: 30 |
| 73 | + |
| 74 | + steps: |
| 75 | + - name: Checkout |
| 76 | + uses: actions/checkout@v4 |
| 77 | + |
| 78 | + - name: Setup .NET (from global.json) |
| 79 | + uses: actions/setup-dotnet@v4 |
| 80 | + with: |
| 81 | + global-json-file: global.json |
| 82 | + |
| 83 | + - name: Initialize CodeQL |
| 84 | + uses: github/codeql-action/init@v3 |
| 85 | + with: |
| 86 | + languages: csharp |
| 87 | + build-mode: manual |
| 88 | + |
| 89 | + - name: Build (Release) |
| 90 | + run: | |
| 91 | + dotnet restore Mouse2Joy.sln |
| 92 | + dotnet build Mouse2Joy.sln -c Release --no-restore |
| 93 | +
|
| 94 | + - name: Perform CodeQL analysis |
| 95 | + uses: github/codeql-action/analyze@v3 |
| 96 | + with: |
| 97 | + category: "/language:csharp" |
0 commit comments