Skip to content

initial commit #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f68b34f
initial commit
cctan777 Aug 14, 2023
d77ae75
set correct location 4 RES.Configuration.Test.dll
cctan777 Aug 14, 2023
b410b66
remove extraneous " in run opencover
cctan777 Aug 14, 2023
5289fe7
use -target:"nunit3-console.exe" in run opencover
cctan777 Aug 14, 2023
7655f6c
install nunit-console.exe
cctan777 Aug 14, 2023
dcf6740
check install of nunit-console
cctan777 Aug 14, 2023
686aca4
add path to nunit3-console.exe
cctan777 Aug 14, 2023
c0c7fad
find where is nunit3-console.exe located
cctan777 Aug 14, 2023
b0abd4a
try again, find location of nunit3-console.exe
cctan777 Aug 14, 2023
909a435
run tests
cctan777 Aug 14, 2023
78d6a28
give full path for RES.Configuration.Test.dll
cctan777 Aug 14, 2023
e91e023
find TestResult.xml
cctan777 Aug 14, 2023
3ef2ea1
inspect the test and coverage results
cctan777 Aug 14, 2023
c1f7ede
add build nuget package
cctan777 Aug 14, 2023
c85ace0
fix path to artifacts
cctan777 Aug 14, 2023
2d0b8ef
add debugtype=true to enable coverage
cctan777 Aug 15, 2023
49e11a3
add --shadowcopy to the nunit3 args
cctan777 Aug 15, 2023
d910a41
use -filter in OpenCover
cctan777 Aug 15, 2023
274764f
ues -filter [RES.Configuration.Text]
cctan777 Aug 15, 2023
3f397d5
don't use -filter
cctan777 Aug 15, 2023
0b32de6
remove extraneous \ before OpenCover
cctan777 Aug 15, 2023
0921f91
convert coverage results to markdown
cctan777 Aug 15, 2023
505a308
get Summary.md
cctan777 Aug 15, 2023
2f4ab93
put -filter back in
cctan777 Aug 15, 2023
d4d10ce
generate test and coverage results and badges
cctan777 Aug 16, 2023
cb7d553
fix filenames
cctan777 Aug 16, 2023
3252d2f
use REPO_NAME
cctan777 Aug 16, 2023
c92c0a7
run badge-maker in powershell not bash
cctan777 Aug 16, 2023
afddf5f
fix typo in README.md
cctan777 Aug 16, 2023
f5d5e37
Bolden the coverage report title in job summary
cctan777 Aug 16, 2023
d45e167
Make code coverage report title bold
cctan777 Aug 16, 2023
1fb9009
fix #
cctan777 Aug 16, 2023
1091180
try again
cctan777 Aug 16, 2023
6992355
final commit
cctan777 Aug 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 204 additions & 0 deletions .github/workflows/build-and-test-RES.Configuration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
name: Build And Test RES.Configuration

on:
push:
branches:
- "master"
paths-ignore:
- '**.md'
pull_request:
workflow_dispatch:

env:
APP_NAME: RES.Configuration
REPO_NAME: configuration

jobs:
Build_And_Test:
name: Build And Test
runs-on: windows-2019

steps:
- name: Checkout PR merged with Master
uses: actions/checkout@v3
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
with:
ref: refs/pull/${{ github.event.number }}/merge

- name: Checkout Master
uses: actions/checkout@v3
if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target'

- name: Setup Node.js
uses: actions/setup-node@v3 # Needed for making badges
with:
node-version: '20.x'

- name: Install Dependencies # Needed for making badges
run: |
npm install badge-maker

- name: Use .NET Core SDK 5.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: 5.0.x

- name: Install OpenCover
run: choco install opencover.portable

- name: Install nunit-console
run: |
msiexec /i D:\a\configuration\configuration\NUnit.Console-3.15.4.msi /qn /norestart

- name: Restore RES.Configuration
run: dotnet restore RES.Configuration.sln

- name: Build RES.Configuration
run: dotnet build RES.Configuration.sln --configuration Release --no-restore

