Skip to content

Commit

Permalink
Updating the Console template
Browse files Browse the repository at this point in the history
  • Loading branch information
Keboo committed Oct 15, 2023
1 parent 5c1616c commit 42dfbe8
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 13 deletions.
17 changes: 13 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "nuget"
directory: "/templates/WPF/WpfApp"
directory: "/templates/WPF/WpfApp"
schedule:
interval: "weekly"

- package-ecosystem: "nuget"
directory: "/templates/console/ConsoleApp"
directory: "/templates/Console/ConsoleApp"
schedule:
interval: "weekly"

- package-ecosystem: "nuget"
directory: "/templates/Library/NuGet"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
directory: "/templates/Library/NuGet"
schedule:
interval: "weekly"
interval: "weekly"
13 changes: 12 additions & 1 deletion templates/Console/ConsoleApp/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indent_style = space
indent_size = 2

# MSBuild files
[*.csproj,*.targets,*.props]
[*.{csproj,targets,props}]
indent_size = 2

# Xml files
Expand Down Expand Up @@ -181,6 +181,7 @@ csharp_preserve_single_line_statements = true
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = false:suggestion

#### Naming styles ####
[*.{cs,vb}]
Expand Down Expand Up @@ -376,3 +377,13 @@ tab_width = 4
indent_size = 4
end_of_line = crlf

###############################
# Spell Check #
###############################
# https://learn.microsoft.com/visualstudio/ide/text-spell-checker
spelling_exclusion_path = .\exclusions.dic
spelling_checkable_types = strings,identifiers,comments
# Update this to match your prefered language, you will need to ensure you have the language pack installed for the language
spelling_languages = en-us
# This is only the level that spelling errors occur in the Error List, it is not actually a compile-time warning/error
spelling_error_severity = information
16 changes: 16 additions & 0 deletions templates/Console/ConsoleApp/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build and deploy

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

defaults:
run:
shell: pwsh

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'

- name: dotnet restore
run: dotnet restore

- name: dotnet build
run: dotnet build --configuration Release --no-restore

- name: dotnet test
run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" --results-directory ./code-coverage

- name: ReportGenerator
uses: danielpalme/[email protected]
with:
reports: code-coverage/**/coverage.cobertura.xml
targetdir: coveragereport
reporttypes: Html;MarkdownSummaryGithub
title: 'Code Coverage'

- name: Write PR Number
if: ${{ github.event_name == 'pull_request' }}
run: |
echo ${{ github.event.number }} > ./coveragereport/PullRequestNumber
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v3
with:
name: CodeCoverage
path: coveragereport/
if-no-files-found: error

- name: dotnet pack
run: dotnet pack --configuration Release --no-build -o ./NuGet

- name: Upload NuGet artifact
uses: actions/upload-artifact@v3
with:
name: NuGet
path: ./NuGet

automerge:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
needs: build

permissions:
pull-requests: write
contents: write

steps:
- uses: fastify/[email protected]
with:
use-github-auto-merge: true

deploy-nuget:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: build

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: NuGet

- name: Push NuGet
run: dotnet nuget push ${{ github.workspace }}/*nupkg --source https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Post Code Coverage on Pull Request

on:
workflow_run:
workflows: [Build and deploy]
types:
- completed

defaults:
run:
shell: pwsh

jobs:
post-code-coverage:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Download artifacts
run: gh run download ${{ github.event.workflow_run.id }} -n CodeCoverage --repo ${{ github.repository }}
env:
GH_TOKEN: ${{ github.token }}

- name: 'Get PR Number'
id: get-pr-number
run: |
$pr_number = (cat PullRequestNumber)
"pr_number=$pr_number" >> $env:GITHUB_OUTPUT
- uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
number: ${{ steps.get-pr-number.outputs.pr_number }}
path: SummaryGithub.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" />
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="Moq.AutoMock" />
<PackageReference Include="System.CommandLine" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 16 additions & 0 deletions templates/Console/ConsoleApp/ConsoleApp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props
exclusions.dic = exclusions.dic
NuGet.config = NuGet.config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{6E32D310-8A68-4061-82C9-4A0040537448}"
ProjectSection(SolutionItems) = preProject
.github\dependabot.yml = .github\dependabot.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{D73E76B4-8613-4EF2-A925-0766B9E8B02C}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build-and-deploy.yml = .github\workflows\build-and-deploy.yml
.github\workflows\pr-code-coverage-comment.yml = .github\workflows\pr-code-coverage-comment.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,6 +46,10 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6E32D310-8A68-4061-82C9-4A0040537448} = {D88D7F20-19C5-42B4-8561-874CC78B134A}
{D73E76B4-8613-4EF2-A925-0766B9E8B02C} = {6E32D310-8A68-4061-82C9-4A0040537448}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DF353750-2089-4072-9508-65E9DC66DF2D}
EndGlobalSection
Expand Down
13 changes: 13 additions & 0 deletions templates/Console/ConsoleApp/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<Version>0.0.1</Version>
</PropertyGroup>

<!--
For packaging as a dotnet global tool
https://learn.microsoft.com/dotnet/core/tools/global-tools-how-to-create
-->
<!--
<PropertyGroup>
<PackageId>ConsoleApp</PackageId>
<PackAsTool>true</PackAsTool>
<ToolCommandName>ConsoleApp</ToolCommandName>
</PropertyGroup>
-->

<ItemGroup>
<PackageReference Include="System.CommandLine" />
</ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions templates/Console/ConsoleApp/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
This would typically list all NuGet packages used within this solution.
-->
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="3.2.0">
<PackageVersion Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Moq" Version="4.20.69" />
<PackageVersion Include="Moq.AutoMock" Version="3.5.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.23219.2" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.23407.1" />
<PackageVersion Include="xunit" Version="2.5.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
Expand Down
Empty file.

0 comments on commit 42dfbe8

Please sign in to comment.