Bump NUnit from 4.3.1 to 4.3.2 in the pkg-updates group (#238) #572
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
name: "Run tests" | |
env: | |
# Only merge code coverage results if 1 | |
USE_MERGE: 0 | |
on: | |
push: | |
paths: | |
- "**/*.cs" | |
- "**/*.csproj" | |
- "**/*.props" | |
- ".github/workflows/test.yml" | |
pull_request: | |
paths: | |
- "**/*.cs" | |
- "**/*.csproj" | |
- "**/*.props" | |
- ".github/workflows/test.yml" | |
permissions: | |
contents: read | |
pull-requests: write | |
# https://www.meziantou.net/how-to-cancel-github-workflows-when-pushing-new-commits-on-a-branch.htm | |
concurrency: | |
# github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: test-${{matrix.os}} | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
env: | |
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
DOTNET_NOLOGO: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
steps: | |
- name: 'Checkout Repository' | |
uses: actions/checkout@v4.2.2 | |
# https://github.com/adamralph/minver?tab=readme-ov-file#why-is-the-default-version-sometimes-used-in-github-actions-azure-pipelines-and-travis-ci-when-a-version-tag-exists-in-the-history | |
with: | |
fetch-depth: 0 | |
filter: tree:0 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4.1.0 | |
with: | |
global-json-file: global.json | |
cache: true | |
cache-dependency-path: "**/packages.lock.json" | |
- name: Install dotnet-coverage tool | |
run: dotnet tool install -g dotnet-coverage | |
- name: Install dependencies | |
run: | | |
if [[" ${{github.event.pull_request.user.login }} " == 'app/dependabot']] || [[ "${{ github.actor }}" == 'app/dependabot' ]]; then | |
dotnet restore --force-evaluate | |
else | |
dotnet restore --locked-mode | |
fi | |
- name: Build | |
run: dotnet build --configuration Release --no-restore --tl | |
- name: Test | |
run: dotnet test --configuration Release -s cicd.runsettings --no-build --verbosity quiet --logger "GitHubActions;summary.includeNotFoundTests=false" | |
- name: ReportGenerator | |
uses: danielpalme/ReportGenerator-GitHub-Action@5.4.1 | |
with: | |
reports: '**/TestResults/**/coverage.cobertura.xml' | |
targetdir: '${{ github.workspace }}/coveragereport' | |
reporttypes: 'MarkdownSummaryGithub;MarkdownAssembliesSummary' | |
classfilters: '-System.*;-Microsoft.*;-Newtonsoft.*;-System.Text.RegularExpressions.*;-xunit.*;-NUnit.*' | |
- name: Upload code coverage results to codecov | |
uses: codecov/codecov-action@v5.1.1 | |
with: | |
flags: unittests | |
verbose: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
- name: Check if PR for current commit | |
uses: 8BitJonny/gh-get-current-pr@3.0.0 | |
with: | |
# This will work no matter the trigger event and no matter if it is the first PR commit or not. | |
sha: ${{ github.event.pull_request.head.sha }} | |
# By default it returns PRs in any state. | |
filterOutClosed: true | |
# By default it returns PRs in any state. | |
filterOutDraft: true | |
id: pr-check | |
# https://github.com/danielpalme/ReportGenerator/issues/431 | |
- name: Publish PR coverage summary | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: steps.pr-check.outputs.pr_found == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
hide: true # Hide previous comment | |
hide_classify: "OUTDATED" | |
skip_unchanged: true | |
number: ${{ steps.pr-check.outputs.number }} | |
path: coveragereport/Summary.md | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
header: "Code coverage" | |
- name: Publish coverage in build summary | |
run: cat $GITHUB_WORKSPACE/coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY | |
shell: bash | |
- name: Merge code coverage results | |
if: env.USE_MERGE == 1 | |
run: dotnet-coverage merge **/*/*.cobertura.xml -f cobertura -o ./cobertura.xml | |
shell: bash | |
# In v4, Artifacts are immutable (unless deleted). So you must change | |
# each of the uploaded Artifacts to have a different name and filter the | |
# downloads by name to achieve the same effect | |
- name: Archive results | |
# https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code-coverage-report-${{ matrix.os }} | |
path: | | |
**/TestResults/**/coverage.cobertura.xml | |
coveragereport/*.md |