- name: Run OpenCover
shell: cmd
run: |
C:\ProgramData\chocolatey\lib\opencover.portable\tools\OpenCover.Console.exe -register:Path64 -target:"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" -targetargs:"${{ github.workspace }}\BuiltDlls\Release\RES.Configuration.Test.dll" -output:"coverage.xml" -returntargetcode -filter:"+[RES.Configuration.Test]*" -oldStyle -register:user
# C:\ProgramData\chocolatey\lib\opencover.portable\tools\\OpenCover.Console.exe -register:Path64 -target:"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" -targetargs:"${{ github.workspace }}\BuiltDlls\Release\RES.Configuration.Test.dll" -output:"coverage.xml" -returntargetcode -filter:"+[RES.Configuration]* -[RES.Configuration.Test]*" -oldStyle -register:user

- name: Create Test Result Summary in Markdown Format
id: get_test_results
shell: pwsh
run: |
$XMLPath = 'TestResult.xml'
$xml = [xml](Get-Content $XMLPath)
$test_run = $xml.SelectNodes('//test-run')
$total_tests = $test_run.total
$passed = $test_run.passed
$failed = $test_run.failed
$warnings = $test_run.warnings
$inconclusive = $test_run.inconclusive
$skipped = $test_run.skipped
$duration = $test_run.duration
$duration = [Math]::Round($duration, 2, [MidpointRounding]::ToEven)

echo "passed=$passed" >> $env:GITHUB_OUTPUT
echo "total_tests=$total_tests" >> $env:GITHUB_OUTPUT

'# Test Report<br>' | Out-File '${{ env.APP_NAME }}-test-results.md'
'## Summary<br>'| Out-File '${{ env.APP_NAME }}-test-results.md' -Append
$total_tests + ' tests ran in ' + $duration + ' seconds.<br>' | Out-File '${{ env.APP_NAME }}-test-results.md' -Append
'- ' + $passed + ' tests passed<br>' | Out-File '${{ env.APP_NAME }}-test-results.md' -Append
'- ' + $failed + ' tests failed<br>' | Out-File '${{ env.APP_NAME }}-test-results.md' -Append
'- ' + $skipped + ' tests skipped<br>' | Out-File '${{ env.APP_NAME }}-test-results.md' -Append

- name: Use ReportGenerator to Convert Code Coverage Results to Markdown Format
uses: danielpalme/[email protected]
with:
reports: coverage.xml
targetdir: ${{ github.workspace }}
reporttypes: MarkdownSummary

- name: Write Test and Coverage Results to Job Summary
shell: bash
run: |
mv Summary.md ${{ env.APP_NAME }}-coverage-results.md
cat ${{ env.APP_NAME }}-test-results.md >> $GITHUB_STEP_SUMMARY
cat ${{ env.APP_NAME }}-coverage-results.md >> $GITHUB_STEP_SUMMARY

- name: Extract code coverage %
id: get_coverage
shell: bash
run: |
coverage=`grep -o '**Line coverage:**[^"]*' ${{ env.APP_NAME }}-coverage-results.md`
echo $coverage
numbers=$(echo $coverage | tr -cd '[. [:digit:]]')
percent=$(echo $numbers | cut -f1 -d' ')
echo "percent=$percent" >> $GITHUB_OUTPUT

- name: Make Test Results and Code Coverage Badges
shell: pwsh
run: |
npm install -g badge-maker
badge "tests" ${{ steps.get_test_results.outputs.passed }}/${{ steps.get_test_results.outputs.total_tests }} "#4c1" "#555" > ${{ env.APP_NAME }}-test-badge.svg
if (${{ steps.get_coverage.outputs.percent }} -ge 80) {
$color="#4c1"
}elseif(${{ steps.get_coverage.outputs.percent }} -ge 50) {
$color="#dfb317"
}elseif(${{ steps.get_coverage.outputs.percent }} -ge 20) {
$color="#fe7d37"
}else{
$color="#f00"
}
badge "code coverage" "${{steps.get_coverage.outputs.percent}}%" "$color" "#555" > ${{ env.APP_NAME }}-coverage-badge.svg

