Skip to content

Commit dfabe4e

Browse files
committed
include climate code coverage in github actions
1 parent ff7a44a commit dfabe4e

4 files changed

Lines changed: 139 additions & 33 deletions

File tree

.github/workflows/build-status.yml

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- master
66

77
jobs:
8-
build-and-test:
8+
build-and-test-windows:
99
name: Build And Test
1010
runs-on: windows-2019
1111

@@ -15,34 +15,89 @@ jobs:
1515
- name: Setup .NET Core
1616
uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: 3.1.301
18+
dotnet-version: 3.1.405
19+
1920
- name: Restore nHapi
2021
run: |
2122
dotnet restore nHapi.sln --configfile build\.nuget\NuGet.config
2223
dotnet restore Hl7Models.sln --configfile build\.nuget\NuGet.config
24+
2325
- name: Build nHapi
2426
run: |
2527
dotnet build nHapi.sln -c Release --no-restore
2628
dotnet build Hl7Models.sln -c Release --no-restore
29+
2730
- name: Run tests for all target frameworks
2831
run: |
29-
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net461 --no-restore --no-build
30-
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
31-
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net461 --no-restore --no-build
32-
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
33-
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f net461 --no-restore --no-build
34-
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
32+
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj -r TestResults -c Release -f net461 --no-restore --no-build
33+
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
34+
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj -r TestResults -c Release -f net461 --no-restore --no-build
35+
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
36+
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj -r TestResults -c Release -f net461 --no-restore --no-build
37+
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
38+
39+
build-and-test-linux:
40+
name: Build And Test Linux
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- uses: actions/checkout@v2
45+
46+
- name: Setup .NET Core
47+
uses: actions/setup-dotnet@v1
48+
with:
49+
dotnet-version: 3.1.405
50+
51+
- name: Restore nHapi
52+
run: |
53+
dotnet restore nHapi.sln --configfile build/.nuget/NuGet.config
54+
dotnet restore Hl7Models.sln --configfile build/.nuget/NuGet.config
55+
56+
- name: Build nHapi
57+
run: |
58+
dotnet build nHapi.sln -c Release --no-restore
59+
dotnet build Hl7Models.sln -c Release --no-restore
60+
61+
- name: Run tests for all target frameworks
62+
run: |
63+
dotnet test tests/NHapi.Base.NUnit/NHapi.Base.NUnit.csproj -r TestResults -c Release -f net461 --no-restore --no-build
64+
dotnet test tests/NHapi.Base.NUnit/NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
65+
dotnet test tests/NHapi.NUnit.SourceGeneration/NHapi.NUnit.SourceGeneration.csproj -r TestResults -c Release -f net461 --no-restore --no-build
66+
dotnet test tests/NHapi.NUnit.SourceGeneration/NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
67+
dotnet test tests/NHapi.NUnit/NHapi.NUnit.csproj -r TestResults -c Release -f net461 --no-restore --no-build
68+
dotnet test tests/NHapi.NUnit/NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
69+
3570
- name: Merge Coverage Reports
71+
if: ${{ success() || failure() }}
3672
run: |
3773
dotnet tool install -g dotnet-reportgenerator-globaltool
3874
reportgenerator "-reports:TestResults/**/coverage.cobertura.xml" "-targetdir:coverage" "-reporttypes:Cobertura"
3975
40-
- name: Publish Code Coverage Results
41-
uses: codecov/codecov-action@v1
76+
- name: Upload Code Coverage Report
77+
if: always()
78+
uses: actions/upload-artifact@v2
4279
with:
43-
files: coverage/Cobertura.xml
80+
name: coverage-reports
81+
path: |
82+
coverage/Cobertura.xml
4483
45-
- name: Test bash Coverage Uploader
46-
run: |
47-
Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
48-
bash codecov.sh -f '"coverage/Cobertura.xml"'
84+
publish-coverage-results:
85+
needs: build-and-test-linux
86+
name: Publish Code Coverage Results
87+
runs-on: ubuntu-latest
88+
# the build-and-test job might be skipped, we don't need to run this job then
89+
if: always()
90+
steps:
91+
- uses: actions/checkout@v2
92+
93+
- name: 'Download artifact'
94+
uses: actions/download-artifact@v2
95+
with:
96+
name: coverage-reports
97+
98+
- name: Publish Code Coverage Results
99+
uses: paambaati/codeclimate-action@v2.7.5
100+
env:
101+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
102+
with:
103+
coverageLocations: Cobertura.xml:cobertura

.github/workflows/publish-pr-coverage-results.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ jobs:
1616
( github.event.workflow_run.conclusion == 'success' ||
1717
github.event.workflow_run.conclusion == 'failure' ) }}
1818
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
ref: ${{ github.event.workflow_run.head_sha }}
22+
1923
- name: 'Download artifact'
2024
uses: actions/github-script@v3.1.0
2125
with:
@@ -39,8 +43,18 @@ jobs:
3943
- run: |
4044
unzip coverage-reports.zip
4145
rm coverage-reports.zip
42-
43-
- run: echo ${{ github.event.workflow_run }}
46+
47+
- name: Dump workflow_run context
48+
env:
49+
WORKFLOW_CONTEXT: ${{ toJSON(github.event.workflow_run) }}
50+
run: echo $WORKFLOW_CONTEXT
51+
52+
- name: Publish Code Coverage Results
53+
uses: paambaati/codeclimate-action@v2.7.5
54+
env:
55+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
56+
with:
57+
coverageLocations: Cobertura.xml:cobertura
4458

