-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from nHapiNET/GitHubActionsCoverage
Add code coverage to the CI/CD, plus build status workflow for master
- Loading branch information
Showing
8 changed files
with
142 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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" -c Release -f net461 --no-restore --no-build | ||
dotnet test tests\NHapi.Base.NUnit\NHapi.Base.NUnit.csproj --collect:"XPlat Code Coverage" -c Release -f netcoreapp3.1 --no-restore --no-build | ||
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -c Release -f net461 --no-restore --no-build | ||
dotnet test tests\NHapi.NUnit.SourceGeneration\NHapi.NUnit.SourceGeneration.csproj --collect:"XPlat Code Coverage" -c Release -f netcoreapp3.1 --no-restore --no-build | ||
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -c Release -f net461 --no-restore --no-build | ||
dotnet test tests\NHapi.NUnit\NHapi.NUnit.csproj --collect:"XPlat Code Coverage" -c Release -f netcoreapp3.1 --no-restore --no-build | ||
- name: Upload Code Coverage Report | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: coverage-reports | ||
path: TestResults\*\coverage.cobertura.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Publish Code Coverage Results | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Build Status", "Receive Pull Request"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
publish-test-results: | ||
name: Publish Code Coverage 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: | ||
- name: 'Download artifact' | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id }}, | ||
}); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "coverage-reports" | ||
})[0]; | ||
var download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
var fs = require('fs'); | ||
fs.writeFileSync('${{github.workspace}}/coverage-reports.zip', Buffer.from(download.data)); | ||
- run: | | ||
unzip coverage-reports.zip | ||
rm coverage-reports.zip | ||
- name: Publish Code Coverage Results | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Publish Pull Request Test Results | ||
name: Publish Test Results | ||
|
||
on: | ||
workflow_run: | ||
|
@@ -8,17 +8,35 @@ on: | |
|
||
jobs: | ||
publish-test-results: | ||
name: 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.conclusion == 'success' || | ||
github.event.workflow_run.conclusion == 'failure' ) }} | ||
steps: | ||
- name: Download Artifacts | ||
uses: actions/download-artifact@v2 | ||
- name: 'Download artifact' | ||
uses: actions/[email protected] | ||
with: | ||
path: artifacts | ||
script: | | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id }}, | ||
}); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "unit-test-results" | ||
})[0]; | ||
var download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
var fs = require('fs'); | ||
fs.writeFileSync('${{github.workspace}}/unit-test-results.zip', Buffer.from(download.data)); | ||
- run: unzip unit-test-results.zip | ||
|
||
- name: Publish Unit Test Results | ||
uses: EnricoMi/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters