Skip to content

Commit

Permalink
Squashed history that preceded this repo going public
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveRMaltby committed Oct 16, 2023
1 parent 838aaa4 commit 35025d9
Show file tree
Hide file tree
Showing 171 changed files with 9,809 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/UpdateVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
param
(
[Parameter(Position=0, Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$buildNumber
)

if([string]::IsNullOrWhiteSpace($buildNumber)){
throw "Please specify the version build number to be used"
}

function Update-CsprojFile {

param (
[Parameter(Position=0, Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$csprojFile,
[Parameter(Position=1, Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$buildNumber
)

$csprojXml = [xml](get-content ($csprojFile))

$versionNode = $csprojXml.Project.PropertyGroup.Version
if ($versionNode -eq $null) {
# create version node if it doesn't exist

$versionNode = $csprojXml.CreateElement("Version")
$csprojXml.Project.PropertyGroup.AppendChild($versionNode) > $null
#Write-Host "Version XML element added to the PropertyGroup of $($csprojFile)"

$version = "1.0.0"
}
else
{
#Write-Host "Version XML element found in the PropertyGroup of $($csprojFile)"
$version = $versionNode
}

$index = $version.LastIndexOf('.')
if ($index -eq -1) {
throw "$version isn't in the expected build format. $version = $($version))"
}

$version = $version.Substring(0, $index + 1) + $buildNumber

Write-Host "Stamping $($csproj) with version number $($version)"

$csprojXml.Project.PropertyGroup.Version = $version


$csprojXml.Save($csprojFile)
}

#Enumerate the csproj files that are under .\src (exclude 3rdParty folder)
Get-ChildItem "./src" -Exclude "3rdParty" |
ForEach-Object {

Get-ChildItem $_.FullName -Include *.csproj -Recurse |
ForEach-Object {
Update-CsprojFile $_.FullName $buildNumber
}
}
94 changes: 94 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build

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

env:
BuildConfiguration: Release
CoreId: SqlBuildingBlocks.Core
GrammarsAnsiSQLId: SqlBuildingBlocks.Grammars.AnsiSQL
GrammarsMySQLId: SqlBuildingBlocks.Grammars.MySQL
GrammarsPostgreSQLId: SqlBuildingBlocks.Grammars.PostgreSQL
GrammarsSQLServerId: SqlBuildingBlocks.Grammars.SQLServer
PackageVersion: 1.0.0.${{github.run_number}}

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x

- name: Set version number
run: '& ${{github.workspace}}/.github/workflows/UpdateVersion.ps1 ${{github.run_number}}'
shell: pwsh

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore --configuration $BuildConfiguration


- name: Test
run: dotnet test --configuration $BuildConfiguration --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Create nuget packages
run: dotnet pack --configuration $BuildConfiguration --no-build

- uses: actions/upload-artifact@v3
with:
name: Nuget Packages
path: ${{github.workspace}}/src/**/*.nupkg

- name: Push to nuget.org (Core)
if: github.ref == 'refs/heads/main'
run: dotnet nuget push ${{github.workspace}}/src/bin/$BuildConfiguration/$CoreId.$PackageVersion.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_ORG_API_KEY }} --skip-duplicate

- name: Push to nuget.org (Grammars.AnsiSQL)
if: github.ref == 'refs/heads/main'
run: dotnet nuget push ${{github.workspace}}/src/bin/$BuildConfiguration/$GrammarsAnsiSQLId.$PackageVersion.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_ORG_API_KEY }} --skip-duplicate

- name: Push to nuget.org (Grammars.MySQL)
if: github.ref == 'refs/heads/main'
run: dotnet nuget push ${{github.workspace}}/src/bin/$BuildConfiguration/$GrammarsMySQLId.$PackageVersion.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_ORG_API_KEY }} --skip-duplicate

- name: Push to nuget.org (Grammars.PostgreSQL)
if: github.ref == 'refs/heads/main'
run: dotnet nuget push ${{github.workspace}}/src/bin/$BuildConfiguration/$GrammarsPostgreSQLId.$PackageVersion.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_ORG_API_KEY }} --skip-duplicate

