From 51d042d486cef9ae0c938fc18c4b9c098bc4d4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hoffmann?= Date: Sun, 7 Jan 2024 13:43:03 +0100 Subject: [PATCH] Create coverage badges - optimize workflow --- .github/matchers/dotnet.json | 28 ++++++++++++++++++++++++++++ .github/workflows/ci-cd.yml | 26 ++++++++++++++------------ .gitignore | 1 - Directory.Build.Props | 1 + 4 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 .github/matchers/dotnet.json diff --git a/.github/matchers/dotnet.json b/.github/matchers/dotnet.json new file mode 100644 index 0000000..e80faff --- /dev/null +++ b/.github/matchers/dotnet.json @@ -0,0 +1,28 @@ +{ + "problemMatcher": [ + { + "owner": "dotnet-file", + "pattern": [ + { + "regexp": "^(.+)\\((\\d+).+\\):\\s(\\w+)\\s(.+)\\:\\s(.*)$", + "file": 1, + "line": 2, + "severity": 3, + "code": 4, + "message": 5 + } + ] + }, + { + "owner": "dotnet-run", + "pattern": [ + { + "regexp": "^.+\\s\\:\\s(\\w+)\\s(.*)\\:\\s(.*)$", + "severity": 1, + "code": 2, + "message": 3 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8ce0d8b..3791467 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -32,11 +32,24 @@ jobs: with: dotnet-version: 8.0.x + # Dotnet matcher + - name: πŸ” Enable problem matchers + run: echo "::add-matcher::.github/matchers/dotnet.json" + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.1 # Restore the application to populate the obj folder with RuntimeIdentifiers + - name: πŸ¦Έβ€β™‚οΈ Restore steriods # this is the caching step, remove if you don't think you need it + uses: actions/cache@v3 + with: + path: ~/.nuget/packages + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget + - name: Restore the application run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration env: @@ -44,19 +57,9 @@ jobs: # Execute all unit tests in the solution - name: Execute unit tests - run: | - echo "## ❔ Test results" >> $GITHUB_STEP_SUMMARY - dotnet test --configuration $env:Configuration --no-restore --logger GitHubActions '/p:CollectCoverage=true;CoverletOutputFormat=\"json,lcov,cobertura,opencover\";MergeWith=${{github.workspace}}/coverage.json;CoverletOutput=${{github.workspace}}/coverage' -- RunConfiguration.CollectSourceInformation=true + run: dotnet test --configuration $env:Configuration --no-restore --logger GitHubActions '/p:CollectCoverage=true;CoverletOutputFormat=\"json,lcov,cobertura,opencover\";MergeWith=${{github.workspace}}/coverage.json;CoverletOutput=${{github.workspace}}/coverage' -- RunConfiguration.CollectSourceInformation=true env: Configuration: ${{ matrix.configuration }} - - - name: πŸ“ Code Coverage report - run: | - dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.1.23 - reportgenerator -reports:${{github.workspace}}/coverage.cobertura.xml -targetdir:${{github.workspace}}/report -reporttypes:MarkdownSummaryGithub "-filefilters:-*.g.cs" -verbosity:Warning - sed -i 's/# Summary/## πŸ“ Code Coverage/g' ${{github.workspace}}/report/SummaryGithub.md - sed -i 's/## Coverage/### Code Coverage details/g' ${{github.workspace}}/report/SummaryGithub.md - cat ${{github.workspace}}/report/*.md >> $GITHUB_STEP_SUMMARY # Create coverage badges - name: OpenCover Badge Generator @@ -65,7 +68,6 @@ jobs: path-to-opencover-xml: ${{github.workspace}}/coverage.opencover.xml path-to-badges: ./ minimum-coverage: 75 - commit-badges: false repo-token: ${{ secrets.GITHUB_TOKEN }} # Archive the package diff --git a/.gitignore b/.gitignore index 70872be..f1e3d20 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ -CoverageResults/ # Visual Studio 2015 cache/options directory .vs/ diff --git a/Directory.Build.Props b/Directory.Build.Props index e0f8e6f..41b01f7 100644 --- a/Directory.Build.Props +++ b/Directory.Build.Props @@ -6,6 +6,7 @@ Β© $([System.DateTime]::Now.ToString('yyyy')) https://github.com/JoergHoffmannatGitHub/Family.Show $(RepositoryUrl) + true CA1416