|
1 | 1 | name: Build and Test |
2 | 2 |
|
3 | | -on: [push] |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master, main] |
| 6 | + pull_request: |
| 7 | + branches: [master, main] |
4 | 8 |
|
5 | 9 | jobs: |
6 | 10 | build: |
7 | | - runs-on: ubuntu-latest |
| 11 | + name: Build & Test |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 18 | + |
8 | 19 | steps: |
9 | | - - uses: actions/checkout@v1 |
10 | | - - name: Setup .NET Core |
11 | | - uses: actions/setup-dotnet@v1 |
12 | | - with: |
13 | | - dotnet-version: 2.2.108 |
14 | | - - name: Build with .NET Core |
15 | | - run: dotnet build --configuration Release |
16 | | - test: |
17 | | - runs-on: ubuntu-latest |
18 | | - needs: build |
19 | | - steps: |
20 | | - - uses: actions/checkout@v1 |
21 | | - - name: Run Tests |
22 | | - run: dotnet test |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Setup .NET |
| 24 | + uses: actions/setup-dotnet@v4 |
| 25 | + with: |
| 26 | + dotnet-version: '10.0.x' |
| 27 | + |
| 28 | + - name: Cache NuGet packages |
| 29 | + uses: actions/cache@v4 |
| 30 | + with: |
| 31 | + path: ~/.nuget/packages |
| 32 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} |
| 33 | + restore-keys: | |
| 34 | + ${{ runner.os }}-nuget- |
| 35 | +
|
| 36 | + - name: Restore dependencies |
| 37 | + run: dotnet restore |
| 38 | + |
| 39 | + - name: Build |
| 40 | + run: dotnet build --configuration Release --no-restore |
| 41 | + |
| 42 | + - name: Test |
| 43 | + run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" |
| 44 | + |
| 45 | + - name: Upload coverage reports |
| 46 | + uses: codecov/codecov-action@v4 |
| 47 | + if: matrix.os == 'ubuntu-latest' |
| 48 | + with: |
| 49 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 50 | + fail_ci_if_error: false |
0 commit comments