- name: Push to nuget.org (Grammars.SQLServer)
if: github.ref == 'refs/heads/main'
run: dotnet nuget push ${{github.workspace}}/src/bin/$BuildConfiguration/$GrammarsSQLServerId.$PackageVersion.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_ORG_API_KEY }} --skip-duplicate

- name: Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
continue-on-error: true
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '40 60'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md


19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

packages
[Bb]in/
[Oo]bj/
[Dd]ebug/
*.suo
.vs
*.user
*.nupkg
*.tokens
.sonar
*.resources.dll
*.metaproj
*.metaproj.tmp


1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @DaveRMaltby @piotrpekala7 @JettPope @PeterSchlenker
24 changes: 24 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project>

<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<IncludeSource>true</IncludeSource>
<IsPackable>false</IsPackable>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<BaseArtifactsPath>$(MSBuildThisFileDirectory)artifacts</BaseArtifactsPath>
<DefaultArtifactsFileMatch>*.nupkg *.snupkg</DefaultArtifactsFileMatch>
<DelaySign>false</DelaySign>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Condition="'$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>

<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.0.36" />

</Project>
21 changes: 21 additions & 0 deletions Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project>

<ItemGroup>
<PackageReference Update="Irony" Version="1.1.0" />
<PackageReference Update="System.ValueTuple" Version="4.5.0" />

<!-- Unit Tests -->
<PackageReference Update="FluentAssertions" Version="6.11.0" />
<PackageReference Update="Moq" Version="4.18.4" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Update="xunit" Version="2.4.2" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Update="coverlet.collector" Version="3.0.2" />
<PackageReference Update="coverlet.msbuild" Version="3.0.2" />
<PackageReference Update="XunitXml.TestLogger" Version="3.0.70" />
<PackageReference Update="BenchmarkDotNet" Version="0.13.4" />
</ItemGroup>
</Project>



41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# SqlBuildingBlocks
Extensible SQL parsing library for multiple databases based on Irony's SQLGrammar.

## Project Status
**IMPORTANT NOTE:** This project is currently under development and not yet viable for production use. It is a work in progress, and we appreciate your patience and interest.

## Overview
SqlBuildingBlocks is an extensible open-source library, designed to parse SQL into manageable, logical classes tailored to different database technologies. It's built upon Irony's SQLGrammar example and leverages design patterns like Factory and Strategy for customization of SQL parsing, making it an excellent tool for working with SQL across multiple databases.

## Project Objectives
- **Extensibility**: Cater to various database technologies by providing specialized grammars.
- **Usability**: Represent complex SQL grammar in a more manageable, logical, and user-friendly format.
- **Testability**: Offer a strong unit-testing framework to ensure the reliability of the code.

## How It Works
SqlBuildingBlocks breaks down SQL into fundamental 'building blocks', or NonTerminal classes, each of which can handle a specific part of the SQL language. These NonTerminal classes use a factory pattern to create 'logical' classes that represent the elements of the SQL language.

## Future Developments
Our roadmap for SqlBuildingBlocks includes developing custom grammars for popular database technologies such as SQL Server, MySQL and PostgreSQL. Furthermore, we are working on a general all-purpose query engine which is still in its infancy. Stay tuned for these exciting updates!

## Contributing
We're open to contributions from the community. More details about how to contribute will be shared soon. In the meantime, feel free to explore the repository, and we appreciate your patience.

## License
This project is licensed under the terms of the MIT license. For more information, please see the [LICENSE](LICENSE) file.

## Installation
Install builds via Nuget.

