Skip to content

docs: simplify-console-file-app-sample #2940

docs: simplify-console-file-app-sample

docs: simplify-console-file-app-sample #2940

Workflow file for this run

name: Code Coverage
on:
push:
branches: [main]
paths-ignore:
- "**.md"
pull_request:
branches: [main]
paths-ignore:
- "**.md"
jobs:
build-test-report:
permissions:
contents: read
pull-requests: write
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5
with:
global-json-file: global.json
- name: Cache NuGet packages
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', 'Directory.Packages.props', 'global.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Run Test
run: dotnet test --coverlet --coverlet-output-format opencover --coverlet-exclude "[GitHubActionsTestLogger*]*" --ignore-exit-code 8
# Keep globbing on non-Windows runners (works today)
- name: Upload coverage to Codecov (non-Windows)
if: runner.os != 'Windows'
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
with:
name: Code Coverage for ${{ matrix.os }}
files: "**/TestResults/**/coverage.opencover.*.xml"
disable_search: true
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
# On Windows, avoid passing a glob that expands into multiple args
- name: Find coverage reports (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$files = Get-ChildItem -Path "$PWD" -Recurse -Filter "coverage.opencover.*.xml" | ForEach-Object { $_.FullName }
if (-not $files -or $files.Count -eq 0) {
throw "No coverage.opencover.*.xml files were found under the repository."
}
# Codecov accepts comma-separated file paths
$csv = ($files -join ",")
"CODECOV_FILES=$csv" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Upload coverage to Codecov (Windows)
if: runner.os == 'Windows'
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
with:
name: Code Coverage for ${{ matrix.os }}
files: ${{ env.CODECOV_FILES }}
disable_search: true
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}