Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing with db on Docker container #23

Merged
merged 16 commits into from
Apr 6, 2024
11 changes: 10 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
name: program
path: ./src/ABulkCopy.Cmd/bin/Release/net8.0/win-x64/publish

- name: Display structure of artifact files
run: ls -R

- name: Upload tests artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -56,7 +59,7 @@ jobs:
./src/APostgres.Test/bin/Debug/net8.0
./src/ASqlServer.Test/bin/Debug/net8.0
./src/Common.Test/bin/Debug/net8.0

./src/End2EndTests/bin/Debug/net8.0
test:
name: Test
runs-on: ubuntu-latest
Expand All @@ -70,6 +73,9 @@ jobs:
with:
name: tests

- name: Display structure of artifact files
run: ls -R

- name: Test AParser
run: dotnet test ./AParser.Test/bin/Debug/net8.0/AParser.Test.dll -v m

Expand All @@ -79,6 +85,9 @@ jobs:
- name: Test ASqlServer
run: dotnet test ./ASqlServer.Test/bin/Debug/net8.0/ASqlServer.Test.dll -v m -e AppSettings__ConnectionString="${{secrets.MSS_ABULKCOPY_TEST_CONNECTIONSTRING}}"

- name: SqlServer to Postgres end-to-end tests
run: dotnet test ./End2EndTests/bin/Debug/net8.0/End2EndTests.dll -v m

release:
name: Release
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ assembly-file-versioning-format: '{Major}.{Minor}.{Patch}'
assembly-file-versioning-scheme: MajorMinorPatch
branches:
pull-request:
increment: Patch
regex: ^master$
tag: ''
master:
increment: Patch
Expand Down
28 changes: 28 additions & 0 deletions src/ABulkCopy.Cmd.Internal/ABulkCopy.Cmd.Internal.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.IO.Abstractions" Version="20.0.15" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ABulkCopy.APostgres\ABulkCopy.APostgres.csproj" />
<ProjectReference Include="..\ABulkCopy.ASqlServer\ABulkCopy.ASqlServer.csproj" />
<ProjectReference Include="..\ABulkCopy.Common\ABulkCopy.Common.csproj" />
<ProjectReference Include="..\AParser\AParser.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd;
namespace ABulkCopy.Cmd.Internal;

public class CmdArguments
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd;
namespace ABulkCopy.Cmd.Internal;

public static class CmdConstants
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd;
namespace ABulkCopy.Cmd.Internal;

public enum CmdStatus
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Serilog.Settings.Configuration;

namespace ABulkCopy.Cmd.Config;
namespace ABulkCopy.Cmd.Internal.Config;

public class LogConfigHelper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd.Config;
namespace ABulkCopy.Cmd.Internal.Config;

public static class ServiceCollectionExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd;
namespace ABulkCopy.Cmd.Internal;

public class CopyIn : ICopyIn
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd;
namespace ABulkCopy.Cmd.Internal;

public class CopyOut : ICopyOut
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd;
namespace ABulkCopy.Cmd.Internal;

public static class DataFolder
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd.Factories;
namespace ABulkCopy.Cmd.Internal.Factories;

public class ADataReaderFactory : IADataReaderFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd.Factories;
namespace ABulkCopy.Cmd.Internal.Factories;

public class QueryBuilderFactory : IQueryBuilderFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd.Factories;
namespace ABulkCopy.Cmd.Internal.Factories;

public class SchemaReaderFactory : ISchemaReaderFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd.Factories;
namespace ABulkCopy.Cmd.Internal.Factories;

