|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + pull_request: |
| 8 | + branches: [main] |
| 9 | + |
| 10 | +jobs: |
| 11 | + lint: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + - name: Setup .NET |
| 16 | + uses: actions/setup-dotnet@v4 |
| 17 | + with: |
| 18 | + dotnet-version: 10.0.x |
| 19 | + - name: Cache NuGet packages |
| 20 | + uses: actions/cache@v4 |
| 21 | + with: |
| 22 | + path: ~/.nuget/packages |
| 23 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} |
| 24 | + restore-keys: | |
| 25 | + ${{ runner.os }}-nuget- |
| 26 | + - name: Restore dependencies |
| 27 | + run: dotnet restore |
| 28 | + - name: Build with analyzers |
| 29 | + run: dotnet build -c Release -warnaserror |
| 30 | + |
| 31 | + test: |
| 32 | + runs-on: ${{ matrix.os }} |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 37 | + dotnet: [8.0.x, 10.0.x] |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + - name: Setup .NET |
| 41 | + uses: actions/setup-dotnet@v4 |
| 42 | + with: |
| 43 | + dotnet-version: ${{ matrix.dotnet }} |
| 44 | + - name: Cache NuGet packages |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: ~/.nuget/packages |
| 48 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-nuget- |
| 51 | + - name: Restore dependencies |
| 52 | + run: dotnet restore |
| 53 | + - name: Test with coverage |
| 54 | + run: dotnet test -c Release --no-restore --verbosity normal --collect:"XPlat Code Coverage" --settings tests/coverlet.runsettings |
| 55 | + - name: Upload coverage to Codecov |
| 56 | + if: matrix.os == 'ubuntu-latest' && matrix.dotnet == '10.0.x' |
| 57 | + uses: codecov/codecov-action@v4 |
| 58 | + with: |
| 59 | + token: ${{ secrets.CODE_COV_TOKEN }} |
| 60 | + fail_ci_if_error: true |
| 61 | + |
| 62 | + build: |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: [lint, test] |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + - name: Setup .NET |
| 68 | + uses: actions/setup-dotnet@v4 |
| 69 | + with: |
| 70 | + dotnet-version: 10.0.x |
| 71 | + - name: Cache NuGet packages |
| 72 | + uses: actions/cache@v4 |
| 73 | + with: |
| 74 | + path: ~/.nuget/packages |
| 75 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} |
| 76 | + restore-keys: | |
| 77 | + ${{ runner.os }}-nuget- |
| 78 | + - name: Restore dependencies |
| 79 | + run: dotnet restore |
| 80 | + - name: Build |
| 81 | + run: dotnet build -c Release --no-restore |
| 82 | + - name: Pack |
| 83 | + run: dotnet pack -c Release --no-build -o ./artifacts |
| 84 | + - name: Upload artifacts |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: packages |
| 88 | + path: ./artifacts |
0 commit comments