4559
- name: Publish Code Coverage Results
4660
uses: codecov/codecov-action@v1
@@ -51,4 +65,6 @@ jobs:
5165
- name: Publish Code Coverage Results
5266
uses: 5monkeys/cobertura-action@master
5367
with:
54-
path: "**/Cobertura.xml"
68+
path: "**/Cobertura.xml"
69+
repo_token: ${{ secrets.GITHUB_TOKEN }}
70+
pull_request_number: ${{ fromJSON(github.event.workflow_run.pull_requests[0].number) }}

.github/workflows/receive-pr.yml

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Receive Pull Request
33
on: [pull_request]
44

55
jobs:
6-
build-and-test:
6+
build-and-test-windows:
77
name: Build And Test
88
runs-on: windows-2019
99

@@ -13,45 +13,80 @@ jobs:
1313
- name: Setup .NET Core
1414
uses: actions/setup-dotnet@v1
1515
with:
16-
dotnet-version: 3.1.301
16+
dotnet-version: 3.1.405
1717
- name: Restore nHapi
1818
run: |
1919
dotnet restore nHapi.sln --configfile build\.nuget\NuGet.config
2020
dotnet restore Hl7Models.sln --configfile build\.nuget\NuGet.config
21+
2122
- name: Build nHapi
2223
run: |
2324
dotnet build nHapi.sln -c Release --no-restore
2425
dotnet build Hl7Models.sln -c Release --no-restore
26+
2527
- name: Run tests for all target frameworks
2628
run: |
27-
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" --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 --collect:"XPlat Code Coverage" --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
29-
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
30-
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
31-
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --collect:"XPlat Code Coverage" --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
32-
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --collect:"XPlat Code Coverage" --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
29+
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
30+
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
31+
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
32+
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
33+
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f net461 --no-restore --no-build
34+
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --logger "trx;LogFilePrefix=TestResults" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
35+
3336
- name: Convert trx to junit
37+
if: ${{ success() || failure() }}
3438
run: |
3539
dotnet tool install -g trx2junit
3640
trx2junit TestResults/*.trx
3741
38-
- name: Merge Coverage Reports
39-
run: |
40-
dotnet tool install -g dotnet-reportgenerator-globaltool
41-
reportgenerator "-reports:TestResults/**/coverage.cobertura.xml" "-targetdir:coverage" "-reporttypes:Cobertura"
42-
4342
- name: Upload Unit Test Results
4443
if: always()
4544
uses: actions/upload-artifact@v2
4645
with:
4746
name: unit-test-results
4847
path: TestResults\TestResults*.xml
4948

49+
build-and-test-linux:
50+
name: Build And Test Linux
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- uses: actions/checkout@v2
55+
56+
- name: Setup .NET Core
57+
uses: actions/setup-dotnet@v1
58+
with:
59+
dotnet-version: 3.1.405
60+
61+
- name: Restore nHapi
62+
run: |
63+
dotnet restore nHapi.sln --configfile build/.nuget/NuGet.config
64+
dotnet restore Hl7Models.sln --configfile build/.nuget/NuGet.config
65+
66+
- name: Build nHapi
67+
run: |
68+
dotnet build nHapi.sln -c Release --no-restore
69+
dotnet build Hl7Models.sln -c Release --no-restore
70+
71+
- name: Run tests for all target frameworks
72+
run: |
73+
dotnet test tests/NHapi.Base.NUnit/NHapi.Base.NUnit.csproj -r TestResults -c Release -f net461 --no-restore --no-build
74+
dotnet test tests/NHapi.Base.NUnit/NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
75+
dotnet test tests/NHapi.NUnit.SourceGeneration/NHapi.NUnit.SourceGeneration.csproj -r TestResults -c Release -f net461 --no-restore --no-build
76+
dotnet test tests/NHapi.NUnit.SourceGeneration/NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
77+
dotnet test tests/NHapi.NUnit/NHapi.NUnit.csproj -r TestResults -c Release -f net461 --no-restore --no-build
78+
dotnet test tests/NHapi.NUnit/NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
79+
80+
- name: Merge Coverage Reports
81+
if: ${{ success() || failure() }}
82+
run: |
83+
dotnet tool install -g dotnet-reportgenerator-globaltool
84+
reportgenerator "-reports:TestResults/**/coverage.cobertura.xml" "-targetdir:coverage" "-reporttypes:Cobertura"
85+
5086
- name: Upload Code Coverage Report
5187
if: always()
5288
uses: actions/upload-artifact@v2
5389
with:
5490
name: coverage-reports
5591
path: |
56-
codecov.yml
57-
coverage\Cobertura.xml
92+
coverage/Cobertura.xml

0 commit comments

Comments
 (0)