public class TableReaderFactory : ITableReaderFactory
{
Expand Down
32 changes: 32 additions & 0 deletions src/ABulkCopy.Cmd.Internal/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Global using directives

global using ABulkCopy.APostgres;
global using ABulkCopy.APostgres.Column;
global using ABulkCopy.APostgres.Mapping;
global using ABulkCopy.APostgres.Reader;
global using ABulkCopy.ASqlServer;
global using ABulkCopy.ASqlServer.Column;
global using ABulkCopy.ASqlServer.Table;
global using ABulkCopy.Common;
global using ABulkCopy.Common.Config;
global using ABulkCopy.Common.Database;
global using ABulkCopy.Common.Extensions;
global using ABulkCopy.Common.Graph;
global using ABulkCopy.Common.Identifier;
global using ABulkCopy.Common.Mapping;
global using ABulkCopy.Common.Reader;
global using ABulkCopy.Common.Types;
global using ABulkCopy.Common.Types.Table;
global using ABulkCopy.Common.Utils;
global using ABulkCopy.Common.Writer;
global using AParser;
global using AParser.Parsers.Pg;
global using CommandLine;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Serilog;
global using System.Diagnostics;
global using System.IO.Abstractions;
global using System.Text.RegularExpressions;
global using Serilog.Settings.Configuration;
50 changes: 50 additions & 0 deletions src/ABulkCopy.Cmd.Internal/HostApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using ABulkCopy.Cmd.Internal.Config;
using ABulkCopy.Cmd.Internal.Factories;
using Microsoft.Extensions.Logging;

namespace ABulkCopy.Cmd.Internal;

public static class HostApplicationBuilderExtensions
{
public static HostApplicationBuilder ConfigureServices(
this HostApplicationBuilder builder,
Rdbms rdbms,
IConfigurationRoot configuration)
{
builder.Services.ConfigureServices(rdbms, configuration);
return builder;
}

public static void ConfigureServices(
this IServiceCollection services,
Rdbms rdbms,
IConfigurationRoot configuration)
{
var loggerFactory = LoggerFactory.Create(loggingBuilder =>
{
loggingBuilder.ClearProviders();
loggingBuilder.AddSerilog(Log.Logger);
});
services.AddSingleton(loggerFactory);
services.AddSingleton<IConfiguration>(configuration);
services.AddSingleton(Log.Logger);
services.AddSingleton<ISchemaWriter, SchemaWriter>();
services.AddSingleton<IDataWriter, DataWriter>();
services.AddSingleton<ISchemaReaderFactory, SchemaReaderFactory>();
services.AddSingleton<IADataReaderFactory, ADataReaderFactory>();
services.AddSingleton<ITableReaderFactory, TableReaderFactory>();
services.AddSingleton<ISelectCreator, SelectCreator>();
services.AddSingleton<ICopyOut, CopyOut>();
services.AddSingleton<ICopyIn, CopyIn>();
services.AddSingleton<IMappingFactory, MappingFactory>();
services.AddSingleton<IFileSystem>(new FileSystem());
services.AddTransient<IDataFileReader, DataFileReader>();
services.AddTransient<IDependencyGraph, DependencyGraph>();
services.AddTransient<IVisitorFactory, VisitorFactory>();
services.AddSingleton<INodeFactory, NodeFactory>();
services.AddSingleton<IQueryBuilderFactory, QueryBuilderFactory>();
services.AddSingleton<IIdentifier, Identifier>();
if (rdbms == Rdbms.Mss) services.AddMssServices();
if (rdbms == Rdbms.Pg) services.AddPgServices();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace ABulkCopy.Cmd;
namespace ABulkCopy.Cmd.Internal;

internal interface ICopyIn
public interface ICopyIn
{
Task RunAsync(Rdbms rdbms, CancellationToken ctsToken);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ABulkCopy.Cmd;
namespace ABulkCopy.Cmd.Internal;

public interface ICopyOut
{
Expand Down
10 changes: 4 additions & 6 deletions src/ABulkCopy.Cmd/ABulkCopy.Cmd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,17 @@
<PackageReference Include="System.IO.Abstractions" Version="20.0.15" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ABulkCopy.APostgres\ABulkCopy.APostgres.csproj" />
<ProjectReference Include="..\ABulkCopy.ASqlServer\ABulkCopy.ASqlServer.csproj" />
<ProjectReference Include="..\ABulkCopy.Common\ABulkCopy.Common.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ABulkCopy.Cmd.Internal\ABulkCopy.Cmd.Internal.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
23 changes: 2 additions & 21 deletions src/ABulkCopy.Cmd/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
// Global using directives

global using ABulkCopy.APostgres;
global using ABulkCopy.APostgres.Column;
global using ABulkCopy.APostgres.Mapping;
global using ABulkCopy.APostgres.Reader;
global using ABulkCopy.ASqlServer;
global using ABulkCopy.ASqlServer.Column;
global using ABulkCopy.ASqlServer.Table;
global using ABulkCopy.Cmd.Config;
global using ABulkCopy.Cmd.Factories;
global using ABulkCopy.Cmd.Internal;
global using ABulkCopy.Cmd.Internal.Config;
global using ABulkCopy.Common;
global using ABulkCopy.Common.Config;
global using ABulkCopy.Common.Database;
global using ABulkCopy.Common.Extensions;
global using ABulkCopy.Common.Graph;
global using ABulkCopy.Common.Identifier;
global using ABulkCopy.Common.Mapping;
global using ABulkCopy.Common.Reader;
global using ABulkCopy.Common.Types;
global using ABulkCopy.Common.Types.Table;
global using ABulkCopy.Common.Utils;
global using ABulkCopy.Common.Writer;
global using AParser;
global using AParser.Parsers.Pg;
global using CommandLine;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Serilog;
global using System.Diagnostics;
global using System.IO.Abstractions;
global using System.Text.RegularExpressions;
4 changes: 2 additions & 2 deletions src/ABulkCopy.Cmd/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace ABulkCopy.Cmd;

internal class Program
public class Program
{
static async Task Main(string[] args)
public static async Task Main(string[] args)
{
var cmdArguments = GetArguments(args);
if (cmdArguments == null) return;
Expand Down
42 changes: 0 additions & 42 deletions src/ABulkCopy.Cmd/Startup.cs

This file was deleted.

Loading
Loading