Bump dotnet-sdk from 9.0.102 to 9.0.200 #613
Workflow file for this run
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: | |
pull_request: | |
permissions: | |
contents: write | |
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/[email protected] | |
# 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: "Check for changed files" | |
uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: .github/filter.yml | |
- name: Set environment variable | |
id: set-env | |
run: | | |
if [ "${{ steps.filter.outputs.code }}" == "true" ] || [ "${{ steps.filter.outputs.test }}" == "true" ]; then | |
echo "ENABLED=1" >> $GITHUB_ENV | |
else | |
echo "ENABLED=0" >> $GITHUB_ENV | |
fi | |
- name: Setup .NET Core | |
uses: actions/[email protected] | |
if: env.ENABLED == '1' | |
with: | |
global-json-file: global.json | |
cache: true | |
cache-dependency-path: "**/packages.lock.json" | |
- name: Install dotnet-coverage tool | |
if: env.ENABLED == '1' | |
run: dotnet tool install -g dotnet-coverage | |
- name: Check if PR for current commit | |
if: env.ENABLED == '1' | |
uses: 8BitJonny/[email protected] | |
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 | |
- name: Install dependencies | |
if: env.ENABLED == '1' && steps.pr-check.outputs.pr_found == 'true' | |
run: | | |
dotnet restore --force-evaluate && git add . | |
- id: commit | |
if: env.ENABLED == '1' && steps.pr-check.outputs.pr_found == 'true' | |
uses: qoomon/actions--create-commit@v1 | |
with: | |
message: "Committing changes to lock files [skip ci]" | |
allow-empty: false | |
skip-empty: true | |
- if: env.ENABLED == '1' && steps.pr-check.outputs.pr_found == 'true' && steps.commit.outputs.commit != null | |
run: git push origin HEAD:${{ github.head_ref || github.ref_name }} | |
- name: Install dependencies | |
if: env.ENABLED == '1' && steps.pr-check.outputs.pr_found == 'false' | |
run: | | |
dotnet restore --locked-mode | |
- name: Build | |
if: env.ENABLED == '1' | |
run: dotnet build --configuration Release --no-restore --tl | |
- name: Test | |
if: env.ENABLED == '1' | |
run: dotnet test --configuration Release -s cicd.runsettings --no-build --verbosity quiet --logger "GitHubActions;summary.includeNotFoundTests=false" | |
- name: ReportGenerator | |
if: env.ENABLED == '1' | |
uses: danielpalme/[email protected] | |
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 | |
if: env.ENABLED == '1' | |
uses: codecov/[email protected] | |
with: | |
flags: unittests | |
verbose: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
# 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 | |
if: env.ENABLED == '1' | |
run: cat $GITHUB_WORKSPACE/coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY | |
shell: bash | |
- name: Merge code coverage results | |
if: env.USE_MERGE == 1 && env.ENABLED == '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 | |
if: env.ENABLED == '1' | |
with: | |
name: code-coverage-report-${{ matrix.os }} | |
path: | | |
**/TestResults/**/coverage.cobertura.xml | |
coveragereport/*.md |