Skip to content

Commit

Permalink
Merge pull request #142 from nHapiNET/GitHubActionsCoverage
Browse files Browse the repository at this point in the history
Add code coverage to the CI/CD, plus build status workflow for master
  • Loading branch information
milkshakeuk committed Feb 5, 2021
2 parents 5289b02 + fb5ede5 commit 837ae24
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 12 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build Status
on:
push:
branches:
- master

jobs:
build-and-test:
name: Build And Test
runs-on: windows-2019

steps:
- uses: actions/checkout@v2

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: Restore nHapi
run: |
dotnet restore nHapi.sln --configfile build\.nuget\NuGet.config
dotnet restore Hl7Models.sln --configfile build\.nuget\NuGet.config
- name: Build nHapi
run: |
dotnet build nHapi.sln -c Release --no-restore
dotnet build Hl7Models.sln -c Release --no-restore
- name: Run tests for all target frameworks
run: |
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
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
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
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
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
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
- name: Convert trx to junit
run: |
dotnet tool install -g trx2junit
trx2junit TestResults/*.trx
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: unit-test-results
path: TestResults\TestResults*.xml

- name: Upload Code Coverage Report
if: always()
uses: actions/upload-artifact@v2
with:
name: coverage-reports
path: TestResults\*\coverage.cobertura.xml
32 changes: 32 additions & 0 deletions .github/workflows/publish-pr-coverage-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish Code Coverage Results

on:
workflow_run:
workflows: ["Build Status", "Receive Pull Request"]
types:
- completed

jobs:
publish-test-results:
runs-on: ubuntu-latest
# the build-and-test job might be skipped, we don't need to run this job then
if: >
${{ ( github.event.workflow_run.event == 'pull_request' ||
github.event.workflow_run.event == 'push' ) &&
( github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ) }}
steps:
- uses: actions/checkout@v2

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Display structure of downloaded files
run: ls -R

- name: Publish Code Coverage Results
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
10 changes: 8 additions & 2 deletions .github/workflows/publish-pr-test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish Pull Request Test Results

on:
workflow_run:
workflows: ["Receive Pull Request"]
workflows: ["Build Status", "Receive Pull Request"]
types:
- completed

Expand All @@ -11,15 +11,21 @@ jobs:
runs-on: ubuntu-latest
# the build-and-test job might be skipped, we don't need to run this job then
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
${{ ( github.event.workflow_run.event == 'pull_request' ||
github.event.workflow_run.event == 'push' ) &&
( github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ) }}
steps:
- uses: actions/checkout@v2

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Display structure of downloaded files
run: ls -R

- name: Publish Unit Test Results
uses: EnricoMi/[email protected]
with:
Expand Down
23 changes: 15 additions & 8 deletions .github/workflows/receive-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
dotnet build Hl7Models.sln -c Release --no-restore
- name: Run tests for all target frameworks
run: |
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --logger trx -r TestResults -c Release -f net461 --no-restore --no-build
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --logger trx -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --logger trx -r TestResults -c Release -f net461 --no-restore --no-build
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --logger trx -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --logger trx -r TestResults -c Release -f net461 --no-restore --no-build
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --logger trx -r TestResults -c Release -f netcoreapp3.1 --no-restore --no-build
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
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
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
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
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
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
- name: Convert trx to junit
run: |
dotnet tool install -g trx2junit
Expand All @@ -39,5 +39,12 @@ jobs:
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results
path: TestResults/*.xml
name: unit-test-results
path: TestResults\TestResults*.xml

- name: Upload Code Coverage Report
if: always()
uses: actions/upload-artifact@v2
with:
name: coverage-reports
path: TestResults\*\coverage.cobertura.xml
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[![Build status](https://ci.appveyor.com/api/projects/status/llfc0qjtahffnpdw?svg=true)](https://ci.appveyor.com/project/DuaneEdwards/nhapi)
![Build Status](https://github.com/nHapiNET/nHapi/workflows/Build%20Status/badge.svg)
[![codecov](https://codecov.io/gh/nHapiNET/nHapi/branch/master/graph/badge.svg?token=pGlqcCryYr)](https://codecov.io/gh/nHapiNET/nHapi)

# This repository is now actively maintained as of 10/21/2020.
This repository is now actively maintained as of 10/21/2020.

# nHapi
NHapi is a .NET port of the original Java project [HAPI](https://github.com/hapifhir/hapi-hl7v2).
Expand All @@ -12,7 +14,7 @@ This project is **NOT** affiliated with the HL7 organization. This software just
**Key Benefits**

- Easy object model
- Microsoft .NET 3.5 library that conforms to HL7 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, 2.5.1, 2.6, 2.7, 2.7.1, 2.8 and 2.8.1 specifications
- Microsoft .NET 3.5 and netstandard2.0 library that conforms to HL7 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, 2.5.1, 2.6, 2.7, 2.7.1, 2.8 and 2.8.1 specifications
- Can take a pipe delimited or XML formatted HL7 2.x message and build the C# object model for use in code
- Can take the C# HL7 object model and produce pipe delimited or XML formatted HL7
- FREE! (You can't beat that price) and open source
Expand Down
5 changes: 5 additions & 0 deletions tests/NHapi.Base.NUnit/NHapi.Base.NUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />

<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions tests/NHapi.NUnit/NHapi.NUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
Expand Down

0 comments on commit 837ae24

Please sign in to comment.