diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b0401f2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories + +# C# or VB files +[*.{cs,vb,ts,tsx}] +guidelines = 120 + +#### Core EditorConfig Options #### + +#Formatting - header template +file_header_template = ---------------------------------------------------------------\nCopyright (c) North East London ICB. All rights reserved.\n--------------------------------------------------------------- + +#sort System.* using directives alphabetically, and place them before other usings +dotnet_sort_system_directives_first = true + diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# 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/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..87d79c2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "nuget" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + commit-message: + prefix: "CONFIG" + labels: + - "dependencies" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c1e0a78 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,114 @@ +name: Build +on: + push: + branches: + - main + pull_request: + types: + - opened + - synchronize + - reopened + - closed + branches: + - main +env: + IS_RELEASE_CANDIDATE: >- + ${{ + ( + github.event_name == 'pull_request' && + startsWith(github.event.pull_request.title, 'RELEASES:') && + contains(github.event.pull_request.labels.*.name, 'RELEASES') + ) + || + ( + github.event_name == 'push' && + startsWith(github.event.head_commit.message, 'RELEASES:') && + github.ref_name == 'RELEASE' + ) + }} +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check Out + uses: actions/checkout@v3 + - name: Setup Dot Net Version + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.201 + - name: Restore + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal + add_tag: + runs-on: ubuntu-latest + needs: + - build + if: > + needs.build.result == 'success' && + github.event.pull_request.merged && + github.event.pull_request.base.ref == 'main' && + startsWith(github.event.pull_request.title, 'RELEASES:') && + contains(github.event.pull_request.labels.*.name, 'RELEASES') + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Extract Version Number + id: extract_version + run: |- + echo "version_number=$(grep -oP '(?<=)[^<]+' NEL.LibPostalClient.Infrastructure/NEL.LibPostalClient.Infrastructure.csproj)" >> $GITHUB_OUTPUT + echo "package_release_notes=$(grep -oP '(?<=)[^<]+' NEL.MESH/NEL.MESH.csproj)" >> $GITHUB_OUTPUT + - name: Print Version Number + run: |- + echo "Release version - ${{ steps.extract_version.outputs.version_number }}" + echo "Release notes - ${{ steps.extract_version.outputs.package_release_notes }}" + - name: Configure Git + run: |- + git config user.name "GitHub Action" + git config user.email "action@github.com" + - name: Authenticate with GitHub + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT_FOR_TAGGING }} + - name: Add Release Tag + run: |- + git tag -a "v${{ steps.extract_version.outputs.version_number }}" -m "Release - v${{ steps.extract_version.outputs.version_number }}" + git push origin --tags + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.PAT_FOR_TAGGING }} + with: + tag_name: "v${{ steps.extract_version.outputs.version_number }}" + release_name: "Release - v${{ steps.extract_version.outputs.version_number }}" + body: | + ### Release - v${{ steps.extract_version.outputs.version_number }} + + #### Release Notes + ${{ steps.extract_version.outputs.package_release_notes }} + publish: + runs-on: ubuntu-latest + needs: + - add_tag + if: needs.add_tag.result == 'success' + steps: + - name: Check out + uses: actions/checkout@v3 + - name: Setup .Net + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.201 + - name: Restore + run: dotnet restore + - name: Build Release + run: dotnet build --no-restore --configuration Release + - name: Pack Nuget + run: dotnet pack --configuration Release + env: + NUGET_KEY: ${{ secrets.NUGET_API_KEY }} + - name: Release Task + run: + dotnet nuget push **/bin/Release/**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} diff --git a/.gitignore b/.gitignore index 8a30d25..340b54e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ ## 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/main/VisualStudio.gitignore +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.rsuser @@ -9,6 +9,10 @@ *.user *.userosscache *.sln.docstates +*.mp4 + +# Local Configuration Files +local.settings.json # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs @@ -90,7 +94,6 @@ StyleCopReport.xml *.tmp_proj *_wpftmp.csproj *.log -*.tlog *.vspscc *.vssscc .builds @@ -294,17 +297,6 @@ node_modules/ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) *.vbw -# Visual Studio 6 auto-generated project file (contains which files were open etc.) -*.vbp - -# Visual Studio 6 workspace and project file (working project files containing files to include in project) -*.dsw -*.dsp - -# Visual Studio 6 technical files -*.ncb -*.aps - # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts @@ -361,9 +353,6 @@ ASALocalRun/ # Local History for Visual Studio .localhistory/ -# Visual Studio History (VSHistory) files -.vshistory/ - # BeatPulse healthcheck temp database healthchecksdb @@ -376,23 +365,11 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd -# VS Code files for those working on multiple tools -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ - -# Windows Installer files from build outputs -*.cab -*.msi -*.msix -*.msm -*.msp - -# JetBrains Rider -*.sln.iml +# Local Settings +local.settings.json +local.appsettings.json +*/local.settings.json +*/local.appsettings.json +/NEL.MESH.Tests.Acceptance/local.appsettings.integration.json +/NEL.MESH.Tests.Integration/local.appsettings.integration.json +/NEL.MESH.Tests.Integration/local.appsettings.acceptance.json diff --git a/NEL.LibPostalClient.Infrastructure.Tests.Acceptance/NEL.LibPostalClient.Infrastructure.Tests.Acceptance.csproj b/NEL.LibPostalClient.Infrastructure.Tests.Acceptance/NEL.LibPostalClient.Infrastructure.Tests.Acceptance.csproj new file mode 100644 index 0000000..f76bed0 --- /dev/null +++ b/NEL.LibPostalClient.Infrastructure.Tests.Acceptance/NEL.LibPostalClient.Infrastructure.Tests.Acceptance.csproj @@ -0,0 +1,44 @@ + + + + net7.0 + disable + enable + false + true + Debug;Release;Test;Acceptance + + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + Always + + + + + diff --git a/NEL.LibPostalClient.Infrastructure.Tests.Unit/NEL.LibPostalClient.Infrastructure.Tests.Unit.csproj b/NEL.LibPostalClient.Infrastructure.Tests.Unit/NEL.LibPostalClient.Infrastructure.Tests.Unit.csproj new file mode 100644 index 0000000..4d2876b --- /dev/null +++ b/NEL.LibPostalClient.Infrastructure.Tests.Unit/NEL.LibPostalClient.Infrastructure.Tests.Unit.csproj @@ -0,0 +1,43 @@ + + + + net7.0 + disable + enable + false + true + Debug;Release;Test;Acceptance + + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + Always + + + + diff --git a/NEL.LibPostalClient.Infrastructure/NEL.LibPostalClient.Infrastructure.csproj b/NEL.LibPostalClient.Infrastructure/NEL.LibPostalClient.Infrastructure.csproj new file mode 100644 index 0000000..6d4060f --- /dev/null +++ b/NEL.LibPostalClient.Infrastructure/NEL.LibPostalClient.Infrastructure.csproj @@ -0,0 +1,16 @@ + + + + Exe + net7.0 + enable + enable + false + false + + + + + + + diff --git a/NEL.LibPostalClient.Infrastructure/Program.cs b/NEL.LibPostalClient.Infrastructure/Program.cs new file mode 100644 index 0000000..4692d81 --- /dev/null +++ b/NEL.LibPostalClient.Infrastructure/Program.cs @@ -0,0 +1,17 @@ +// --------------------------------------------------------------- +// Copyright (c) North East London ICB. All rights reserved. +// --------------------------------------------------------------- + +using NEL.LibPostalClient.Infrastructure.Services; + +namespace NEL.LibPostalClient.Infrastructure +{ + internal class Program + { + static void Main(string[] args) + { + var scriptGenerationService = new ScriptGenerationService(); + scriptGenerationService.GenerateBuildScript(); + } + } +} \ No newline at end of file diff --git a/NEL.LibPostalClient.Infrastructure/Services/ScriptGenerationService.cs b/NEL.LibPostalClient.Infrastructure/Services/ScriptGenerationService.cs new file mode 100644 index 0000000..adc0323 --- /dev/null +++ b/NEL.LibPostalClient.Infrastructure/Services/ScriptGenerationService.cs @@ -0,0 +1,94 @@ +// --------------------------------------------------------------- +// Copyright (c) North East London ICB. All rights reserved. +// --------------------------------------------------------------- + +using ADotNet.Clients; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV1s; + +namespace NEL.LibPostalClient.Infrastructure.Services +{ + internal class ScriptGenerationService + { + private readonly ADotNetClient adotNetClient; + + public ScriptGenerationService() => + this.adotNetClient = new ADotNetClient(); + + public void GenerateBuildScript() + { + var githubPipeline = new GithubPipeline + { + Name = ".Net", + + OnEvents = new Events + { + Push = new PushEvent + { + Branches = new string[] { "main" } + }, + + PullRequest = new PullRequestEvent + { + Branches = new string[] { "main" } + } + }, + + Jobs = new Jobs + { + Build = new BuildJob + { + RunsOn = BuildMachines.WindowsLatest, + + Steps = new List + { + new CheckoutTaskV2 + { + Name = "Check Out" + }, + + new SetupDotNetTaskV1 + { + Name = "Setup Dot Net Version", + + TargetDotNetVersion = new TargetDotNetVersion + { + DotNetVersion = "7.0.201", + IncludePrerelease = false + } + }, + + new RestoreTask + { + Name = "Restore" + }, + + new DotNetBuildTask + { + Name = "Build" + }, + + new TestTask + { + Name = "Test" + } + } + } + } + }; + + string buildScriptPath = "../../../../.github/workflows/build.yml"; + string directoryPath = Path.GetDirectoryName(buildScriptPath); + + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + this.adotNetClient.SerializeAndWriteToFile( + githubPipeline, + path: buildScriptPath); + } + } +} diff --git a/NEL.LibPostalClient.sln b/NEL.LibPostalClient.sln new file mode 100644 index 0000000..46fdcc4 --- /dev/null +++ b/NEL.LibPostalClient.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34202.233 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NEL.LibPostalClient", "NEL.LibPostalClient\NEL.LibPostalClient.csproj", "{8F716F8C-89E2-4B11-8220-234499B00A33}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NEL.LibPostalClient.Infrastructure", "NEL.LibPostalClient.Infrastructure\NEL.LibPostalClient.Infrastructure.csproj", "{B99B5798-18E4-4DD9-8CDB-A08F6B89CA19}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEL.LibPostalClient.Infrastructure.Tests.Unit", "NEL.LibPostalClient.Infrastructure.Tests.Unit\NEL.LibPostalClient.Infrastructure.Tests.Unit.csproj", "{7184373C-6377-4A12-8C05-95C2B87D56F5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEL.LibPostalClient.Infrastructure.Tests.Acceptance", "NEL.LibPostalClient.Infrastructure.Tests.Acceptance\NEL.LibPostalClient.Infrastructure.Tests.Acceptance.csproj", "{AB0D7591-3461-4E2B-BA6B-08A0063F9D50}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8F716F8C-89E2-4B11-8220-234499B00A33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F716F8C-89E2-4B11-8220-234499B00A33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F716F8C-89E2-4B11-8220-234499B00A33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F716F8C-89E2-4B11-8220-234499B00A33}.Release|Any CPU.Build.0 = Release|Any CPU + {B99B5798-18E4-4DD9-8CDB-A08F6B89CA19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B99B5798-18E4-4DD9-8CDB-A08F6B89CA19}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B99B5798-18E4-4DD9-8CDB-A08F6B89CA19}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B99B5798-18E4-4DD9-8CDB-A08F6B89CA19}.Release|Any CPU.Build.0 = Release|Any CPU + {7184373C-6377-4A12-8C05-95C2B87D56F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7184373C-6377-4A12-8C05-95C2B87D56F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7184373C-6377-4A12-8C05-95C2B87D56F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7184373C-6377-4A12-8C05-95C2B87D56F5}.Release|Any CPU.Build.0 = Release|Any CPU + {AB0D7591-3461-4E2B-BA6B-08A0063F9D50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AB0D7591-3461-4E2B-BA6B-08A0063F9D50}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AB0D7591-3461-4E2B-BA6B-08A0063F9D50}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AB0D7591-3461-4E2B-BA6B-08A0063F9D50}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {48B8B835-3204-4034-8944-F129304C43D1} + EndGlobalSection +EndGlobal diff --git a/NEL.LibPostalClient/License.txt b/NEL.LibPostalClient/License.txt new file mode 100644 index 0000000..50db861 --- /dev/null +++ b/NEL.LibPostalClient/License.txt @@ -0,0 +1 @@ +Copyright (c) North East London ICB. All rights reserved. diff --git a/NEL.LibPostalClient/NEL.LibPostalClient.csproj b/NEL.LibPostalClient/NEL.LibPostalClient.csproj new file mode 100644 index 0000000..9c12afb --- /dev/null +++ b/NEL.LibPostalClient/NEL.LibPostalClient.csproj @@ -0,0 +1,47 @@ + + + + net7.0 + disable + enable + LibPostal Client + Christo du Toit + NEL ICB + .NET Client wrapper for LibPostal that provides address parsing and normalisation capabilities. + Copyright (c) NEL ICB + true + true + LibPostalClient.png + + 1.0.0.0 + 1.0.0.0 + 1.0.0.0 + en-US + + https://github.com/TowerHamletsCCG/MeshClient + License.txt + https://github.com/TowerHamletsCCG/MeshClient + Github + .NET Client LibPostal + A .NET Client to parse and normalise unstructured adrresses + + + + + True + + + + True + + + + + + + + + + + + diff --git a/NEL.LibPostalClient/Resources/LibPostalClient.png b/NEL.LibPostalClient/Resources/LibPostalClient.png new file mode 100644 index 0000000..8e38ba6 Binary files /dev/null and b/NEL.LibPostalClient/Resources/LibPostalClient.png differ