- name: Upload Test and Coverage Reports and Badges to Artifacts
uses: actions/upload-artifact@v3
with:
name: reports-and-badges
path: |
${{ env.APP_NAME }}-test-results.md
${{ env.APP_NAME }}-coverage-results.md
${{ env.APP_NAME }}-test-badge.svg
${{ env.APP_NAME }}-coverage-badge.svg

- name: Create nuget package
run: |
dotnet pack RES.Configuration/RES.Configuration.csproj --configuration Release --no-restore --no-build --output ${{ github.workspace }}/artifacts

- name: Upload nuget package to Artifacts
uses: actions/upload-artifact@v3
with:
name: RES.Configuration
path: |
artifacts/*.nupkg

Upload_Reports_And_Badges_To_Repo_Wiki:
name: Upload Test and Code Coverage Reports and Badges to Repo Wiki
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
needs: [ Build_And_Test ]

steps:

- name: Checkout Repo Wiki
uses: actions/checkout@v3
with:
repository: resgroup/${{ env.REPO_NAME }}.wiki

- name: Check If There is Existing Test Report
id: check_files
uses: andstor/file-existence-action@v2
with:
files: |
${{ env.APP_NAME }}-test-results.md
${{ env.APP_NAME }}-test-badge.svg
${{ env.APP_NAME }}-coverage-results.md
${{ env.APP_NAME }}-coverage-badge.svg

- name: If There are Existing Test Results and Badges, Delete Them and Sync Back With Wiki
if: steps.check_files.outputs.files_exists == 'true'
run: |
rm -f ${{ env.APP_NAME }}-test-results.md, ${{ env.APP_NAME }}-test-badge.svg, ${{ env.APP_NAME }}-coverage-results.md, ${{ env.APP_NAME }}-coverage-badge.svg
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Add changes"
git push

- name: Download New Test and Coverage Reports and Badges From Artifacts
if: success() || failure()
uses: actions/download-artifact@v3
with:
path: ./
name: reports-and-badges

- name: Commit Changes (New Test and Coverage Reports and Badges) Back to Repo Wiki
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Add changes"
git push

- name: Delete "reports-and-badges" from Artifacts - no longer needed
uses: GeekyEggo/[email protected]
with:
name: |
reports-and-badges
Binary file added NUnit.Console-3.15.4.msi
Binary file not shown.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

A C# library for strongly typed Configuration with validation. Please see [Taming Configuration in C#](https://medium.com/hackernoon/taming-configuration-in-c-a2706b2d4741) for more details.

[![Build status](https://ci.appveyor.com/api/projects/status/oujy1v19iwdba8e5?svg=true)](https://ci.appveyor.com/project/RESSoftwareTeam/configuration)

[![codecov](https://codecov.io/gh/resgroup/configuration/branch/master/graph/badge.svg)](https://codecov.io/gh/resgroup/configuration)
[![](https://github.com/resgroup/configuration/actions/workflows/build-and-test-RES.Configuration.yml/badge.svg)](https://github.com/resgroup/configuration/actions/workflows/build-and-test-RES.Configuration.yml) [![](https://github.com/resgroup/configuration/wiki/RES.Configuration-test-badge.svg)](https://github.com/resgroup/configuration/wiki/RES.Configuration-test-results) [![](https://github.com/resgroup/configuration/wiki/RES.Configuration-coverage-badge.svg)](https://github.com/resgroup/configuration/wiki/RES.Configuration-coverage-results)

Example Usage (`Configuration` is the class provided by this repo)

Expand Down
1 change: 1 addition & 0 deletions RES.Configuration.Test/RES.Configuration.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ProjectGuid>40b5b4a7-ad9a-4cec-b1cf-059482dfb9ce</ProjectGuid>
</PropertyGroup>
<PropertyGroup>
<DebugType>full</DebugType>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugSymbols>True</DebugSymbols>
<WarningsAsErrors />
Expand Down