Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"Bash(git diff*)",
"Bash(git status*)",
"Bash(git show*)",
"Bash(git branch*)"
"Bash(git branch*)",
"mcp__claude_ai_Microsoft_Learn__microsoft_docs_search",
"mcp__claude_ai_Microsoft_Learn__microsoft_docs_fetch",
"mcp__claude_ai_Microsoft_Learn__microsoft_code_sample_search"
]
},
"enabledPlugins": {
Expand Down
6 changes: 2 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ updates:
prefix: "dependencies(nuget): "
labels:
- "dependencies"
open-pull-requests-limit: 5
open-pull-requests-limit: 10
allow:
- dependency-type: direct
- dependency-type: indirect
Expand All @@ -54,7 +54,6 @@ updates:
testing:
patterns:
- "AwesomeAssertions*"
- "coverlet*"
- "GitHubActionsTestLogger"
- "xunit*"
update-types: ["minor", "patch"]
Expand All @@ -67,7 +66,7 @@ updates:
prefix: "dependencies(nuget): "
labels:
- "dependencies"
open-pull-requests-limit: 5
open-pull-requests-limit: 10
allow:
- dependency-type: direct
- dependency-type: indirect
Expand All @@ -81,7 +80,6 @@ updates:
testing:
patterns:
- "AwesomeAssertions*"
- "coverlet*"
- "GitHubActionsTestLogger"
- "xunit*"
update-types: ["minor", "patch"]
29 changes: 21 additions & 8 deletions .github/workflows/_dotnet-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ on:
required: false
type: string
default: 10.0.x
codecov-slug:
description: "Slug to upload code coverage results for Codecov. e.g. saan800/saansoft-correlationId"
codecov-name:
description: "Name to upload code coverage results for Codecov. e.g. saansoft-correlationId"
required: false
type: string
codecov-flag:
Expand Down Expand Up @@ -97,20 +97,22 @@ jobs:
auth.docker.io:443
builds.dotnet.microsoft.com:443
cli.codecov.io:443
ingest.codecov.io:433
ingest.codecov.io:443
dotnetcli.azureedge.net:443
cognito-identity.us-east-1.amazonaws.com:443
crl.sectigo.com:443
crl3.digicert.com:80
crl4.digicert.com:443
dc.services.visualstudio.com:443
github.com:443
keybase.io:443
ocsp.digicert.com:443
ocsp.sectigo.com:443
pinpoint.us-east-1.amazonaws.com:443
production.cloudflare.docker.com:443
registry-1.docker.io:443
s.symcb.com:443
storage.googleapis.com:443
ts-crl.ws.symantec.com:443
ts-ocsp.ws.symantec.com:443
www.microsoft.com:443
Expand Down Expand Up @@ -173,7 +175,18 @@ jobs:
--configuration Release \
$FRAMEWORK_ARG \
--report-github \
/p:CollectCoverage=true
--coverage \
--coverage-output-format cobertura \
--results-directory ./reports/coverage/

# MTP names coverage files "<test-run-guid>.cobertura.xml", which Codecov's
# file auto-discovery does not recognize (it only matches exactly
# "cobertura.xml" or filenames containing "coverage"). Rename in place so
# the upload step's `directory:` search actually finds them.
for f in ./reports/coverage/*.cobertura.xml; do
[ -e "$f" ] || continue
mv "$f" "$(dirname "$f")/coverage.$(basename "$f")"
done
;;
*)
dotnet test \
Expand All @@ -187,10 +200,10 @@ jobs:

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
if: inputs.codecov-slug != ''
if: inputs.codecov-name != ''
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./reports/coverage/
fail_ci_if_error: false
directory: ${{ inputs.working-directory }}/reports/coverage/
flags: ${{ inputs.codecov-flag }}, ${{ matrix.dotnet-version }}, ${{ inputs.os }}
slug: ${{ inputs.codecov-slug }}
name: ${{ inputs.codecov-name }}
8 changes: 4 additions & 4 deletions .github/workflows/_dotnet-build-test-pack-publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ on:
type: number
required: false
default: 50
codecov-slug:
description: "Slug to upload code coverage results for Codecov. e.g. saan800/saansoft-correlationId"
codecov-name:
description: "Name to upload code coverage results for Codecov. e.g. saansoft-correlationId"
required: false
type: string
codecov-flag:
Expand All @@ -55,7 +55,7 @@ on:
description: "API key for nuget.org. Required if upload-to-nuget is true"
required: false
CODECOV_TOKEN:
description: "Token for CodeCov. Required if codecov-slug is set"
description: "Token for CodeCov. Required if codecov-name is set"
required: false

permissions:
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
os: ${{ inputs.os }}
dotnet-version-matrix: ${{ inputs.dotnet-version-matrix }}
dotnet-version: ${{ inputs.dotnet-version }}
codecov-slug: ${{ inputs.codecov-slug }}
codecov-name: ${{ inputs.codecov-name }}
codecov-flag: ${{ inputs.codecov-flag }}
secrets: inherit

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dotnet-package-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ on:
type: number
required: false
default: 50
codecov-slug:
description: "Slug to upload code coverage results for Codecov. e.g. saan800/saansoft-correlationId"
codecov-name:
description: "Name to upload code coverage results for Codecov. e.g. saansoft-correlationId"
required: false
type: string
codecov-flag:
Expand All @@ -54,7 +54,7 @@ on:
description: "API key for nuget.org. Required if upload-to-nuget is true"
required: false
CODECOV_TOKEN:
description: "Token for CodeCov. Required if codecov-slug is set"
description: "Token for CodeCov. Required if codecov-name is set"
required: false

permissions:
Expand All @@ -76,7 +76,7 @@ jobs:
dotnet-version-matrix: ${{ inputs.dotnet-version-matrix }}
dotnet-version: ${{ inputs.dotnet-version }}
num-github-prerelease-packages-to-keep: ${{ inputs.num-github-prerelease-packages-to-keep }}
codecov-slug: ${{ inputs.codecov-slug }}
codecov-name: ${{ inputs.codecov-name }}
codecov-flag: ${{ inputs.codecov-flag }}
is-release-branch: false
force-release: false
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dotnet-package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ on:
type: number
required: false
default: 50
codecov-slug:
description: "Slug to upload code coverage results for Codecov. e.g. saan800/saansoft-correlationId"
codecov-name:
description: "Name to upload code coverage results for Codecov. e.g. saansoft-correlationId"
required: false
type: string
codecov-flag:
Expand All @@ -55,7 +55,7 @@ on:
description: "API key for nuget.org. Required if upload-to-nuget is true"
required: false
CODECOV_TOKEN:
description: "Token for CodeCov. Required if codecov-slug is set"
description: "Token for CodeCov. Required if codecov-name is set"
required: false

permissions:
Expand All @@ -77,7 +77,7 @@ jobs:
dotnet-version-matrix: ${{ inputs.dotnet-version-matrix }}
dotnet-version: ${{ inputs.dotnet-version }}
num-github-prerelease-packages-to-keep: ${{ inputs.num-github-prerelease-packages-to-keep }}
codecov-slug: ${{ inputs.codecov-slug }}
codecov-name: ${{ inputs.codecov-name }}
codecov-flag: ${{ inputs.codecov-flag }}
is-release-branch: ${{ inputs.is-release-branch }}
force-release: ${{ inputs.force-release }}
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/dotnet-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ on:
type: number
required: false
default: 50
codecov-slug:
description: "Slug to upload code coverage results for Codecov. e.g. saan800/saansoft-correlationId"
codecov-name:
description: "Name to upload code coverage results for Codecov. e.g. saansoft-correlationId"
required: false
type: string
codecov-flag:
Expand All @@ -54,7 +54,7 @@ on:
description: "API key for nuget.org. Required if upload-to-nuget is true"
required: false
CODECOV_TOKEN:
description: "Token for CodeCov. Required if codecov-slug is set"
description: "Token for CodeCov. Required if codecov-name is set"
required: false

permissions:
Expand All @@ -72,8 +72,9 @@ jobs:
os: ${{ inputs.os }}
dotnet-version-matrix: ${{ inputs.dotnet-version-matrix }}
dotnet-version: ${{ inputs.dotnet-version }}
codecov-slug: ${{ inputs.codecov-slug }}
codecov-name: ${{ inputs.codecov-name }}
codecov-flag: ${{ inputs.codecov-flag }}
secrets: inherit

pr-labels:
permissions:
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/example-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ name: example-pr

on:
pull_request:
workflow_dispatch: # 👈 manual trigger here to release - should only be on "release" workflows, not "pr" workflows
inputs:
force-release:
description: "Force a release regardless of PR labels or branch"
type: boolean
required: false
default: false

permissions:
actions: read
Expand All @@ -30,8 +23,7 @@ jobs:
working-directory: "./examples/NugetPackages"
os: ubuntu-latest
dotnet-version: 10.0.x
# is-release-branch: ${{ github.ref == 'refs/heads/main' }} for "release" workflows only
# force-release: ${{ github.event.inputs.force-release || false }} for "release" workflows only
codecov-name: "example-dotnet-package"
secrets: inherit

dotnet-minimal-web-api-pr:
Expand All @@ -45,4 +37,5 @@ jobs:
working-directory: "./examples/MinimalWebApi"
os: "ubuntu-latest"
dotnet-version: "10.0.x"
codecov-name: "example-minimal-web-api"
secrets: inherit
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# github

[![codecov](https://codecov.io/gh/saan800/github/graph/badge.svg?token=WWF9NNOGJ0)](https://codecov.io/gh/saan800/github)


Reusable GitHub Actions workflow templates for .NET projects, with reference example implementations.

## Reusable Workflow Templates
Expand All @@ -18,7 +21,7 @@ Restores, builds, and runs tests with optional framework matrix and Codecov uplo
| `dotnet-version` | | `10.0.x` | SDK version (single build) |
| `dotnet-version-matrix` | | | JSON array of `{dotnet-version, framework}` pairs for matrix builds |
| `os` | | `ubuntu-latest` | Runner OS |
| `codecov-slug` | | | Repo slug for Codecov upload (skipped if empty) |
| `codecov-name` | | | Repo name for Codecov upload (skipped if empty) |
| `codecov-flag` | | `unittests` | Codecov flag |

| Secret | Required | Description |
Expand Down Expand Up @@ -116,7 +119,7 @@ get-version ─┬─ check-release-eligibility
| `dotnet-version` | | `10.0.x` | SDK version for pack/publish jobs |
| `dotnet-version-matrix` | | | JSON matrix for the build-and-test job |
| `os` | | `ubuntu-latest` | Runner OS |
| `codecov-slug` | | | Codecov repo slug |
| `codecov-name` | | | Codecov repo name |
| `codecov-flag` | | `unittests` | Codecov flag |
| `num-github-prerelease-packages-to-keep` | | `50` | GPR cleanup retention count |

Expand Down
5 changes: 0 additions & 5 deletions examples/MinimalWebApi/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

<PropertyGroup Condition=" '$(IsTestProject)' == 'true'">
<NoWarn>CS1591;CS8602;CS8625;CS8618</NoWarn>
<CollectCoverage>true</CollectCoverage>
<CoverletOutput>$([System.IO.Path]::Combine($(MSBuildProjectDirectory), "../../", 'reports', 'coverage'))/</CoverletOutput>
<CoverletOutputFormat>opencover,json</CoverletOutputFormat>
<MergeWith>$(CoverletOutput)/coverage.json</MergeWith>
<Exclude>[*.Tests.*]*,[xunit.*]*</Exclude>
</PropertyGroup>

<ItemGroup Condition=" '$(IsTestProject)' == 'true'">
Expand Down
17 changes: 5 additions & 12 deletions examples/MinimalWebApi/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
<Project>
<ItemGroup>
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
<PackageVersion Include="coverlet.collector" Version="8.0.1" />
<PackageVersion Include="coverlet.msbuild" Version="8.0.1" />
<PackageVersion Include="GitHubActionsTestLogger" Version="3.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.9" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.9" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.7.0" />
<PackageVersion Include="Microsoft.OpenApi" Version="2.7.5" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.7.0" />
<PackageVersion Include="Microsoft.Testing.Platform" Version="2.2.3" />
<PackageVersion Include="Scalar.AspNetCore" Version="2.16.9" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
</ItemGroup>
<ItemGroup Condition=" '$(IsTestProject)' == 'true'">
<PackageReference Include="AwesomeAssertions" />
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="GitHubActionsTestLogger" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="Microsoft.Testing.Platform" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.v3.mtp-v2" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MinimalWebApi.Api\MinimalWebApi.Api.csproj" />
</ItemGroup>
Expand Down
Loading
Loading