diff --git a/.github/workflows/install-and-test-action.yml b/.github/workflows/install-and-test-action.yml index 52e2517..944a7d7 100644 --- a/.github/workflows/install-and-test-action.yml +++ b/.github/workflows/install-and-test-action.yml @@ -20,4 +20,6 @@ jobs: uses: cake-build/cake-action@v1 with: script-path: template.cake - target: InstallAndTestTemplate \ No newline at end of file + target: InstallAndTestTemplate + ApiKey: ${{ secrets.NUGET_APIKEY }} + Source: ${{ vars.NUGET_SOURCE }} \ No newline at end of file diff --git a/.github/workflows/pack-and-push-action.yml b/.github/workflows/pack-and-push-action.yml index 3cf90b0..3cf3619 100644 --- a/.github/workflows/pack-and-push-action.yml +++ b/.github/workflows/pack-and-push-action.yml @@ -22,4 +22,4 @@ jobs: script-path: template.cake target: PackAndPushTemplate ApiKey: ${{ secrets.NUGET_APIKEY }} - Source: ${{ vars.NUGET_SOURCE }} \ No newline at end of file + Source: ${{ vars.NUGET_SOURCE }} \ No newline at end of file diff --git a/template.cake b/template.cake index b1e27c7..ac7b977 100644 --- a/template.cake +++ b/template.cake @@ -30,9 +30,49 @@ string fullPackageName; string[] templates = new [] { "Template.TestedLibrary", - "Template.DbApi", + "Template.TestedApi", }; +public void MoveDirectory(string source, string target) +{ + var stack = new Stack(); + stack.Push(new Folders(source, target)); + + while (stack.Count > 0) + { + var folders = stack.Pop(); + System.IO.Directory.CreateDirectory(folders.Target); + foreach (var file in System.IO.Directory.GetFiles(folders.Source, "*.*")) + { + string targetFile = System.IO.Path.Combine(folders.Target, System.IO.Path.GetFileName(file)); + if (System.IO.File.Exists(targetFile)) System.IO.File.Delete(targetFile); + System.IO.File.Move(file, targetFile); + } + + foreach (var folder in System.IO.Directory.GetDirectories(folders.Source)) + { + // Don't copy the .git folder. + if (folder.EndsWith(".git")) + continue; + + stack.Push(new Folders(folder, + System.IO.Path.Combine(folders.Target, System.IO.Path.GetFileName(folder)))); + } + } +} + +public class Folders +{ + public string Source { get; private set; } + public string Target { get; private set; } + + public Folders(string source, string target) + { + Source = source; + Target = target; + } +} + /////////////////////////////////////////////////////////////////////////////// // Setup / Teardown /////////////////////////////////////////////////////////////////////////////// @@ -58,6 +98,61 @@ Task("__PackageArgsCheck") throw new ArgumentException("ApiKey is required"); }); +Task("__CloneTestedLibraryTemplate") + .Does(() => { + + if (!System.IO.Directory.Exists(@"./staging")) + System.IO.Directory.CreateDirectory(@"./staging"); + + if (System.IO.Directory.Exists(@"./staging/Template.TestedLibrary")) + System.IO.Directory.Delete(@"./staging/Template.TestedLibrary", true); + + Information("Cloning Template.TestedLibrary..."); + + var args = new ProcessArgumentBuilder() + .Append($"clone https://TristanRhodes:{apiKey}@github.com/TristanRhodes/Template.TestedLibrary.git"); + + var cloneSettings = new ProcessSettings + { + Arguments = args, + WorkingDirectory = @"./staging" + }; + + var cloneResult = StartProcess("git", cloneSettings); + if (cloneResult != 0) + throw new ApplicationException($"Failed to clone Template.TestedLibrary."); + + MoveDirectory("staging/Template.TestedLibrary", "templates/Template.TestedLibrary"); + }); + +Task("__CloneTestedApiTemplate") + .Does(() => { + + if (!System.IO.Directory.Exists(@"./staging")) + System.IO.Directory.CreateDirectory(@"./staging"); + + if (System.IO.Directory.Exists(@"./staging/Template.TestedApi")) + System.IO.Directory.Delete(@"./staging/Template.TestedApi", true); + + Information("Cloning Template.TestedApi..."); + + var args = new ProcessArgumentBuilder() + .Append($"clone https://TristanRhodes:{apiKey}@github.com/TristanRhodes/Template.TestedApi.git"); + + var cloneSettings = new ProcessSettings + { + Arguments = args, + WorkingDirectory = @"./staging" + }; + + var cloneResult = StartProcess("git", cloneSettings); + if (cloneResult != 0) + throw new ApplicationException($"Failed to clone Template.TestedApi."); + + MoveDirectory("staging/Template.TestedApi", "templates/Template.TestedApi"); + }); + + Task("__InstallTemplate") .Does(() => { Information("Installing Template..."); @@ -71,6 +166,8 @@ Task("__CreateProjectAndTest") foreach(var template in templates) { + Information("Testing Tempalte: " + template); + Information("Cleaning folders..."); if (System.IO.Directory.Exists(@"./bin/template-proj")) System.IO.Directory.Delete(@"./bin/template-proj", true); @@ -144,6 +241,9 @@ Task("__VersionInfo") }); Task("InstallAndTestTemplate") + .IsDependentOn("__PackageArgsCheck") + .IsDependentOn("__CloneTestedLibraryTemplate") + .IsDependentOn("__CloneTestedApiTemplate") .IsDependentOn("__InstallTemplate") .IsDependentOn("__CreateProjectAndTest") .IsDependentOn("__UninstallTemplate"); diff --git a/templates/Template.DbApi/.config/dotnet-tools.json b/templates/Template.DbApi/.config/dotnet-tools.json deleted file mode 100644 index 831d039..0000000 --- a/templates/Template.DbApi/.config/dotnet-tools.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "cake.tool": { - "version": "3.0.0", - "commands": [ - "dotnet-cake" - ] - } - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/.dockerignore b/templates/Template.DbApi/.dockerignore deleted file mode 100644 index 3729ff0..0000000 --- a/templates/Template.DbApi/.dockerignore +++ /dev/null @@ -1,25 +0,0 @@ -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/bin -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml -LICENSE -README.md \ No newline at end of file diff --git a/templates/Template.DbApi/.gitattributes b/templates/Template.DbApi/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/templates/Template.DbApi/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/templates/Template.DbApi/.github/workflows/build-and-test-action.yml b/templates/Template.DbApi/.github/workflows/build-and-test-action.yml deleted file mode 100644 index 9114f87..0000000 --- a/templates/Template.DbApi/.github/workflows/build-and-test-action.yml +++ /dev/null @@ -1,29 +0,0 @@ - -name: Build and Test Solution -run-name: Build and Test Solution - -on: - pull_request: - branches: - - master - -jobs: - Build-And-Test: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - with: - fetch-depth: 0 # This is nescessary so it does not conflict with git-version - - - name: Run cake step - uses: cake-build/cake-action@v1 - with: - script-path: build.cake - target: BuildAndTest - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: TestedLibrary Artifacts - path: ./artifacts/ \ No newline at end of file diff --git a/templates/Template.DbApi/.github/workflows/pack-and-push-action.yml b/templates/Template.DbApi/.github/workflows/pack-and-push-action.yml deleted file mode 100644 index 5cb9b28..0000000 --- a/templates/Template.DbApi/.github/workflows/pack-and-push-action.yml +++ /dev/null @@ -1,34 +0,0 @@ - -name: Pack and Push Solution -run-name: Pack and Push Solution - -on: - push: - branches: - - master - -jobs: - Pack-And-Push: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - with: - fetch-depth: 0 # This is nescessary so it does not conflict with git-version - - - name: Run cake step - uses: cake-build/cake-action@v1 - with: - script-path: build.cake - target: FullPackAndPush - ApiKey: ${{ secrets.NUGET_APIKEY }} - Source: ${{ vars.NUGET_SOURCE }} - ContainerRegistry: ${{ vars.CONTAINER_REGISTRY }} - ContainerRegistryToken: ${{ secrets.CONTAINER_REGISTRY_TOKEN }} - ContainerRegistryUserName: ${{ vars.CONTAINER_REGISTRY_USERNAME }} - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: TestedLibrary Artifacts - path: ./artifacts/ \ No newline at end of file diff --git a/templates/Template.DbApi/.gitignore b/templates/Template.DbApi/.gitignore deleted file mode 100644 index 9e5825f..0000000 --- a/templates/Template.DbApi/.gitignore +++ /dev/null @@ -1,364 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Oo]ut/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -**/tools/** -!**/tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd -*.ncrunchsolution diff --git a/templates/Template.DbApi/LICENSE.txt b/templates/Template.DbApi/LICENSE.txt deleted file mode 100644 index 8aa2645..0000000 --- a/templates/Template.DbApi/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) [year] [fullname] - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/templates/Template.DbApi/README.md b/templates/Template.DbApi/README.md deleted file mode 100644 index baf6f89..0000000 --- a/templates/Template.DbApi/README.md +++ /dev/null @@ -1,30 +0,0 @@ -### Message Template.DbApi - -## Template Project -This project was created from a template. - -## Overview - -This project contains a postgres DB, an API, and a DB up project to handle DB migrations. - -* Keycloak and SSO -* `Ping`, `Health`, and `Metrics` endpoints. -* Unit Tests, Acceptance Tests and Benchmarks with packaged reports. -* Export swagger defintions. - -### To Run -Run docker-compose project in VS - -OR - -Run `docker compose -f docker-compose.infra.yml up` -Launch apps: -* Template.DbApi.API -* Template.DbApi.DbUp - - -### Docker Pack and Push - -for the purpose of getting started, I am using `ghcr.io/TristanRhodes` and the default `USERNAME` - -`dotnet cake --Target=DockerPackAndPush --ContainerRegistry=ghcr.io/TristanRhodes --ContainerRegistryToken={token} --ContainerRegistryUserName=USERNAME` \ No newline at end of file diff --git a/templates/Template.DbApi/Template.DbApi.sln b/templates/Template.DbApi/Template.DbApi.sln deleted file mode 100644 index 1699cb3..0000000 --- a/templates/Template.DbApi/Template.DbApi.sln +++ /dev/null @@ -1,80 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.32112.339 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Template.DbApi", "src\Template.DbApi\Template.DbApi.csproj", "{394802F1-4507-42D5-808E-90E73AA05A85}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6F7D680F-991C-4E30-B835-E2AF3A558390}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{391B01B0-22D7-4B3D-BB61-F4263AFAA4E2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Template.DbApi.Api", "src\Template.DbApi.Api\Template.DbApi.Api.csproj", "{E6EE082A-4B00-4EB7-BB07-794405EA6A74}" -EndProject -Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{F906CB00-263B-41F9-B129-FEA19802AED8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{BB8C3CB1-DAB0-44B8-93C4-00DD38CA96BB}" - ProjectSection(SolutionItems) = preProject - build.cake = build.cake - build.cakemix = build.cakemix - README.md = README.md - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Template.DbApi.DbUp", "src\Template.DbApi.DbUp\Template.DbApi.DbUp.csproj", "{9E50A0DC-5C52-4556-B2AE-D9421F9F4F29}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Template.DbApi.UnitTests", "test\Template.DbApi.UnitTests\Template.DbApi.UnitTests.csproj", "{EB6D2A08-EC3D-4BF8-9EC0-DF8EED0CF329}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Template.DbApi.AcceptanceTests", "test\Template.DbApi.AcceptanceTests\Template.DbApi.AcceptanceTests.csproj", "{B0B61E2F-1395-495D-BF82-7F7FFE91BBC6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Template.DbApi.Benchmark", "test\Template.DbApi.Benchmark\Template.DbApi.Benchmark.csproj", "{8026E453-ED3D-467C-930D-53D189EC6CD5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {394802F1-4507-42D5-808E-90E73AA05A85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {394802F1-4507-42D5-808E-90E73AA05A85}.Debug|Any CPU.Build.0 = Debug|Any CPU - {394802F1-4507-42D5-808E-90E73AA05A85}.Release|Any CPU.ActiveCfg = Release|Any CPU - {394802F1-4507-42D5-808E-90E73AA05A85}.Release|Any CPU.Build.0 = Release|Any CPU - {E6EE082A-4B00-4EB7-BB07-794405EA6A74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E6EE082A-4B00-4EB7-BB07-794405EA6A74}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6EE082A-4B00-4EB7-BB07-794405EA6A74}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6EE082A-4B00-4EB7-BB07-794405EA6A74}.Release|Any CPU.Build.0 = Release|Any CPU - {F906CB00-263B-41F9-B129-FEA19802AED8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F906CB00-263B-41F9-B129-FEA19802AED8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F906CB00-263B-41F9-B129-FEA19802AED8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F906CB00-263B-41F9-B129-FEA19802AED8}.Release|Any CPU.Build.0 = Release|Any CPU - {9E50A0DC-5C52-4556-B2AE-D9421F9F4F29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9E50A0DC-5C52-4556-B2AE-D9421F9F4F29}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9E50A0DC-5C52-4556-B2AE-D9421F9F4F29}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9E50A0DC-5C52-4556-B2AE-D9421F9F4F29}.Release|Any CPU.Build.0 = Release|Any CPU - {EB6D2A08-EC3D-4BF8-9EC0-DF8EED0CF329}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EB6D2A08-EC3D-4BF8-9EC0-DF8EED0CF329}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EB6D2A08-EC3D-4BF8-9EC0-DF8EED0CF329}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EB6D2A08-EC3D-4BF8-9EC0-DF8EED0CF329}.Release|Any CPU.Build.0 = Release|Any CPU - {B0B61E2F-1395-495D-BF82-7F7FFE91BBC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B0B61E2F-1395-495D-BF82-7F7FFE91BBC6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B0B61E2F-1395-495D-BF82-7F7FFE91BBC6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B0B61E2F-1395-495D-BF82-7F7FFE91BBC6}.Release|Any CPU.Build.0 = Release|Any CPU - {8026E453-ED3D-467C-930D-53D189EC6CD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8026E453-ED3D-467C-930D-53D189EC6CD5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8026E453-ED3D-467C-930D-53D189EC6CD5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8026E453-ED3D-467C-930D-53D189EC6CD5}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {394802F1-4507-42D5-808E-90E73AA05A85} = {6F7D680F-991C-4E30-B835-E2AF3A558390} - {E6EE082A-4B00-4EB7-BB07-794405EA6A74} = {6F7D680F-991C-4E30-B835-E2AF3A558390} - {9E50A0DC-5C52-4556-B2AE-D9421F9F4F29} = {6F7D680F-991C-4E30-B835-E2AF3A558390} - {EB6D2A08-EC3D-4BF8-9EC0-DF8EED0CF329} = {391B01B0-22D7-4B3D-BB61-F4263AFAA4E2} - {B0B61E2F-1395-495D-BF82-7F7FFE91BBC6} = {391B01B0-22D7-4B3D-BB61-F4263AFAA4E2} - {8026E453-ED3D-467C-930D-53D189EC6CD5} = {391B01B0-22D7-4B3D-BB61-F4263AFAA4E2} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CAD81B82-8E39-4E88-9AB6-DD38786C5FD1} - EndGlobalSection -EndGlobal diff --git a/templates/Template.DbApi/build.cake b/templates/Template.DbApi/build.cake deleted file mode 100644 index a10ac62..0000000 --- a/templates/Template.DbApi/build.cake +++ /dev/null @@ -1,417 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// ADDINS -/////////////////////////////////////////////////////////////////////////////// -#addin nuget:?package=Cake.Json&version=7.0.1 -#addin nuget:?package=Cake.Docker&version=1.2.0 - -/////////////////////////////////////////////////////////////////////////////// -// TOOLS -/////////////////////////////////////////////////////////////////////////////// -#tool dotnet:?package=GitVersion.Tool&version=5.12.0 - -/////////////////////////////////////////////////////////////////////////////// -// ARGUMENTS -/////////////////////////////////////////////////////////////////////////////// -var target = Argument("target", "Default"); - -var configuration = Argument("configuration", "Release"); - -var nugetPackageSource = Argument("Source", null) // Input from cmd args to Cake - ?? EnvironmentVariable("INPUT_SOURCE", null); // Input from GHA to Cake - -var nugetApiKey = Argument("ApiKey", null) // Input from cmd args to Cake - ?? EnvironmentVariable("INPUT_APIKEY", null); // Input from GHA to Cake - -var versionNumber = Argument("VersionOverride", null) // Input from cmd args to Cake - ?? EnvironmentVariable("INPUT_VERSIONOVERRIDE", null); // Input from GHA to Cake - -var containerRegistry = - Argument("ContainerRegistry", null) ?? - EnvironmentVariable("INPUT_CONTAINERREGISTRY", null); - -var containerRegistryToken = - Argument("ContainerRegistryToken", null) ?? - EnvironmentVariable("INPUT_CONTAINERREGISTRYTOKEN", null); - -var containerRegistryUserName = - Argument("ContainerRegistryUserName", null) ?? - EnvironmentVariable("INPUT_CONTAINERREGISTRYUSERNAME", null); - -var artifactsFolder = "./artifacts"; -var packagesFolder = System.IO.Path.Combine(artifactsFolder, "packages"); -var swaggerFolder = System.IO.Path.Combine(artifactsFolder, "swagger"); -var postmanFolder = System.IO.Path.Combine(artifactsFolder, "postman"); - -BuildManifest buildManifest; - -/////////////////////////////////////////////////////////////////////////////// -// Setup / Teardown -/////////////////////////////////////////////////////////////////////////////// -Setup(context => -{ - var cakeMixFile = "build.cakemix"; - - // Load BuildManifest - if (!System.IO.File.Exists(cakeMixFile)) - { - Warning("No cakemix file found, creating..."); - - var manifest = new BuildManifest - { - NugetPackages = new string[0], - DockerComposeFiles = System.IO.Directory.GetFiles(".", "docker-compose*.yml"), - DockerPackages = System.IO.Directory.GetFiles(".\\src\\", "Dockerfile", SearchOption.AllDirectories), - UnitTests = System.IO.Directory.GetFiles(".", "*.UnitTests.csproj", SearchOption.AllDirectories), - AcceptanceTests = System.IO.Directory.GetFiles(".", "*.AcceptanceTests.csproj", SearchOption.AllDirectories), - Benchmarks = System.IO.Directory.GetFiles(".", "*.Benchmark.csproj", SearchOption.AllDirectories), - }; - SerializeJsonToPrettyFile(cakeMixFile, manifest); - } - - buildManifest = DeserializeJsonFromFile(cakeMixFile); - - // Clean artifacts - if (System.IO.Directory.Exists(artifactsFolder)) - System.IO.Directory.Delete(artifactsFolder, true); -}); - -Teardown(context => -{ - -}); - -/////////////////////////////////////////////////////////////////////////////// -// Tasks -/////////////////////////////////////////////////////////////////////////////// -Task("__NugetArgsCheck") - .Does(() => { - if (string.IsNullOrEmpty(nugetPackageSource)) - throw new ArgumentException("NugetPackageSource is required"); - - if (string.IsNullOrEmpty(nugetApiKey)) - throw new ArgumentException("NugetApiKey is required"); - }); - -Task("__ContainerArgsCheck") - .Does(() => { - if (string.IsNullOrEmpty(containerRegistryToken)) - throw new ArgumentException("ContainerRegistryToken is required"); - - if (string.IsNullOrEmpty(containerRegistryUserName)) - throw new ArgumentException("ContainerRegistryUserName is required"); - - if (string.IsNullOrEmpty(containerRegistry)) - throw new ArgumentException("ContainerRegistry is required"); - }); - -Task("__UnitTest") - .Does(() => { - - foreach(var test in buildManifest.UnitTests) - { - Information($"Testing {test}..."); - - var testName = System.IO.Path.GetFileNameWithoutExtension(test); - - var settings = new DotNetTestSettings - { - Configuration = configuration, - ResultsDirectory = artifactsFolder - }; - - // Console log for build agent - settings.Loggers.Add("console;verbosity=normal"); - - // Logging for trx test report artifact - settings.Loggers.Add($"trx;logfilename={testName}.trx"); - - DotNetTest(test, settings); - } - }); - -Task("__DockerComposeUp") - .Does(() => { - - var settings = new DockerComposeUpSettings - { - Files = buildManifest.DockerComposeFiles, - DetachedMode = true - }; - DockerComposeUp(settings); - }); - -Task("__AcceptanceTest") - .IsDependentOn("__DockerComposeUp") - .Does(() => { - - foreach(var test in buildManifest.AcceptanceTests) - { - Information($"Acceptance Testing {test}..."); - - var testName = System.IO.Path.GetFileNameWithoutExtension(test); - - var settings = new DotNetTestSettings - { - Configuration = configuration, - ResultsDirectory = artifactsFolder, - EnvironmentVariables = new Dictionary { - { "env", "ci" } - } - }; - - // Console log for build agent - settings.Loggers.Add("console;verbosity=normal"); - - // Logging for trx test report artifact - settings.Loggers.Add($"trx;logfilename={testName}.trx"); - - DotNetTest(test, settings); - } - }); - -Task("__Benchmark") - .Does(() => { - - foreach(var benchmark in buildManifest.Benchmarks) - { - Information($"Benchmarking {benchmark}..."); - var benchName = System.IO.Path.GetFileNameWithoutExtension(benchmark); - - var settings = new DotNetRunSettings - { - Configuration = "Release", - ArgumentCustomization = args => { - return args - .Append("--artifacts") - .AppendQuoted(System.IO.Path.Combine(artifactsFolder, benchName)); - } - }; - - DotNetRun(benchmark, settings); - } - }); - -Task("__VersionInfo") - .Does(() => { - - if (string.IsNullOrEmpty(versionNumber)) - { - var version = GitVersion(); - Information("GitVersion Info: " + SerializeJsonPretty(version)); - versionNumber = version.SemVer; - } - - Information("Version Number: " + versionNumber); - }); - -Task("__GenerateSwagger") - .Does(async () => { - - if (!System.IO.Directory.Exists(swaggerFolder)) - System.IO.Directory.CreateDirectory(swaggerFolder); - - foreach(var kvp in buildManifest.ApiSpecs) - { - using var client = new System.Net.Http.HttpClient(); - var response = await client.GetAsync($"{kvp.Value}/swagger/v1/swagger.json"); - response.EnsureSuccessStatusCode(); - - var content = await response.Content.ReadAsStringAsync(); - - var fileArtifact = System.IO.Path.Combine(swaggerFolder, $"{kvp.Key}.swagger.json"); - - System.IO.File.WriteAllText(fileArtifact, content); - } - }); - -Task("__GeneratePostman") - .Does(() => { - - // From Root: - // docker build ./docker/OpenApiToPostman/ -t tr/openapi-to-postmanv2 - // docker run -d -v {localroot}\artifacts\swagger:/swagger -v {localroot}\artifacts\postman:/postman -p 8080:8080 tr/openapi-to-postmanv2 - - var basePath = System.IO.Path.GetFullPath(@".\artifacts"); - - // Build Docker - var buildSettings = new DockerImageBuildSettings - { - Tag = new [] { "tr/openapi-to-postmanv2" } - }; - DockerBuild(buildSettings, "./docker/OpenApiToPostman/"); - - // Run Docker - var runSettings = new DockerContainerRunSettings - { - Volume = new [] - { - @$"{basePath}\swagger:/swagger", - @$"{basePath}\postman:/postman", - }, - Publish = new [] - { - "8080:8080" - } - }; - DockerRun(runSettings, "tr/openapi-to-postmanv2", string.Empty, "-d"); - }); - -Task("__NugetPack") - .Does(() => { - - foreach(var package in buildManifest.NugetPackages) - { - Information($"Packing {package}..."); - var settings = new DotNetMSBuildSettings - { - PackageVersion = versionNumber - }; - - var packSettings = new DotNetPackSettings - { - Configuration = "Release", - OutputDirectory = packagesFolder, - MSBuildSettings = settings - }; - DotNetPack(package, packSettings); - } - }); - -Task("__NugetPush") - .Does(() => { - - if (!System.IO.Directory.Exists(packagesFolder)) - { - Information("No packages to push in the packages folder"); - return; - } - - var packedArtifacts = System.IO.Directory.EnumerateFiles(packagesFolder); - foreach(var package in packedArtifacts) - { - Information($"Pushing {package}..."); - var pushSettings = new DotNetNuGetPushSettings - { - Source = nugetPackageSource, - ApiKey = nugetApiKey - }; - DotNetNuGetPush(package, pushSettings); - } - }); - -Task("__DockerLogin") - .Does(() => { - - Information($"Logging into registry: {containerRegistry}..."); - - var loginSettings = new DockerRegistryLoginSettings - { - Password = containerRegistryToken, - Username = containerRegistryUserName - }; - - DockerLogin(loginSettings, containerRegistry); - }); - -Task("__DockerPack") - .IsDependentOn("__VersionInfo") - .Does(() => { - - foreach(var package in buildManifest.DockerPackages) - { - Information($"Packing Docker: {package}..."); - var directoryName = System.IO.Path.GetDirectoryName(package); - var parts = directoryName.Split(System.IO.Path.DirectorySeparatorChar); - var packageName = parts.Last().ToLower(); - packageName = $"{containerRegistry}/{packageName}".ToLower(); - - Information($"Packing: {packageName}..."); - var settings = new DockerImageBuildSettings - { - Tag = new[] { $"{packageName}:{versionNumber}" }, - File = package - }; - - DockerBuild(settings, "."); - } - }); - -Task("__DockerPush") - .Does(() => { - - foreach(var package in buildManifest.DockerPackages) - { - Information($"Pushing Docker: {package}..."); - var directoryName = System.IO.Path.GetDirectoryName(package); - var parts = directoryName.Split(System.IO.Path.DirectorySeparatorChar); - var packageName = parts.Last().ToLower(); - packageName = $"{containerRegistry}/{packageName}".ToLower(); - var fullPackageName = $"{packageName}:{versionNumber}"; - - var settings = new DockerImagePushSettings - { - AllTags = true - }; - - Information($"Pushing: {packageName}..."); - - DockerPush(settings, $"{packageName}"); - } - }); - -Task("BuildAndTest") - .IsDependentOn("__UnitTest"); - -Task("BuildAndAcceptanceTest") - .IsDependentOn("__AcceptanceTest"); - -Task("BuildAndBenchmark") - .IsDependentOn("__Benchmark"); - -Task("NugetPackAndPush") - .IsDependentOn("__NugetArgsCheck") - .IsDependentOn("__VersionInfo") - .IsDependentOn("__UnitTest") - .IsDependentOn("__Benchmark") - .IsDependentOn("__NugetPack") - .IsDependentOn("__NugetPush"); - -Task("DockerPackAndPush") - .IsDependentOn("__ContainerArgsCheck") - .IsDependentOn("__DockerLogin") - .IsDependentOn("__DockerPack") - .IsDependentOn("__DockerPush"); - -Task("FullPackAndPush") - .IsDependentOn("__NugetArgsCheck") - .IsDependentOn("__ContainerArgsCheck") - .IsDependentOn("__VersionInfo") - .IsDependentOn("__UnitTest") - .IsDependentOn("__Benchmark") - .IsDependentOn("__NugetPack") - .IsDependentOn("__DockerLogin") - .IsDependentOn("__DockerPack") - .IsDependentOn("__NugetPush") - .IsDependentOn("__DockerPush"); - -Task("ExportApiSpecs") - .IsDependentOn("__DockerComposeUp") - .IsDependentOn("__GenerateSwagger") - .IsDependentOn("__GeneratePostman"); - -Task("Default") - .IsDependentOn("__UnitTest") - .IsDependentOn("__Benchmark"); - -RunTarget(target); - -public class BuildManifest -{ - public string[] NugetPackages { get; set; } - public string[] DockerPackages { get; set; } - public string[] DockerComposeFiles { get; set; } - public string[] AcceptanceTests { get; set; } - public string[] UnitTests { get; set; } - public string[] Benchmarks { get; set; } - public Dictionary ApiSpecs { get; set; } -} \ No newline at end of file diff --git a/templates/Template.DbApi/build.cakemix b/templates/Template.DbApi/build.cakemix deleted file mode 100644 index 0307da9..0000000 --- a/templates/Template.DbApi/build.cakemix +++ /dev/null @@ -1,24 +0,0 @@ -{ - "NugetPackages": [], - "DockerPackages": [ - ".\\src\\Template.DbApi.Api\\Dockerfile", - ".\\src\\Template.DbApi.DbUp\\Dockerfile" - ], - "DockerComposeFiles": [ - ".\\docker-compose.yml", - ".\\docker-compose.infra.yml", - ".\\docker-compose.override.yml" - ], - "AcceptanceTests": [ - ".\\test\\Template.DbApi.AcceptanceTests\\Template.DbApi.AcceptanceTests.csproj" - ], - "UnitTests": [ - ".\\test\\Template.DbApi.UnitTests\\Template.DbApi.UnitTests.csproj" - ], - "Benchmarks": [ - ".\\test\\Template.DbApi.Benchmark\\Template.DbApi.Benchmark.csproj" - ], - "ApiSpecs": { - "Template.DbApi.Api": "http://localhost:5080" - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/docker-compose.dcproj b/templates/Template.DbApi/docker-compose.dcproj deleted file mode 100644 index ee59de7..0000000 --- a/templates/Template.DbApi/docker-compose.dcproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 2.1 - Linux - f906cb00-263b-41f9-b129-fea19802aed8 - LaunchBrowser - {Scheme}://localhost:{ServicePort}/swagger - enricher.api - docker-compose.infra.yml - - - - docker-compose.yml - - - docker-compose.yml - - - - - \ No newline at end of file diff --git a/templates/Template.DbApi/docker-compose.infra.yml b/templates/Template.DbApi/docker-compose.infra.yml deleted file mode 100644 index c3a3fbd..0000000 --- a/templates/Template.DbApi/docker-compose.infra.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: '3.4' - -services: - - enricher.db: - image: postgres - container_name: Template.DbApi.Db - restart: always - environment: - POSTGRES_PASSWORD: example - ports: - - 5432:5432 - networks: - - main - - enricher.seq: - image: datalust/seq - container_name: Template.DbApi.Seq - ports: - - "5030:80" - environment: - - ACCEPT_EULA=Y - networks: - - main - -networks: - main: \ No newline at end of file diff --git a/templates/Template.DbApi/docker-compose.override.yml b/templates/Template.DbApi/docker-compose.override.yml deleted file mode 100644 index c127e33..0000000 --- a/templates/Template.DbApi/docker-compose.override.yml +++ /dev/null @@ -1,28 +0,0 @@ -version: '3.4' - -services: - - enricher.api: - environment: - - ASPNETCORE_ENVIRONMENT=Development - - http://+:80 - - Serilog__WriteTo__0__Args__serverUrl=http://Template.DbApi.Seq - - Postgres__WriteConnection=Host=Template.DbApi.Db;Port=5432;Username=postgres;Password=example;Database=shop; - - Postgres__ReadConnection=Host=Template.DbApi.Db;Port=5432;Username=postgres;Password=example;Database=shop; - ports: - - "5080:80" - volumes: - - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro - - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro - networks: - - main - - enricher.dbup: - environment: - - ASPNETCORE_ENVIRONMENT=Development - - DbConnectionString=Host=Template.DbApi.Db;Port=5432;Username=postgres;Password=example;Database=shop; - networks: - - main - -networks: - main: \ No newline at end of file diff --git a/templates/Template.DbApi/docker-compose.yml b/templates/Template.DbApi/docker-compose.yml deleted file mode 100644 index 4784957..0000000 --- a/templates/Template.DbApi/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: '3.4' - -services: - - enricher.api: - image: ${DOCKER_REGISTRY-}enricherapi - build: - context: . - dockerfile: src/Template.DbApi.Api/Dockerfile - - enricher.dbup: - image: ${DOCKER_REGISTRY-}enricherdbup - build: - context: . - dockerfile: src/Template.DbApi.DbUp/Dockerfile \ No newline at end of file diff --git a/templates/Template.DbApi/docker/OpenApiToPostman/Dockerfile b/templates/Template.DbApi/docker/OpenApiToPostman/Dockerfile deleted file mode 100644 index 2cf7a6e..0000000 --- a/templates/Template.DbApi/docker/OpenApiToPostman/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM node:16 - -# Create app directory -WORKDIR /usr/src/app - -# Install app dependencies -# A wildcard is used to ensure both package.json AND package-lock.json are copied -# where available (npm@5+) -COPY package*.json ./ - -RUN npm install -# If you are building your code for production -# RUN npm ci --omit=dev - -# Bundle app source -COPY . . - -EXPOSE 8080 -CMD [ "node", "server.js" ] \ No newline at end of file diff --git a/templates/Template.DbApi/docker/OpenApiToPostman/package.json b/templates/Template.DbApi/docker/OpenApiToPostman/package.json deleted file mode 100644 index e0bd7c5..0000000 --- a/templates/Template.DbApi/docker/OpenApiToPostman/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "docker_web_app", - "version": "1.0.0", - "description": "Node.js on Docker", - "author": "First Last ", - "main": "server.js", - "scripts": { - "start": "node server.js" - }, - "dependencies": { - "openapi-to-postmanv2": "^4.11.0" - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/docker/OpenApiToPostman/server.js b/templates/Template.DbApi/docker/OpenApiToPostman/server.js deleted file mode 100644 index 478fb21..0000000 --- a/templates/Template.DbApi/docker/OpenApiToPostman/server.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -// https://github.com/postmanlabs/OpenAPI-to-Postman -const fs = require('fs'); -const converter = require('openapi-to-postmanv2'); - -var files = fs.readdirSync('/swagger'); - -files.forEach(file => { - console.log(file); - - var postmanFile = file.replace('swagger', 'collection'); - const openapiData = fs.readFileSync(`/swagger/${file}`, { encoding: 'UTF8' }); - - converter.convert({ type: 'string', data: openapiData }, - {}, (err, conversionResult) => { - - if (!conversionResult.result) { - throw err; - } - - var payload = conversionResult.output[0].data; - console.log('The collection object is: ', payload); - - fs.writeFileSync(`/postman/${postmanFile}`, JSON.stringify(payload)); - } - ); - -}); - diff --git a/templates/Template.DbApi/launchSettings.json b/templates/Template.DbApi/launchSettings.json deleted file mode 100644 index 8cb5de4..0000000 --- a/templates/Template.DbApi/launchSettings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "profiles": { - "Docker Compose": { - "commandName": "DockerCompose", - "commandVersion": "1.0", - "serviceActions": { - "enricher.api": "StartDebugging", - "enricher.consumer": "StartDebugging", - "enricher.queue": "StartWithoutDebugging", - "enricher.simulator": "StartDebugging" - } - } - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/scripts/postgres-kill.ps1 b/templates/Template.DbApi/scripts/postgres-kill.ps1 deleted file mode 100644 index fefe61d..0000000 --- a/templates/Template.DbApi/scripts/postgres-kill.ps1 +++ /dev/null @@ -1,25 +0,0 @@ - -$container = $(docker container ls -a -q --filter=name='Template.DbApi.Db') - -# Remove DB containers -if ($container -ne $null) { - Write-Host "Found existing database container. Removing." - docker kill $container - docker rm $container -} -else -{ - Write-Host "No database container found." -} - -# Clear out DB image -$image = docker images -a -q --filter=reference='*enricher.db' - -if ($image -ne $null) { - Write-Host "Found existing database image. Removing." - docker rmi $image -f -} -else -{ - Write-Host "No database image found." -} \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.Api/Controllers/TodoListController.cs b/templates/Template.DbApi/src/Template.DbApi.Api/Controllers/TodoListController.cs deleted file mode 100644 index 753ab0b..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.Api/Controllers/TodoListController.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Serilog; -using System; -using Dapper; -using System.Threading.Tasks; -using Template.DbApi.Model; -using MediatR; -using System.Collections.Generic; -using Template.DbApi.Handlers; - -namespace Template.DbApi.Api.Controllers -{ - [ApiController] - [Route("[controller]")] - public class TodoListController : ControllerBase - { - private readonly IMediator _mediator; - - public TodoListController(IMediator store) - { - _mediator = store; - } - - [HttpGet] - public async Task GetItems() - { - var result = await _mediator.Send(new SelectTodo()); - - return Ok(result); - } - - [HttpPost] - public async Task InsertItem(InsertTodo insert) - { - var result = await _mediator.Send(insert); - return Ok(result); - } - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.Api/Dockerfile b/templates/Template.DbApi/src/Template.DbApi.Api/Dockerfile deleted file mode 100644 index 9965477..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.Api/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY ["src/Template.DbApi.Api/Template.DbApi.Api.csproj", "src/Template.DbApi.Api/"] -RUN dotnet restore "src/Template.DbApi.Api/Template.DbApi.Api.csproj" -COPY . . -WORKDIR "/src/src/Template.DbApi.Api" -RUN dotnet build "Template.DbApi.Api.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "Template.DbApi.Api.csproj" -c Release -o /app/publish - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Template.DbApi.Api.dll"] \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.Api/Program.cs b/templates/Template.DbApi/src/Template.DbApi.Api/Program.cs deleted file mode 100644 index cfa06d4..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.Api/Program.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Template.DbApi; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Prometheus; -using Serilog; - -var builder = WebApplication.CreateBuilder(args); - -// Add services to the container. -builder.Services.AddControllers(); - -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); -builder.Services.WithSerilog(builder.Configuration, "Template.DbApi API"); -builder.Services.WithPostgres(builder.Configuration); -builder.Services.WithMediatr(); -builder.Services.AddHealthChecks(); - -var app = builder.Build(); - -// Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) -{ - app.UseSwagger(); - app.UseSwaggerUI(); -} - -app.UseHttpsRedirectionExcluding("/_system"); - -// https://github.com/prometheus-net/prometheus-net - -app.UseMetricServer(); -app.UseRouting(); -app.UseHttpMetrics(); -app.UseAuthorization(); - -app.UseEndpoints(endpoints => -{ - endpoints.MapControllers(); - endpoints.MapMetrics("_system/metrics"); - endpoints.MapHealthChecks("/_system/health"); - endpoints.MapGet("/_system/ping", () => Results.Ok("pong")); -}); - -app.MapControllers(); - -Log.Logger.Information("Starting Application"); - -app.Run(); diff --git a/templates/Template.DbApi/src/Template.DbApi.Api/Properties/launchSettings.json b/templates/Template.DbApi/src/Template.DbApi.Api/Properties/launchSettings.json deleted file mode 100644 index 6b2513f..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.Api/Properties/launchSettings.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:35614", - "sslPort": 44353 - } - }, - "profiles": { - "Template.DbApi.Api": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:7160;http://localhost:5160", - "dotnetRunMessages": true - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Docker": { - "commandName": "Docker", - "launchBrowser": true, - "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", - "publishAllPorts": true, - "useSSL": true - } - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.Api/Template.DbApi.Api.csproj b/templates/Template.DbApi/src/Template.DbApi.Api/Template.DbApi.Api.csproj deleted file mode 100644 index d9232ea..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.Api/Template.DbApi.Api.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net6.0 - enable - 906f752f-f3ab-4819-8b5c-43d9bd0ab85c - Linux - ..\.. - ..\..\docker-compose.dcproj - - - - - - - - - - - - - - - - diff --git a/templates/Template.DbApi/src/Template.DbApi.Api/appsettings.Development.json b/templates/Template.DbApi/src/Template.DbApi.Api/appsettings.Development.json deleted file mode 100644 index 0c208ae..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.Api/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/templates/Template.DbApi/src/Template.DbApi.Api/appsettings.json b/templates/Template.DbApi/src/Template.DbApi.Api/appsettings.json deleted file mode 100644 index f4d01b3..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.Api/appsettings.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "DetailedErrors": true, - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "Serilog": { - "Using": [ - "Serilog.Sinks.Seq" - ], - "WriteTo": [ - { - "Name": "Seq", - "Args": { - "restrictedToMinimumLevel": "Information", - "compact": true, - "serverUrl": "http://localhost:5030" - } - } - ] - }, - "Postgres": { - "WriteConnection": "Host=localhost;Port=5432;Username=postgres;Password=example;Database=shop;", - "ReadConnection": "Host=localhost;Port=5432;Username=postgres;Password=example;Database=shop;" - }, - "AllowedHosts": "*" -} \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.DbUp/Dockerfile b/templates/Template.DbApi/src/Template.DbApi.DbUp/Dockerfile deleted file mode 100644 index b8485ef..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.DbUp/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY ["src/Template.DbApi.DbUp/Template.DbApi.DbUp.csproj", "src/Template.DbApi.DbUp/"] -RUN dotnet restore "src/Template.DbApi.DbUp/Template.DbApi.DbUp.csproj" -COPY . . -WORKDIR "/src/src/Template.DbApi.DbUp" -RUN dotnet build "Template.DbApi.DbUp.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "Template.DbApi.DbUp.csproj" -c Release -o /app/publish - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Template.DbApi.DbUp.dll"] \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.DbUp/Program.cs b/templates/Template.DbApi/src/Template.DbApi.DbUp/Program.cs deleted file mode 100644 index bec7423..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.DbUp/Program.cs +++ /dev/null @@ -1,47 +0,0 @@ -using DbUp; -using Npgsql; -using Polly; -using System.Reflection; - -public static class Program -{ - static int Main(string[] args) - { - var connectionString = - args.FirstOrDefault() - ?? Environment.GetEnvironmentVariable("DbConnectionString"); - - if (string.IsNullOrEmpty(connectionString)) - throw new ArgumentException("Must supply either connection string arg, or DbConnectionString environment variable."); - - var retryPolicy = Policy - .Handle() - .WaitAndRetry(20, i => TimeSpan.FromSeconds(5), - (e, t) => Console.WriteLine("Retrying... Waiting for database")); - - retryPolicy.Execute(() => - EnsureDatabase.For.PostgresqlDatabase(connectionString)); - - var upgrader = - DeployChanges.To - .PostgresqlDatabase(connectionString) - .WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()) - .LogToConsole() - .Build(); - - var result = upgrader.PerformUpgrade(); - - if (!result.Successful) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(result.Error); - Console.ResetColor(); - return -1; - } - - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine("Success!"); - Console.ResetColor(); - return 0; - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.DbUp/Properties/launchSettings.json b/templates/Template.DbApi/src/Template.DbApi.DbUp/Properties/launchSettings.json deleted file mode 100644 index d538879..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.DbUp/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "Template.DbApi.DbUp": { - "commandName": "Project", - "commandLineArgs": "Host=localhost;Port=5432;Username=postgres;Password=example;Database=shop;" - } - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.DbUp/Scripts/0001_Create_Tables.sql b/templates/Template.DbApi/src/Template.DbApi.DbUp/Scripts/0001_Create_Tables.sql deleted file mode 100644 index ec665cc..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.DbUp/Scripts/0001_Create_Tables.sql +++ /dev/null @@ -1,14 +0,0 @@ --- Load Extensions -CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; - --- Create Tables - -CREATE TABLE todo_list ( - item_id uuid NOT NULL DEFAULT uuid_generate_v4 (), - title VARCHAR(128) NOT NULL, - description VARCHAR(512) NOT NULL, - due_date date NOT NULL, - open boolean default true, - closed_date date default NULL, - PRIMARY KEY(item_id) - ); \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi.DbUp/Template.DbApi.DbUp.csproj b/templates/Template.DbApi/src/Template.DbApi.DbUp/Template.DbApi.DbUp.csproj deleted file mode 100644 index b4fd34e..0000000 --- a/templates/Template.DbApi/src/Template.DbApi.DbUp/Template.DbApi.DbUp.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - - - - - - - - - - diff --git a/templates/Template.DbApi/src/Template.DbApi/ConfigurationExtensions.cs b/templates/Template.DbApi/src/Template.DbApi/ConfigurationExtensions.cs deleted file mode 100644 index 252eda7..0000000 --- a/templates/Template.DbApi/src/Template.DbApi/ConfigurationExtensions.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Serilog; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Configuration; -using System.Reflection; -using static Dapper.SqlMapper; -using Microsoft.Extensions.Options; -using Template.DbApi.Model; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; - -namespace Template.DbApi; -public static class ConfigurationExtensions -{ - public static IApplicationBuilder UseHttpsRedirectionExcluding(this IApplicationBuilder builder, string excluding) - { - builder.UseWhen( - context => !context.Request.Path.StartsWithSegments(excluding), - builder => builder.UseHttpsRedirection()); - - return builder; - } - - public static IServiceCollection WithMediatr(this IServiceCollection services) - { - services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining(typeof(ConfigurationExtensions))); - return services; - } - - public static IServiceCollection WithPostgres(this IServiceCollection services, IConfiguration configuration) - { - var writeConn = configuration.GetSection("Postgres:WriteConnection").Value; - var readConn = configuration.GetSection("Postgres:ReadConnection").Value; - services.AddSingleton(new PostgresConnectionFactory(writeConn, readConn)); - - return services; - } - - public static IServiceCollection WithSerilog(this IServiceCollection services, IConfiguration configuration, string appName) - { - Log.Logger = new LoggerConfiguration() - .ReadFrom.Configuration(configuration) - .WriteTo.Console() - .Enrich.WithProperty("App", appName) - .CreateLogger(); - services.AddSingleton(Log.Logger); - services.AddLogging(lb => { - lb.ClearProviders(); - lb.AddSerilog(Log.Logger); - }); - - return services; - } -} diff --git a/templates/Template.DbApi/src/Template.DbApi/Handlers/InsertTodoItemHandler.cs b/templates/Template.DbApi/src/Template.DbApi/Handlers/InsertTodoItemHandler.cs deleted file mode 100644 index 9f07497..0000000 --- a/templates/Template.DbApi/src/Template.DbApi/Handlers/InsertTodoItemHandler.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Dapper; -using MediatR; -using Microsoft.AspNetCore.Connections; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Template.DbApi.Model; - -namespace Template.DbApi.Handlers; -internal class InsertTodoItemHandler : IRequestHandler -{ - private readonly IConnectionFactory _connectionFactory; - - public InsertTodoItemHandler(IConnectionFactory connectionFactory) - { - _connectionFactory = connectionFactory; - } - - public async Task Handle(InsertTodo request, CancellationToken cancellationToken) - { - using var conn = _connectionFactory.CreateWriteConnection(); - - var recordId = await conn.ExecuteScalarAsync("INSERT INTO todo_list (title, description, due_date) VALUES (@Title, @Description, @DueDate) RETURNING item_id;", request); - - var record = new TodoRecord( - recordId, - request.Title, - request.Description, - request.DueDate); - - return record; - } -} - -public record InsertTodo(string Title, string Description, DateTime DueDate) : IRequest; diff --git a/templates/Template.DbApi/src/Template.DbApi/Handlers/SelectTodoItemsHandler.cs b/templates/Template.DbApi/src/Template.DbApi/Handlers/SelectTodoItemsHandler.cs deleted file mode 100644 index 1d13b6e..0000000 --- a/templates/Template.DbApi/src/Template.DbApi/Handlers/SelectTodoItemsHandler.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Dapper; -using MediatR; -using Microsoft.AspNetCore.Connections; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Template.DbApi.Model; - -namespace Template.DbApi.Handlers; -internal class SelectTodoItemsHandler : IRequestHandler> -{ - private readonly IConnectionFactory _connectionFactory; - - public SelectTodoItemsHandler(IConnectionFactory connectionFactory) - { - _connectionFactory = connectionFactory; - } - - public async Task> Handle(SelectTodo request, CancellationToken cancellationToken) - { - using var conn = _connectionFactory.CreateReadConnection(); - - var items = await conn.QueryAsync("SELECT item_id, title, description, due_date, open, closed_date FROM todo_list WHERE open = true;"); - - // NOTE: This will require pagination to scale. - return items - .Select(d => new TodoRecord(d.item_id, d.title, d.description, d.due_date, d.open, d.closed_date)) - .ToList(); - } -} - -public record SelectTodo() : IRequest>; diff --git a/templates/Template.DbApi/src/Template.DbApi/IConnectionFactory.cs b/templates/Template.DbApi/src/Template.DbApi/IConnectionFactory.cs deleted file mode 100644 index 242c009..0000000 --- a/templates/Template.DbApi/src/Template.DbApi/IConnectionFactory.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Npgsql; -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Common; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Template.DbApi; -public interface IConnectionFactory -{ - IDbConnection CreateWriteConnection(); - - IDbConnection CreateReadConnection(); -} - -public class PostgresConnectionFactory : IConnectionFactory -{ - private readonly string _writeConnectionString; - private readonly string _readConnectionString; - - public PostgresConnectionFactory(string writeConnectionString, string readConnectionString) - { - _writeConnectionString = writeConnectionString; - _readConnectionString = readConnectionString; - } - - public IDbConnection CreateWriteConnection() => new NpgsqlConnection(_writeConnectionString); - public IDbConnection CreateReadConnection() => new NpgsqlConnection(_readConnectionString); -} diff --git a/templates/Template.DbApi/src/Template.DbApi/Model/TodoRecord.cs b/templates/Template.DbApi/src/Template.DbApi/Model/TodoRecord.cs deleted file mode 100644 index 015d3ad..0000000 --- a/templates/Template.DbApi/src/Template.DbApi/Model/TodoRecord.cs +++ /dev/null @@ -1,2 +0,0 @@ -namespace Template.DbApi.Model; -public record TodoRecord(Guid ItemId, string Title, string Description, DateTime DueDate, bool Open = true, DateTime? ClosedDate = null); \ No newline at end of file diff --git a/templates/Template.DbApi/src/Template.DbApi/Template.DbApi.csproj b/templates/Template.DbApi/src/Template.DbApi/Template.DbApi.csproj deleted file mode 100644 index b3a4e20..0000000 --- a/templates/Template.DbApi/src/Template.DbApi/Template.DbApi.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - - - - - diff --git a/templates/Template.DbApi/src/Template.DbApi/Validators/InsertTodoItemValidator.cs b/templates/Template.DbApi/src/Template.DbApi/Validators/InsertTodoItemValidator.cs deleted file mode 100644 index 22f3b9c..0000000 --- a/templates/Template.DbApi/src/Template.DbApi/Validators/InsertTodoItemValidator.cs +++ /dev/null @@ -1,18 +0,0 @@ -using FluentValidation; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Template.DbApi.Handlers; - -namespace Template.DbApi.Validators; -public class InsertTodoValidator : AbstractValidator -{ - public InsertTodoValidator() - { - RuleFor(x => x.Title).NotEmpty().MaximumLength(128); - RuleFor(x => x.Description).NotEmpty().MaximumLength(512); - RuleFor(x => x.DueDate).NotEmpty().Must(m => m.ToUniversalTime().Date >= DateTime.UtcNow.Date).WithMessage("DueDate cannot be in the past."); - } -} diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/CoreTestContext.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/CoreTestContext.cs deleted file mode 100644 index 2919987..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/CoreTestContext.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Polly; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http.Json; -using System.Text; -using System.Threading.Tasks; - -namespace Template.DbApi.AcceptanceTests; -public class CoreTestContext -{ - public string Uri { get; set; } - - public HttpResponseMessage Response { get; set; } - - public AsyncPolicy RetryPolicy { get; } = Policy - .Handle() - .WaitAndRetryAsync(10, i => TimeSpan.FromSeconds(1)); - - public HttpClient CreateClient() - { - return new HttpClient() - { - BaseAddress = new Uri(Uri) - }; - } - - public async Task GetAsync(string path) - { - using var client = CreateClient(); - - Response = await RetryPolicy.ExecuteAsync(async () => { - var result = await client.GetAsync(path); - result.EnsureSuccessStatusCode(); - return result; - }); - } - - public async Task PostAsJsonAsync(string path, T payload) - { - using var client = CreateClient(); - - Response = await RetryPolicy.ExecuteAsync(async () => { - var result = await client.PostAsJsonAsync(path, payload); - result.EnsureSuccessStatusCode(); - return result; - }); - } -} diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/Healthcheck.feature b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/Healthcheck.feature deleted file mode 100644 index db37fca..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/Healthcheck.feature +++ /dev/null @@ -1,13 +0,0 @@ -Feature: Healthchecks - -@healthcheck @api -Scenario: API Healthcheck - Given We have a Application api - When We call the ping endpoint - Then The response should be 200 OK - When We call the healthcheck endpoint - Then The response should be 200 OK - When We call the metrics endpoint - Then The response should be 200 OK - When We call the swagger endpoint - Then The response should be 200 OK diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/Healthcheck.feature.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/Healthcheck.feature.cs deleted file mode 100644 index 6b4aa83..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/Healthcheck.feature.cs +++ /dev/null @@ -1,154 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by SpecFlow (https://www.specflow.org/). -// SpecFlow Version:3.9.0.0 -// SpecFlow Generator Version:3.9.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -namespace Template.DbApi.AcceptanceTests.Features -{ - using TechTalk.SpecFlow; - using System; - using System.Linq; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public partial class HealthchecksFeature : object, Xunit.IClassFixture, System.IDisposable - { - - private static TechTalk.SpecFlow.ITestRunner testRunner; - - private static string[] featureTags = ((string[])(null)); - - private Xunit.Abstractions.ITestOutputHelper _testOutputHelper; - -#line 1 "Healthcheck.feature" -#line hidden - - public HealthchecksFeature(HealthchecksFeature.FixtureData fixtureData, Template_DbApi_AcceptanceTests_XUnitAssemblyFixture assemblyFixture, Xunit.Abstractions.ITestOutputHelper testOutputHelper) - { - this._testOutputHelper = testOutputHelper; - this.TestInitialize(); - } - - public static void FeatureSetup() - { - testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); - TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Healthchecks", null, ProgrammingLanguage.CSharp, featureTags); - testRunner.OnFeatureStart(featureInfo); - } - - public static void FeatureTearDown() - { - testRunner.OnFeatureEnd(); - testRunner = null; - } - - public void TestInitialize() - { - } - - public void TestTearDown() - { - testRunner.OnScenarioEnd(); - } - - public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(_testOutputHelper); - } - - public void ScenarioStart() - { - testRunner.OnScenarioStart(); - } - - public void ScenarioCleanup() - { - testRunner.CollectScenarioErrors(); - } - - void System.IDisposable.Dispose() - { - this.TestTearDown(); - } - - [Xunit.SkippableFactAttribute(DisplayName="API Healthcheck")] - [Xunit.TraitAttribute("FeatureTitle", "Healthchecks")] - [Xunit.TraitAttribute("Description", "API Healthcheck")] - [Xunit.TraitAttribute("Category", "healthcheck")] - [Xunit.TraitAttribute("Category", "api")] - public void APIHealthcheck() - { - string[] tagsOfScenario = new string[] { - "healthcheck", - "api"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("API Healthcheck", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 4 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - this.ScenarioStart(); -#line 5 - testRunner.Given("We have a Application api", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); -#line hidden -#line 6 - testRunner.When("We call the ping endpoint", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line hidden -#line 7 - testRunner.Then("The response should be 200 OK", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden -#line 8 - testRunner.When("We call the healthcheck endpoint", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line hidden -#line 9 - testRunner.Then("The response should be 200 OK", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden -#line 10 - testRunner.When("We call the metrics endpoint", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line hidden -#line 11 - testRunner.Then("The response should be 200 OK", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden -#line 12 - testRunner.When("We call the swagger endpoint", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line hidden -#line 13 - testRunner.Then("The response should be 200 OK", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden - } - this.ScenarioCleanup(); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class FixtureData : System.IDisposable - { - - public FixtureData() - { - HealthchecksFeature.FeatureSetup(); - } - - void System.IDisposable.Dispose() - { - HealthchecksFeature.FeatureTearDown(); - } - } - } -} -#pragma warning restore -#endregion diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/TodoApiFeatures.feature b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/TodoApiFeatures.feature deleted file mode 100644 index 13aa7c9..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/TodoApiFeatures.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: TodoApiFeatures - -Feature test for the Todo list API. - -@todo-list @api -Scenario: Create and View Todo item - Given We have a Application api - When We create task 'New Task' - Then The response should be 200 OK - And The response should contain a new RecordId - When We get our TodoList - Then The response should be 200 OK - And The response should contain a Todo List - Then The result contains the created recordId diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/TodoApiFeatures.feature.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/TodoApiFeatures.feature.cs deleted file mode 100644 index dca67d1..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Features/TodoApiFeatures.feature.cs +++ /dev/null @@ -1,151 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by SpecFlow (https://www.specflow.org/). -// SpecFlow Version:3.9.0.0 -// SpecFlow Generator Version:3.9.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -#region Designer generated code -#pragma warning disable -namespace Template.DbApi.AcceptanceTests.Features -{ - using TechTalk.SpecFlow; - using System; - using System.Linq; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public partial class TodoApiFeaturesFeature : object, Xunit.IClassFixture, System.IDisposable - { - - private static TechTalk.SpecFlow.ITestRunner testRunner; - - private static string[] featureTags = ((string[])(null)); - - private Xunit.Abstractions.ITestOutputHelper _testOutputHelper; - -#line 1 "TodoApiFeatures.feature" -#line hidden - - public TodoApiFeaturesFeature(TodoApiFeaturesFeature.FixtureData fixtureData, Template_DbApi_AcceptanceTests_XUnitAssemblyFixture assemblyFixture, Xunit.Abstractions.ITestOutputHelper testOutputHelper) - { - this._testOutputHelper = testOutputHelper; - this.TestInitialize(); - } - - public static void FeatureSetup() - { - testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); - TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "TodoApiFeatures", "Feature test for the Todo list API.", ProgrammingLanguage.CSharp, featureTags); - testRunner.OnFeatureStart(featureInfo); - } - - public static void FeatureTearDown() - { - testRunner.OnFeatureEnd(); - testRunner = null; - } - - public void TestInitialize() - { - } - - public void TestTearDown() - { - testRunner.OnScenarioEnd(); - } - - public void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) - { - testRunner.OnScenarioInitialize(scenarioInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(_testOutputHelper); - } - - public void ScenarioStart() - { - testRunner.OnScenarioStart(); - } - - public void ScenarioCleanup() - { - testRunner.CollectScenarioErrors(); - } - - void System.IDisposable.Dispose() - { - this.TestTearDown(); - } - - [Xunit.SkippableFactAttribute(DisplayName="Create and View Todo item")] - [Xunit.TraitAttribute("FeatureTitle", "TodoApiFeatures")] - [Xunit.TraitAttribute("Description", "Create and View Todo item")] - [Xunit.TraitAttribute("Category", "todo-list")] - [Xunit.TraitAttribute("Category", "api")] - public void CreateAndViewTodoItem() - { - string[] tagsOfScenario = new string[] { - "todo-list", - "api"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Create and View Todo item", null, tagsOfScenario, argumentsOfScenario, featureTags); -#line 6 -this.ScenarioInitialize(scenarioInfo); -#line hidden - if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) - { - testRunner.SkipScenario(); - } - else - { - this.ScenarioStart(); -#line 7 - testRunner.Given("We have a Application api", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); -#line hidden -#line 8 - testRunner.When("We create task \'New Task\'", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line hidden -#line 9 - testRunner.Then("The response should be 200 OK", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden -#line 10 - testRunner.And("The response should contain a new RecordId", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line hidden -#line 11 - testRunner.When("We get our TodoList", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); -#line hidden -#line 12 - testRunner.Then("The response should be 200 OK", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden -#line 13 - testRunner.And("The response should contain a Todo List", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); -#line hidden -#line 14 - testRunner.Then("The result contains the created recordId", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); -#line hidden - } - this.ScenarioCleanup(); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class FixtureData : System.IDisposable - { - - public FixtureData() - { - TodoApiFeaturesFeature.FeatureSetup(); - } - - void System.IDisposable.Dispose() - { - TodoApiFeaturesFeature.FeatureTearDown(); - } - } - } -} -#pragma warning restore -#endregion diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/CommonStepDefinitions.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/CommonStepDefinitions.cs deleted file mode 100644 index 1360a7e..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/CommonStepDefinitions.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Template.DbApi.AcceptanceTests.StepDefinitions; - -[Binding] -public class CommonStepDefinitions -{ - private readonly CoreTestContext _testContext; - - public CommonStepDefinitions(CoreTestContext testContext) - { - _testContext = testContext; - } - - [Given("We have a Application api")] - public void WeHaveAnApplicationApi() - { - _testContext.Uri - .Should().NotBeNullOrEmpty(); - - Console.WriteLine("Targeting: " + _testContext.Uri); - } - - [Then("The response should be 200 OK")] - public void TheResultShouldBeOk() - { - _testContext.Response - .Should().NotBeNull() - .And - .Subject.EnsureSuccessStatusCode(); - } -} diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/ConfigurationSetup.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/ConfigurationSetup.cs deleted file mode 100644 index b78dfb0..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/ConfigurationSetup.cs +++ /dev/null @@ -1,40 +0,0 @@ -using BoDi; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Configuration.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Template.DbApi.AcceptanceTests.StepDefinitions; -[Binding] -public class ConfigurationSetup -{ - private readonly IObjectContainer objectContainer; - - public ConfigurationSetup(IObjectContainer objectContainer) - { - this.objectContainer = objectContainer; - } - - [BeforeScenario] - public void ConfigureInjection() - { - var env = Environment.GetEnvironmentVariable("env"); - - var settings = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json") - .AddJsonFile($"appsettings.{env}.json", optional: true) - .Build(); - - var context = new CoreTestContext - { - Uri = settings["Apis:Template.DbApi"] - }; - - objectContainer.RegisterInstanceAs(context); - } -} - diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/HealthcheckStepDefinitions.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/HealthcheckStepDefinitions.cs deleted file mode 100644 index 5159231..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/HealthcheckStepDefinitions.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Template.DbApi.AcceptanceTests; - -namespace SpecFlowProject1.StepDefinitions; - -[Binding] -public sealed class HealthcheckStepDefinitions -{ - // For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef - - private readonly CoreTestContext _testContext; - - public HealthcheckStepDefinitions(CoreTestContext testContext) - { - _testContext = testContext; - } - - [When("We call the healthcheck endpoint")] - public async Task WeCallTheHealthcheckEndpoint() - { - await _testContext.GetAsync("_system/health"); - } - - [When("We call the ping endpoint")] - public async Task WeCallThePingEndpoint() - { - await _testContext.GetAsync("_system/ping"); - } - - [When("We call the metrics endpoint")] - public async Task WeCallTheMetricsEndpoint() - { - await _testContext.GetAsync("_system/metrics"); - } - - [When("We call the swagger endpoint")] - public async Task WeCallTheSwaggerEndpoint() - { - await _testContext.GetAsync("swagger/v1/swagger.json"); - } -} diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/TodoApiFeatureStepDefinitions.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/TodoApiFeatureStepDefinitions.cs deleted file mode 100644 index 8af4988..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/StepDefinitions/TodoApiFeatureStepDefinitions.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.ComponentModel; -using System.Net.Http.Json; -using TechTalk.SpecFlow.CommonModels; -using Template.DbApi.AcceptanceTests; - -namespace SpecFlowProject1.StepDefinitions; - -[Binding] -public sealed class TodoApiFeatureStepDefinitions -{ - private readonly CoreTestContext _testContext; - private readonly TodoListTestContext _todoListTestContext; - - public TodoApiFeatureStepDefinitions( - CoreTestContext testContext, - TodoListTestContext todoListTestContext) - { - _testContext = testContext; - _todoListTestContext = todoListTestContext; - } - - [When("We create task '(.*)'")] - public async Task WeCreateATodoItem(string text) - { - var payload = new - { - Title = text, - Description = text, - DueDate = DateTime.Today - }; - - await _testContext.PostAsJsonAsync("TodoList", payload); - } - - [Then("The response should contain a new RecordId")] - public async Task TheResponseShouldContainANewRecordId() - { - var json = await _testContext.Response.Content.ReadAsStringAsync(); - _todoListTestContext.NewTodoItem = JsonConvert.DeserializeObject(json); - - ((string)_todoListTestContext.NewTodoItem - .itemId.Value) - .Should().NotBeNull(); - } - - [When("We get our TodoList")] - public async Task WeGetOurTodoList() - { - await _testContext.GetAsync("TodoList"); - } - - [Then("The response should contain a Todo List")] - public async Task TheResponseShouldContainATodoList() - { - var json = await _testContext.Response.Content.ReadAsStringAsync(); - _todoListTestContext.TaskList = ((JArray)JsonConvert.DeserializeObject(json)) - .Select(j => (dynamic)j) - .ToList(); - } - - [Then("The result contains the created recordId")] - public void TheResultsContainsTheCreatedItemId() - { - var item = _todoListTestContext.NewTodoItem; - var id = item.itemId; - - var match = _todoListTestContext.TaskList - .SingleOrDefault(i => i.itemId == id); - - ((object)match).Should().NotBeNull(); - } -} diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Template.DbApi.AcceptanceTests.csproj b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Template.DbApi.AcceptanceTests.csproj deleted file mode 100644 index d4b2a10..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Template.DbApi.AcceptanceTests.csproj +++ /dev/null @@ -1,64 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - $(UsingMicrosoftNETSdk) - %(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension) - - - - diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/TodoListTestContext.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/TodoListTestContext.cs deleted file mode 100644 index 6235e84..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/TodoListTestContext.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Template.DbApi.AcceptanceTests; - -public class TodoListTestContext -{ - public dynamic NewTodoItem { get; set; } - - public List TaskList { get; set; } -} diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Usings.cs b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Usings.cs deleted file mode 100644 index ebc3a11..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/Usings.cs +++ /dev/null @@ -1,3 +0,0 @@ -global using Xunit; -global using FluentAssertions; -global using TechTalk.SpecFlow; \ No newline at end of file diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/appsettings.ci.json b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/appsettings.ci.json deleted file mode 100644 index 1519676..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/appsettings.ci.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Apis": { - "Template.DbApi": "http://localhost:5080/" - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/appsettings.json b/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/appsettings.json deleted file mode 100644 index befaa67..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.AcceptanceTests/appsettings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Apis": { - "Template.DbApi": "http://localhost:5160/" - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/test/Template.DbApi.Benchmark/Program.cs b/templates/Template.DbApi/test/Template.DbApi.Benchmark/Program.cs deleted file mode 100644 index 7578617..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.Benchmark/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Security.Cryptography; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.ConsoleArguments; -using BenchmarkDotNet.Running; - -namespace Template.DbApi.Benchmark -{ - public class Program - { - public static void Main(string[] args) - { - BenchmarkRunner.Run(typeof(Program).Assembly, args: args); - } - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/test/Template.DbApi.Benchmark/Template.DbApi.Benchmark.csproj b/templates/Template.DbApi/test/Template.DbApi.Benchmark/Template.DbApi.Benchmark.csproj deleted file mode 100644 index 7b6557a..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.Benchmark/Template.DbApi.Benchmark.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - - - - - diff --git a/templates/Template.DbApi/test/Template.DbApi.Benchmark/Tests/ValidatorBenchmark.cs b/templates/Template.DbApi/test/Template.DbApi.Benchmark/Tests/ValidatorBenchmark.cs deleted file mode 100644 index 6d67495..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.Benchmark/Tests/ValidatorBenchmark.cs +++ /dev/null @@ -1,31 +0,0 @@ -using BenchmarkDotNet.Attributes; -using FluentValidation; -using FluentValidation.Results; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Template.DbApi.Handlers; -using Template.DbApi.Validators; - -namespace Template.DbApi.Benchmark.Tests; - -public class ValidatorBenchmark -{ - private readonly InsertTodoValidator subject = new InsertTodoValidator(); - private readonly InsertTodo validPayload; - private readonly InsertTodo invalidPayload; - - public ValidatorBenchmark() - { - validPayload = new InsertTodo("Title", "Description", DateTime.Today); - invalidPayload = new InsertTodo(string.Empty, new string('a', 550), DateTime.Today.AddDays(-1)); - } - - [Benchmark] - public ValidationResult ValidBenchmark() => subject.Validate(validPayload); - - [Benchmark] - public ValidationResult InvalidBenchmark() => subject.Validate(invalidPayload); -} \ No newline at end of file diff --git a/templates/Template.DbApi/test/Template.DbApi.UnitTests/InsertTodoValidatorTests.cs b/templates/Template.DbApi/test/Template.DbApi.UnitTests/InsertTodoValidatorTests.cs deleted file mode 100644 index c1a55a7..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.UnitTests/InsertTodoValidatorTests.cs +++ /dev/null @@ -1,84 +0,0 @@ -using FluentAssertions; -using Template.DbApi.Handlers; -using Template.DbApi.Validators; - -namespace Template.DbApi.UnitTests; - -public class InsertTodoValidatorTests -{ - readonly InsertTodoValidator validator = new InsertTodoValidator(); - - [Fact] - public void CanPassValidRecord() - { - var args = new InsertTodo("Title", "Desc", DateTime.UtcNow.Date); - var result = validator.Validate(args); - result.IsValid.Should().BeTrue(); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - public void TitleCannotBeEmpty(string value) - { - var args = new InsertTodo(value, "Desc", DateTime.UtcNow.Date.AddDays(1)); - var result = validator.Validate(args); - result.IsValid.Should().BeFalse(); - - var error = result.Errors.Single(); - error.PropertyName.Should().Be("Title"); - error.ErrorCode.Should().Be("NotEmptyValidator"); - } - - [Fact] - public void TitleCannotBeOver125() - { - var longString = new string('a', 129); - var args = new InsertTodo(longString, "Desc", DateTime.UtcNow.Date.AddDays(1)); - var result = validator.Validate(args); - result.IsValid.Should().BeFalse(); - - var error = result.Errors.Single(); - error.PropertyName.Should().Be("Title"); - error.ErrorCode.Should().Be("MaximumLengthValidator"); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - public void DescriptionCannotBeEmpty(string value) - { - var args = new InsertTodo("Title", value, DateTime.UtcNow.Date.AddDays(1)); - var result = validator.Validate(args); - result.IsValid.Should().BeFalse(); - - var error = result.Errors.Single(); - error.PropertyName.Should().Be("Description"); - error.ErrorCode.Should().Be("NotEmptyValidator"); - } - - [Fact] - public void DescriptionCannotBeOver512() - { - var longString = new string('a', 513); - var args = new InsertTodo("Title", longString, DateTime.UtcNow.Date.AddDays(1)); - var result = validator.Validate(args); - result.IsValid.Should().BeFalse(); - - var error = result.Errors.Single(); - error.PropertyName.Should().Be("Description"); - error.ErrorCode.Should().Be("MaximumLengthValidator"); - } - - [Fact] - public void DueDateCannotBeInPast() - { - var args = new InsertTodo("Title", "Desc", DateTime.UtcNow.Date.AddDays(-1)); - var result = validator.Validate(args); - result.IsValid.Should().BeFalse(); - - var error = result.Errors.Single(); - error.PropertyName.Should().Be("DueDate"); - error.ErrorMessage.Should().Be("DueDate cannot be in the past."); - } -} \ No newline at end of file diff --git a/templates/Template.DbApi/test/Template.DbApi.UnitTests/Template.DbApi.UnitTests.csproj b/templates/Template.DbApi/test/Template.DbApi.UnitTests/Template.DbApi.UnitTests.csproj deleted file mode 100644 index dbf764b..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.UnitTests/Template.DbApi.UnitTests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - diff --git a/templates/Template.DbApi/test/Template.DbApi.UnitTests/Usings.cs b/templates/Template.DbApi/test/Template.DbApi.UnitTests/Usings.cs deleted file mode 100644 index 8c927eb..0000000 --- a/templates/Template.DbApi/test/Template.DbApi.UnitTests/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file diff --git a/templates/Template.DbApi/.template.config/template.json b/templates/Template.TestedApi/.template.config/template.json similarity index 82% rename from templates/Template.DbApi/.template.config/template.json rename to templates/Template.TestedApi/.template.config/template.json index 24e3af2..67f3552 100644 --- a/templates/Template.DbApi/.template.config/template.json +++ b/templates/Template.TestedApi/.template.config/template.json @@ -2,10 +2,10 @@ "$schema": "http://json.schemastore.org/template", "author": "Tristan Rhodes", "classifications": [ "DotNet Core", "Solution" ], - "identity": "Template.DbApi", - "name": "Database Api", + "identity": "Template.TestedApi", + "name": "Tested Api Template", "description": "Postgres database with API, comes with DbUp, packages as Api and containers.", - "shortName": "Template.DbApi", + "shortName": "Template.TestedApi", "tags": { "language": "C#", "type": "solution" @@ -20,13 +20,13 @@ "type": "derived", "valueSource": "ProjectName", "valueTransform": "chain", - "replaces": "Template.DbApi" + "replaces": "Template.TestedApi" }, "RenameFiles": { "type": "derived", "valueSource": "ProjectName", "valueTransform": "chain", - "fileRename": "Template.DbApi" + "fileRename": "Template.TestedApi" } }, "sources": [ diff --git a/templates/Template.TestedLibrary/.config/dotnet-tools.json b/templates/Template.TestedLibrary/.config/dotnet-tools.json deleted file mode 100644 index 8398ae0..0000000 --- a/templates/Template.TestedLibrary/.config/dotnet-tools.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "cake.tool": { - "version": "3.0.0", - "commands": [ - "dotnet-cake" - ] - }, - "gitversion.tool": { - "version": "5.12.0", - "commands": [ - "dotnet-gitversion" - ] - } - } -} \ No newline at end of file diff --git a/templates/Template.TestedLibrary/.gitattributes b/templates/Template.TestedLibrary/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/templates/Template.TestedLibrary/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/templates/Template.TestedLibrary/.github/workflows/build-and-test-action.yml b/templates/Template.TestedLibrary/.github/workflows/build-and-test-action.yml deleted file mode 100644 index 30f0d75..0000000 --- a/templates/Template.TestedLibrary/.github/workflows/build-and-test-action.yml +++ /dev/null @@ -1,29 +0,0 @@ - -name: Build and Test Template -run-name: Build and Test Project Template - -on: - pull_request: - branches: - - master - -jobs: - Build-And-Test-Template: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - with: - fetch-depth: 0 # This is nescessary so it does not conflict with git-version - - - name: Run cake step - uses: cake-build/cake-action@v1 - with: - script-path: build.cake - target: BuildAndTest - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: TestedLibrary Artifacts - path: ./artifacts/ \ No newline at end of file diff --git a/templates/Template.TestedLibrary/.github/workflows/pack-and-push-action.yml b/templates/Template.TestedLibrary/.github/workflows/pack-and-push-action.yml deleted file mode 100644 index 35670b1..0000000 --- a/templates/Template.TestedLibrary/.github/workflows/pack-and-push-action.yml +++ /dev/null @@ -1,31 +0,0 @@ - -name: Pack and Push Template -run-name: Pack and push project templates - -on: - push: - branches: - - master - -jobs: - Pack-And-Push-Template: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - with: - fetch-depth: 0 # This is nescessary so it does not conflict with git-version - - - name: Run cake step - uses: cake-build/cake-action@v1 - with: - script-path: build.cake - target: PackAndPush - ApiKey: ${{ secrets.NUGET_APIKEY }} - Source: ${{ vars.NUGET_SOURCE }} - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: TestedLibrary Artifacts - path: ./artifacts/ \ No newline at end of file diff --git a/templates/Template.TestedLibrary/.gitignore b/templates/Template.TestedLibrary/.gitignore deleted file mode 100644 index cc69cab..0000000 --- a/templates/Template.TestedLibrary/.gitignore +++ /dev/null @@ -1,364 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Oo]ut/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -**/tools/** -!**/tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd -/tools diff --git a/templates/Template.TestedLibrary/.template.config/template.json b/templates/Template.TestedLibrary/.template.config/template.json index c084e34..42965bf 100644 --- a/templates/Template.TestedLibrary/.template.config/template.json +++ b/templates/Template.TestedLibrary/.template.config/template.json @@ -20,13 +20,13 @@ "type": "derived", "valueSource": "ProjectName", "valueTransform": "chain", - "replaces": "TestedLibrary" + "replaces": "Template.TestedLibrary" }, "RenameFiles": { "type": "derived", "valueSource": "ProjectName", "valueTransform": "chain", - "fileRename": "TestedLibrary" + "fileRename": "Template.TestedLibrary" } }, "sources": [ diff --git a/templates/Template.TestedLibrary/GitVersion.yml b/templates/Template.TestedLibrary/GitVersion.yml deleted file mode 100644 index 9a55472..0000000 --- a/templates/Template.TestedLibrary/GitVersion.yml +++ /dev/null @@ -1,4 +0,0 @@ -# For more on gitversion config: -# https://gitversion.net/docs/reference/configuration - -mode: Mainline \ No newline at end of file diff --git a/templates/Template.TestedLibrary/LICENSE.txt b/templates/Template.TestedLibrary/LICENSE.txt deleted file mode 100644 index c6c9fcb..0000000 --- a/templates/Template.TestedLibrary/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Tristan Rhodes - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/templates/Template.TestedLibrary/README.md b/templates/Template.TestedLibrary/README.md deleted file mode 100644 index bb351e2..0000000 --- a/templates/Template.TestedLibrary/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Readme - -This project was created from a template. - -## Build Output - -All build artifacts are output to the `artifacts` folder in the project root directory. - -- Benchmark Results: `artifacts/TestedLibrary.Benchmark` -- Test Results: `artifacts/TestedLibrary.Tests.trx` -- Package Output: `artifacts/TestedLibrary.{version}.nupkg` - -## Cake - -To run cake steps: `dotnet cake --Target=PackAndPush --Source=https://www.myget.org/F/tr-public/api/v3/index.json --ApiKey={apiKey}` \ No newline at end of file diff --git a/templates/Template.TestedLibrary/TestedLibrary.sln b/templates/Template.TestedLibrary/TestedLibrary.sln deleted file mode 100644 index aa8f710..0000000 --- a/templates/Template.TestedLibrary/TestedLibrary.sln +++ /dev/null @@ -1,53 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33414.496 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8E442588-6798-4F9D-942F-04B52DE0ABD7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{7D9F3553-B04C-491A-B174-ADBD57A833C6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestedLibrary.UnitTests", "test\TestedLibrary.UnitTests\TestedLibrary.UnitTests.csproj", "{2BFEAB9E-11F8-464C-8CF7-8B025D98D45E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestedLibrary", "src\TestedLibrary\TestedLibrary.csproj", "{AC531AF6-986D-41F1-8C9F-74D969890BE8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{6618C5A2-3A53-48FB-ACA5-EC3A355BD1D0}" - ProjectSection(SolutionItems) = preProject - build.cake = build.cake - LICENSE.txt = LICENSE.txt - README.md = README.md - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestedLibrary.Benchmark", "test\TestedLibrary.Benchmark\TestedLibrary.Benchmark.csproj", "{C255C31D-FC66-4F71-ABFE-F9523994F92D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2BFEAB9E-11F8-464C-8CF7-8B025D98D45E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2BFEAB9E-11F8-464C-8CF7-8B025D98D45E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2BFEAB9E-11F8-464C-8CF7-8B025D98D45E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2BFEAB9E-11F8-464C-8CF7-8B025D98D45E}.Release|Any CPU.Build.0 = Release|Any CPU - {AC531AF6-986D-41F1-8C9F-74D969890BE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AC531AF6-986D-41F1-8C9F-74D969890BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC531AF6-986D-41F1-8C9F-74D969890BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AC531AF6-986D-41F1-8C9F-74D969890BE8}.Release|Any CPU.Build.0 = Release|Any CPU - {C255C31D-FC66-4F71-ABFE-F9523994F92D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C255C31D-FC66-4F71-ABFE-F9523994F92D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C255C31D-FC66-4F71-ABFE-F9523994F92D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C255C31D-FC66-4F71-ABFE-F9523994F92D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {2BFEAB9E-11F8-464C-8CF7-8B025D98D45E} = {7D9F3553-B04C-491A-B174-ADBD57A833C6} - {AC531AF6-986D-41F1-8C9F-74D969890BE8} = {8E442588-6798-4F9D-942F-04B52DE0ABD7} - {C255C31D-FC66-4F71-ABFE-F9523994F92D} = {7D9F3553-B04C-491A-B174-ADBD57A833C6} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7AED03EA-EDCA-4E74-BC4D-D91E03842C16} - EndGlobalSection -EndGlobal diff --git a/templates/Template.TestedLibrary/TestedLibrary.v3.ncrunchsolution b/templates/Template.TestedLibrary/TestedLibrary.v3.ncrunchsolution deleted file mode 100644 index f774ab9..0000000 --- a/templates/Template.TestedLibrary/TestedLibrary.v3.ncrunchsolution +++ /dev/null @@ -1,6 +0,0 @@ - - - False - True - - \ No newline at end of file diff --git a/templates/Template.TestedLibrary/build.cake b/templates/Template.TestedLibrary/build.cake deleted file mode 100644 index 7a6dc44..0000000 --- a/templates/Template.TestedLibrary/build.cake +++ /dev/null @@ -1,205 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// ADDINS -/////////////////////////////////////////////////////////////////////////////// -#addin nuget:?package=Cake.Json&version=7.0.1 - -/////////////////////////////////////////////////////////////////////////////// -// TOOLS -/////////////////////////////////////////////////////////////////////////////// -#tool dotnet:?package=GitVersion.Tool&version=5.12.0 - -/////////////////////////////////////////////////////////////////////////////// -// ARGUMENTS -/////////////////////////////////////////////////////////////////////////////// -var target = Argument("target", "Default"); - -var configuration = Argument("configuration", "Release"); - -var packageSource = Argument("Source", null) // Input from cmd args to Cake - ?? EnvironmentVariable("INPUT_SOURCE", null); // Input from GHA to Cake - -var apiKey = Argument("ApiKey", null) // Input from cmd args to Cake - ?? EnvironmentVariable("INPUT_APIKEY", null); // Input from GHA to Cake - -var versionNumber = Argument("VersionOverride", null) // Input from cmd args to Cake - ?? EnvironmentVariable("INPUT_VERSIONOVERRIDE", null); // Input from GHA to Cake - -string artifactsFolder = "./artifacts"; -var packagesFolder = System.IO.Path.Combine(artifactsFolder, "packages"); - -BuildManifest buildManifest; - -/////////////////////////////////////////////////////////////////////////////// -// Setup / Teardown -/////////////////////////////////////////////////////////////////////////////// -Setup(context => -{ - var cakeMixFile = "build.cakemix"; - - // Load BuildManifest - if (!System.IO.File.Exists(cakeMixFile)) - { - Warning("No cakemix file found, creating..."); - - var manifest = new BuildManifest - { - NugetPackages = new string[0], - Tests = System.IO.Directory.GetFiles(".", "*.UnitTests.csproj", SearchOption.AllDirectories), - Benchmarks = System.IO.Directory.GetFiles(".", "*.Benchmark.csproj", SearchOption.AllDirectories) - }; - SerializeJsonToPrettyFile(cakeMixFile, manifest); - } - - buildManifest = DeserializeJsonFromFile(cakeMixFile); - - // Clean artifacts - if (System.IO.Directory.Exists(artifactsFolder)) - System.IO.Directory.Delete(artifactsFolder, true); -}); - -Teardown(context => -{ - -}); - -/////////////////////////////////////////////////////////////////////////////// -// Tasks -/////////////////////////////////////////////////////////////////////////////// -Task("__PackageArgsCheck") - .Does(() => { - if (string.IsNullOrEmpty(packageSource)) - throw new ArgumentException("Source is required"); - - if (string.IsNullOrEmpty(apiKey)) - throw new ArgumentException("ApiKey is required"); - }); - -Task("__UnitTest") - .Does(() => { - - foreach(var test in buildManifest.Tests) - { - Information($"Testing {test}..."); - - var testName = System.IO.Path.GetFileNameWithoutExtension(test); - - var settings = new DotNetTestSettings - { - Configuration = configuration, - ResultsDirectory = artifactsFolder - }; - - // Console log for build agent - settings.Loggers.Add("console;verbosity=normal"); - - // Logging for trx test report artifact - settings.Loggers.Add($"trx;logfilename={testName}.trx"); - - DotNetTest(test, settings); - } - }); - -Task("__Benchmark") - .Does(() => { - - foreach(var benchmark in buildManifest.Benchmarks) - { - Information($"Benchmarking {benchmark}..."); - var benchName = System.IO.Path.GetFileNameWithoutExtension(benchmark); - - var settings = new DotNetRunSettings - { - Configuration = "Release", - ArgumentCustomization = args => { - return args - .Append("--artifacts") - .AppendQuoted(System.IO.Path.Combine(artifactsFolder, benchName)); - } - }; - - DotNetRun(benchmark, settings); - } - }); - -Task("__VersionInfo") - .Does(() => { - - if (string.IsNullOrEmpty(versionNumber)) - { - var version = GitVersion(); - Information("GitVersion Info: " + SerializeJsonPretty(version)); - versionNumber = version.SemVer; - } - - Information("Version Number: " + versionNumber); - }); - -Task("__NugetPack") - .Does(() => { - - foreach(var package in buildManifest.NugetPackages) - { - Information($"Packing {package}..."); - var settings = new DotNetMSBuildSettings - { - PackageVersion = versionNumber - }; - - var packSettings = new DotNetPackSettings - { - Configuration = "Release", - OutputDirectory = packagesFolder, - MSBuildSettings = settings - }; - DotNetPack(package, packSettings); - } - }); - -Task("__NugetPush") - .Does(() => { - - if (!System.IO.Directory.Exists(packagesFolder)) - { - Information("No packages to push in the packages folder"); - return; - } - - var packedArtifacts = System.IO.Directory.EnumerateFiles(packagesFolder); - foreach(var package in packedArtifacts) - { - Information($"Pushing {package}..."); - var pushSettings = new DotNetNuGetPushSettings - { - Source = packageSource, - ApiKey = apiKey - }; - DotNetNuGetPush(package, pushSettings); - } - }); - -Task("BuildAndTest") - .IsDependentOn("__UnitTest"); - -Task("BuildAndBenchmark") - .IsDependentOn("__Benchmark"); - -Task("PackAndPush") - .IsDependentOn("__PackageArgsCheck") - .IsDependentOn("__VersionInfo") - .IsDependentOn("__UnitTest") - .IsDependentOn("__Benchmark") - .IsDependentOn("__NugetPack") - .IsDependentOn("__NugetPush"); - -Task("Default") - .IsDependentOn("__UnitTest") - .IsDependentOn("__Benchmark"); - -RunTarget(target); - -public class BuildManifest -{ - public string[] NugetPackages { get; set; } - public string[] Tests { get; set; } - public string[] Benchmarks { get; set; } -} diff --git a/templates/Template.TestedLibrary/build.cakemix b/templates/Template.TestedLibrary/build.cakemix deleted file mode 100644 index 0606634..0000000 --- a/templates/Template.TestedLibrary/build.cakemix +++ /dev/null @@ -1,9 +0,0 @@ -{ - "NugetPackages": [], - "Tests": [ - ".\\test\\TestedLibrary.UnitTests\\TestedLibrary.UnitTests.csproj" - ], - "Benchmarks": [ - ".\\test\\TestedLibrary.Benchmark\\TestedLibrary.Benchmark.csproj" - ] -} \ No newline at end of file diff --git a/templates/Template.TestedLibrary/src/TestedLibrary/MyClass.cs b/templates/Template.TestedLibrary/src/TestedLibrary/MyClass.cs deleted file mode 100644 index 6f4b6d1..0000000 --- a/templates/Template.TestedLibrary/src/TestedLibrary/MyClass.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TestedLibrary; - -public class MyClass -{ - public int Multiply(int x, int y) => - x * y; -} diff --git a/templates/Template.TestedLibrary/src/TestedLibrary/TestedLibrary.csproj b/templates/Template.TestedLibrary/src/TestedLibrary/TestedLibrary.csproj deleted file mode 100644 index 132c02c..0000000 --- a/templates/Template.TestedLibrary/src/TestedLibrary/TestedLibrary.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net6.0 - enable - enable - - - diff --git a/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/Program.cs b/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/Program.cs deleted file mode 100644 index 7a3dbcd..0000000 --- a/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Security.Cryptography; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.ConsoleArguments; -using BenchmarkDotNet.Running; - -namespace MyBenchmarks -{ - public class Program - { - public static void Main(string[] args) - { - BenchmarkRunner.Run(typeof(Program).Assembly, args: args); - } - } -} \ No newline at end of file diff --git a/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/TestedLibrary.Benchmark.csproj b/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/TestedLibrary.Benchmark.csproj deleted file mode 100644 index 27346ba..0000000 --- a/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/TestedLibrary.Benchmark.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - - - - diff --git a/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/Tests/MyClassBenchmark.cs b/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/Tests/MyClassBenchmark.cs deleted file mode 100644 index 74a16b9..0000000 --- a/templates/Template.TestedLibrary/test/TestedLibrary.Benchmark/Tests/MyClassBenchmark.cs +++ /dev/null @@ -1,24 +0,0 @@ -using BenchmarkDotNet.Attributes; -using TestedLibrary; - -namespace TestedLibrary.Benchmark.Tests -{ - public class MyClassBenchmark - { - private readonly MyClass subject = new MyClass(); - private readonly int _smallNumber; - private readonly int _largeNumber; - - public MyClassBenchmark() - { - _smallNumber = Random.Shared.Next(1, 100); - _largeNumber = Random.Shared.Next(1000000, 10000000); - } - - [Benchmark] - public int SmallMultiply() => subject.Multiply(_smallNumber, _smallNumber); - - [Benchmark] - public int LargeMultiply() => subject.Multiply(_largeNumber, _largeNumber); - } -} \ No newline at end of file diff --git a/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/MyClassTests.cs b/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/MyClassTests.cs deleted file mode 100644 index e018e16..0000000 --- a/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/MyClassTests.cs +++ /dev/null @@ -1,18 +0,0 @@ -using FluentAssertions; - -namespace TestedLibrary.UnitTests; - -public class MyClassTests -{ - MyClass subject = new MyClass(); - - [Theory] - [InlineData(1, 2, 2)] - [InlineData(2, 2, 4)] - [InlineData(5, 10, 50)] - public void MultiplicationTest(int x, int y, int expected) - { - var result = subject.Multiply(x, y); - result.Should().Be(expected); - } -} \ No newline at end of file diff --git a/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/TestedLibrary.UnitTests.csproj b/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/TestedLibrary.UnitTests.csproj deleted file mode 100644 index 2abc8aa..0000000 --- a/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/TestedLibrary.UnitTests.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/Usings.cs b/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/Usings.cs deleted file mode 100644 index 8c927eb..0000000 --- a/templates/Template.TestedLibrary/test/TestedLibrary.UnitTests/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file