Skip to content

Commit 14e820f

Browse files
committed
Update Github Actions to use OS matrix
1 parent 221069e commit 14e820f

File tree

2 files changed

+57
-74
lines changed

2 files changed

+57
-74
lines changed

.github/workflows/build-status.yml

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,63 @@ on:
33
push:
44
branches:
55
- master
6-
6+
env:
7+
DOTNET_VERSION: '6.0.x'
78
jobs:
8-
build-and-test-windows:
9-
name: Build And Test
10-
runs-on: windows-2019
11-
9+
build-and-test:
10+
name: Build And Test ${{matrix.os}}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macOS-latest]
1215
steps:
1316
- uses: actions/checkout@v2
1417

1518
- name: Setup .NET Core
1619
uses: actions/setup-dotnet@v1
1720
with:
18-
dotnet-version: 6.0.101
21+
dotnet-version: ${{ env.DOTNET_VERSION }}
1922

20-
- name: Restore nHapi
23+
- name: Restore nHapi (Windows)
24+
if: matrix.os == 'windows-latest'
2125
run: |
2226
dotnet restore nHapi.sln --configfile build\.nuget\NuGet.config
2327
28+
- name: Restore nHapi (Non-Windows)
29+
if: matrix.os != 'windows-latest'
30+
run: |
31+
dotnet restore nHapi.sln --configfile build/.nuget/NuGet.config
32+
2433
- name: Build nHapi
2534
run: |
2635
dotnet build nHapi.sln -c Release --no-restore
2736
28-
- name: Run tests for all target frameworks
37+
- name: Run tests for all target frameworks (Windows)
38+
if: matrix.os == 'windows-latest'
2939
run: |
3040
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj -r TestResults -c Release -f net461 --no-restore --no-build
31-
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj -r TestResults -c Release -f net6.0--no-restore --no-build
41+
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj -r TestResults -c Release -f net6.0 --no-restore --no-build
3242
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj -r TestResults -c Release -f net6.0 --no-restore --no-build
3343
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj -r TestResults -c Release -f net461 --no-restore --no-build
3444
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj -r TestResults -c Release -f net6.0 --no-restore --no-build
3545
36-
build-and-test-linux:
37-
name: Build And Test Linux
38-
runs-on: ubuntu-latest
39-
40-
steps:
41-
- uses: actions/checkout@v2
42-
43-
- name: Setup .NET Core
44-
uses: actions/setup-dotnet@v1
45-
with:
46-
dotnet-version: 6.0.101
47-
48-
- name: Restore nHapi
49-
run: |
50-
dotnet restore nHapi.sln --configfile build/.nuget/NuGet.config
51-
52-
- name: Build nHapi
53-
run: |
54-
dotnet build nHapi.sln -c Release --no-restore
55-
56-
- name: Run tests for all target frameworks
46+
- name: Run tests for all target frameworks (Non-Windows)
47+
if: matrix.os != 'windows-latest'
5748
run: |
5849
dotnet test tests/NHapi.Base.NUnit/NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
5950
dotnet test tests/NHapi.NUnit.SourceGeneration/NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
6051
dotnet test tests/NHapi.NUnit/NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
6152
6253
- name: Upload Code Coverage Report
63-
if: always()
54+
if: always() && matrix.os == 'ubuntu-latest'
6455
uses: actions/upload-artifact@v2
6556
with:
6657
name: coverage-reports
6758
path: |
6859
TestResults/
6960
7061
publish-coverage-results:
71-
needs: build-and-test-linux
62+
needs: build-and-test
7263
name: Publish Code Coverage Results
7364
runs-on: ubuntu-latest
7465
# the build-and-test job might be skipped, we don't need to run this job then

.github/workflows/receive-pr.yml

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,68 @@
11
name: Receive Pull Request
22

33
on: [pull_request]
4-
4+
env:
5+
DOTNET_VERSION: '6.0.x'
56
jobs:
6-
build-and-test-windows:
7-
name: Build And Test
8-
runs-on: windows-2019
9-
7+
build-and-test:
8+
name: Build And Test ${{matrix.os}}
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest, windows-latest, macOS-latest]
1013
steps:
1114
- uses: actions/checkout@v2
1215

1316
- name: Setup .NET Core
1417
uses: actions/setup-dotnet@v1
1518
with:
16-
dotnet-version: 6.0.101
17-
- name: Restore nHapi
19+
dotnet-version: ${{ env.DOTNET_VERSION }}
20+
21+
- name: Restore nHapi (Windows)
22+
if: matrix.os == 'windows-latest'
1823
run: |
1924
dotnet restore nHapi.sln --configfile build\.nuget\NuGet.config
2025
26+
- name: Restore nHapi (Non-Windows)
27+
if: matrix.os != 'windows-latest'
28+
run: |
29+
dotnet restore nHapi.sln --configfile build/.nuget/NuGet.config
30+
2131
- name: Build nHapi
2232
run: |
2333
dotnet build nHapi.sln -c Release --no-restore
2434
25-
- name: Run tests for all target frameworks
35+
- name: Run tests for all target frameworks (Windows)
36+
if: matrix.os == 'windows-latest'
37+
run: |
38+
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
39+
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net6.0 --no-restore --no-build
40+
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net6.0 --no-restore --no-build
41+
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
42+
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net6.0 --no-restore --no-build
43+
44+
- name: Run tests for all target frameworks (Non-Windows)
45+
if: matrix.os != 'windows-latest'
2646
run: |
27-
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
28-
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net6.0 --no-restore --no-build
29-
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net6.0 --no-restore --no-build
30-
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
31-
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net6.0 --no-restore --no-build
47+
dotnet test tests/NHapi.Base.NUnit/NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
48+
dotnet test tests/NHapi.NUnit.SourceGeneration/NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
49+
dotnet test tests/NHapi.NUnit/NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
3250
3351
- name: Convert trx to junit
34-
if: ${{ success() || failure() }}
52+
if: (success() || failure()) && matrix.os == 'windows-latest'
3553
run: |
3654
dotnet tool install -g trx2junit
3755
trx2junit TestResults/*.trx
3856
3957
- name: Upload Unit Test Results
40-
if: always()
58+
if: always() && matrix.os == 'windows-latest'
4159
uses: actions/upload-artifact@v2
4260
with:
4361
name: unit-test-results
4462
path: TestResults\TestResults*.xml
4563

46-
build-and-test-linux:
47-
name: Build And Test Linux
48-
runs-on: ubuntu-latest
49-
50-
steps:
51-
- uses: actions/checkout@v2
52-
53-
- name: Setup .NET Core
54-
uses: actions/setup-dotnet@v1
55-
with:
56-
dotnet-version: 6.0.101
57-
58-
- name: Restore nHapi
59-
run: |
60-
dotnet restore nHapi.sln --configfile build/.nuget/NuGet.config
61-
62-
- name: Build nHapi
63-
run: |
64-
dotnet build nHapi.sln -c Release --no-restore
65-
66-
- name: Run tests for all target frameworks
67-
run: |
68-
dotnet test tests/NHapi.Base.NUnit/NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
69-
dotnet test tests/NHapi.NUnit.SourceGeneration/NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
70-
dotnet test tests/NHapi.NUnit/NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net6.0 --no-restore --no-build
71-
7264
- name: Upload Code Coverage Report
73-
if: always()
65+
if: always() && matrix.os == 'ubuntu-latest'
7466
uses: actions/upload-artifact@v2
7567
with:
7668
name: coverage-reports

0 commit comments

Comments
 (0)