| Package Name | Release (NuGet) |
|--------------------------------|-----------------|
| `SqlBuildingBlocks.Core` | [![NuGet](https://img.shields.io/nuget/v/SqlBuildingBlocks.Core.svg)](https://www.nuget.org/packages/SqlBuildingBlocks.Core/)
| `SqlBuildingBlocks.Grammars.AnsiSQL` | [![NuGet](https://img.shields.io/nuget/v/SqlBuildingBlocks.Grammars.AnsiSQL.svg)](https://www.nuget.org/packages/SqlBuildingBlocks.Grammars.AnsiSQL/)
| `SqlBuildingBlocks.Grammars.MySQL` | [![NuGet](https://img.shields.io/nuget/v/SqlBuildingBlocks.Grammars.MySQL.svg)](https://www.nuget.org/packages/SqlBuildingBlocks.Grammars.MySQL/)
| `SqlBuildingBlocks.Grammars.PostgreSQL` | [![NuGet](https://img.shields.io/nuget/v/SqlBuildingBlocks.Grammars.PostgreSQL.svg)](https://www.nuget.org/packages/SqlBuildingBlocks.Grammars.PostgreSQL/)
| `SqlBuildingBlocks.Grammars.SQLServer` | [![NuGet](https://img.shields.io/nuget/v/SqlBuildingBlocks.Grammars.SQLServer.svg)](https://www.nuget.org/packages/SqlBuildingBlocks.Grammars.SQLServer/)


## Contact
For any inquiries or issues related to SqlBuildingBlocks, please open an issue on GitHub, and we'll do our best to respond promptly.

We're excited to embark on this journey with the community and look forward to seeing SqlBuildingBlocks grow! Stay tuned for more updates as the project progresses.
93 changes: 93 additions & 0 deletions SqlBuildingBlocks.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Core", "src\Core\SqlBuildingBlocks.Core.csproj", "{79FBCB53-4784-4896-8E78-B678C0E6ACEC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{83B9C7C1-A4ED-49E4-988F-89E3423313EB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Core.Tests", "tests\Core.Tests\SqlBuildingBlocks.Core.Tests.csproj", "{FDB8AF1D-3F96-4F4E-8B46-2D14F3321A00}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Grammars.AnsiSQL", "src\Grammars\AnsiSQL\SqlBuildingBlocks.Grammars.AnsiSQL.csproj", "{28F393D0-DF3B-4AEE-9993-8390D1BC066C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Grammars.SQLServer", "src\Grammars\SQLServer\SqlBuildingBlocks.Grammars.SQLServer.csproj", "{F77B4E33-B9A1-488A-B2ED-F130C53D6F1C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Grammars.MySQL", "src\Grammars\MySQL\SqlBuildingBlocks.Grammars.MySQL.csproj", "{2753F5AA-5A7E-4B82-BA71-79AD7C81F6FF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8CFE6E37-04D7-4599-97FB-7D2F1F189CE3}"
ProjectSection(SolutionItems) = preProject
Packages.props = Packages.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Grammars.PostgreSQL", "src\Grammars\PostgreSQL\SqlBuildingBlocks.Grammars.PostgreSQL.csproj", "{44827791-6AFA-4240-8307-EB16AE8E6257}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Grammars.AnsiSQL.Tests", "tests\Grammars\AnsiSQL.Tests\SqlBuildingBlocks.Grammars.AnsiSQL.Tests.csproj", "{5F7DFB56-3A46-437E-A8D7-4F0A5853CBCD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Grammars.MySQL.Tests", "tests\Grammars\MySQL.Tests\SqlBuildingBlocks.Grammars.MySQL.Tests.csproj", "{9182BAE0-0023-4E48-830F-184A3E3DFB89}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Grammars.PostgreSQL.Tests", "tests\Grammars\PostgreSQL.Tests\SqlBuildingBlocks.Grammars.PostgreSQL.Tests.csproj", "{B377CC60-B4BC-4A89-9856-553711690127}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlBuildingBlocks.Grammars.SQLServer.Tests", "tests\Grammars\SQLServer.Tests\SqlBuildingBlocks.Grammars.SQLServer.Tests.csproj", "{7BB67ECA-F6A6-4BB5-9DCB-0D9BFB710B19}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{79FBCB53-4784-4896-8E78-B678C0E6ACEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{79FBCB53-4784-4896-8E78-B678C0E6ACEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79FBCB53-4784-4896-8E78-B678C0E6ACEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79FBCB53-4784-4896-8E78-B678C0E6ACEC}.Release|Any CPU.Build.0 = Release|Any CPU
{FDB8AF1D-3F96-4F4E-8B46-2D14F3321A00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDB8AF1D-3F96-4F4E-8B46-2D14F3321A00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDB8AF1D-3F96-4F4E-8B46-2D14F3321A00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDB8AF1D-3F96-4F4E-8B46-2D14F3321A00}.Release|Any CPU.Build.0 = Release|Any CPU
{28F393D0-DF3B-4AEE-9993-8390D1BC066C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28F393D0-DF3B-4AEE-9993-8390D1BC066C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28F393D0-DF3B-4AEE-9993-8390D1BC066C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28F393D0-DF3B-4AEE-9993-8390D1BC066C}.Release|Any CPU.Build.0 = Release|Any CPU
{F77B4E33-B9A1-488A-B2ED-F130C53D6F1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F77B4E33-B9A1-488A-B2ED-F130C53D6F1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F77B4E33-B9A1-488A-B2ED-F130C53D6F1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F77B4E33-B9A1-488A-B2ED-F130C53D6F1C}.Release|Any CPU.Build.0 = Release|Any CPU
{2753F5AA-5A7E-4B82-BA71-79AD7C81F6FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2753F5AA-5A7E-4B82-BA71-79AD7C81F6FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2753F5AA-5A7E-4B82-BA71-79AD7C81F6FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2753F5AA-5A7E-4B82-BA71-79AD7C81F6FF}.Release|Any CPU.Build.0 = Release|Any CPU
{44827791-6AFA-4240-8307-EB16AE8E6257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44827791-6AFA-4240-8307-EB16AE8E6257}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44827791-6AFA-4240-8307-EB16AE8E6257}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44827791-6AFA-4240-8307-EB16AE8E6257}.Release|Any CPU.Build.0 = Release|Any CPU
{5F7DFB56-3A46-437E-A8D7-4F0A5853CBCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F7DFB56-3A46-437E-A8D7-4F0A5853CBCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F7DFB56-3A46-437E-A8D7-4F0A5853CBCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F7DFB56-3A46-437E-A8D7-4F0A5853CBCD}.Release|Any CPU.Build.0 = Release|Any CPU
{9182BAE0-0023-4E48-830F-184A3E3DFB89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9182BAE0-0023-4E48-830F-184A3E3DFB89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9182BAE0-0023-4E48-830F-184A3E3DFB89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9182BAE0-0023-4E48-830F-184A3E3DFB89}.Release|Any CPU.Build.0 = Release|Any CPU
{B377CC60-B4BC-4A89-9856-553711690127}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B377CC60-B4BC-4A89-9856-553711690127}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B377CC60-B4BC-4A89-9856-553711690127}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B377CC60-B4BC-4A89-9856-553711690127}.Release|Any CPU.Build.0 = Release|Any CPU
{7BB67ECA-F6A6-4BB5-9DCB-0D9BFB710B19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7BB67ECA-F6A6-4BB5-9DCB-0D9BFB710B19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7BB67ECA-F6A6-4BB5-9DCB-0D9BFB710B19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7BB67ECA-F6A6-4BB5-9DCB-0D9BFB710B19}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FDB8AF1D-3F96-4F4E-8B46-2D14F3321A00} = {83B9C7C1-A4ED-49E4-988F-89E3423313EB}
{5F7DFB56-3A46-437E-A8D7-4F0A5853CBCD} = {83B9C7C1-A4ED-49E4-988F-89E3423313EB}
{9182BAE0-0023-4E48-830F-184A3E3DFB89} = {83B9C7C1-A4ED-49E4-988F-89E3423313EB}
{B377CC60-B4BC-4A89-9856-553711690127} = {83B9C7C1-A4ED-49E4-988F-89E3423313EB}
{7BB67ECA-F6A6-4BB5-9DCB-0D9BFB710B19} = {83B9C7C1-A4ED-49E4-988F-89E3423313EB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {834FEEDD-2B16-456F-9126-C7C082A29837}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"sdk": {
"version": "7.0"
},
"msbuild-sdks": {
"Microsoft.Build.Traversal": "3.0.2"
}
}

0 comments on commit 35025d9

Please sign in to comment.