Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ COPY ./src/*/*.csproj ./src/Directory.Build.props ./

RUN for file in $(ls *.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done

WORKDIR /app/tests

COPY ./tests/*/*.csproj ./

RUN for file in $(ls *.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done

WORKDIR /app

COPY ./NuGet.Config ./
Expand All @@ -50,6 +56,10 @@ COPY ./src .

COPY --from=build-javascript /app/node_modules/${CLIENT_PACKAGE}/build /app/src/SqlStreamStore.Server/Browser/build

WORKDIR /app/tests

COPY ./tests .

WORKDIR /app/build

COPY ./build/build.csproj .
Expand All @@ -58,6 +68,10 @@ RUN dotnet restore

COPY ./build .

WORKDIR /app/src

COPY ./src .

WORKDIR /app

RUN dotnet run --project build/build.csproj -- --runtime=${RUNTIME} --library-version=${LIBRARY_VERSION}
Expand Down
6 changes: 6 additions & 0 deletions SqlStreamStore.Server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlStreamStore.Server", "src\SqlStreamStore.Server\SqlStreamStore.Server.csproj", "{B4B24F09-CB96-4D2E-A1D2-C50C9557F144}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlStreamStore.Server.Tests", "tests\SqlStreamStore.Server.Tests\SqlStreamStore.Server.Tests.csproj", "{AE3DAADF-EE63-4CFF-9024-0730650DD165}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{B4B24F09-CB96-4D2E-A1D2-C50C9557F144}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4B24F09-CB96-4D2E-A1D2-C50C9557F144}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4B24F09-CB96-4D2E-A1D2-C50C9557F144}.Release|Any CPU.Build.0 = Release|Any CPU
{AE3DAADF-EE63-4CFF-9024-0730650DD165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE3DAADF-EE63-4CFF-9024-0730650DD165}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE3DAADF-EE63-4CFF-9024-0730650DD165}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE3DAADF-EE63-4CFF-9024-0730650DD165}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-alpine3.9}
LIBRARY_VERSION=${LIBRARY_VERSION:-1.2.0-beta.3.12}
LIBRARY_VERSION=${LIBRARY_VERSION:-1.2.0-beta.3.19}
CLIENT_VERSION=${CLIENT_VERSION:-0.9.2}

LOCAL_IMAGE="sql-stream-store-server"
Expand Down
18 changes: 14 additions & 4 deletions build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ static class Program

public static void Main(string[] args)
{
const string clean = nameof(Clean);
const string build = nameof(Build);
const string publish = nameof(Publish);
const string clean = nameof(clean);
const string build = nameof(build);
const string test = nameof(test);
const string publish = nameof(publish);

var runtime = "alpine-x64";
var libraryVersion = "1.2.0-beta.*";
Expand Down Expand Up @@ -43,8 +44,13 @@ public static void Main(string[] args)
Build(libraryVersion));

Target(
publish,
test,
DependsOn(build),
Test);

Target(
publish,
DependsOn(test),
Publish(runtime, libraryVersion));

Target("default", DependsOn(publish));
Expand All @@ -69,6 +75,10 @@ private static Action Build(string libraryVersion) => () => Run(
"dotnet",
$"build SqlStreamStore.Server.sln --configuration=Release /p:LibraryVersion={libraryVersion}");

private static readonly Action Test = () => Run(
"dotnet",
$"test --configuration=Release --no-build");

private static Action Publish(string runtime, string libraryVersion) => () => Run(
"dotnet",
$"publish --configuration=Release --output=../../{PublishDir} --runtime={runtime} /p:ShowLinkerSizeComparison=true /p:LibraryVersion={libraryVersion} src/SqlStreamStore.Server");
Expand Down
3 changes: 3 additions & 0 deletions src/SqlStreamStore.Server/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("SqlStreamStore.Server.Tests")]
2 changes: 1 addition & 1 deletion src/SqlStreamStore.Server/SqlStreamStore.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<LangVersion>latest</LangVersion>
<CrossGenDuringPublish>false</CrossGenDuringPublish>
<LibraryVersion Condition="$(LibraryVersion) == ''">1.2.0-beta.3.16+build.415</LibraryVersion>
<LibraryVersion Condition="$(LibraryVersion) == ''">1.2.0-beta.3.19</LibraryVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ILLink.Tasks" Version="0.1.5-preview-1841731" />
Expand Down
14 changes: 1 addition & 13 deletions src/SqlStreamStore.Server/SqlStreamStoreServerStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,15 @@ public SqlStreamStoreServerStartup(

public IServiceProvider ConfigureServices(IServiceCollection services) => services
.AddResponseCompression(options => options.MimeTypes = new[] { "application/hal+json" })
.AddRouting()
.BuildServiceProvider();

public void Configure(IApplicationBuilder app) => app
.UseResponseCompression()
.Use(VaryAccept)
.Use(CatchAndDisplayErrors)
.UseSqlStreamStoreBrowser()
.UseSqlStreamStoreHal(_streamStore, _options);

private static MidFunc CatchAndDisplayErrors => async (context, next) =>
{
try
{
await next();
}
catch(Exception ex)
{
Log.Warning(ex, "Error during request.");
}
};

private static MidFunc VaryAccept => (context, next) =>
{
Task Vary()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\SqlStreamStore.Server\SqlStreamStore.Server.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using SqlStreamStore;
using SqlStreamStore.HAL;
using SqlStreamStore.Server;
using Xunit;

namespace SQLStreamStore.Server.Tests
{
public class SqlStreamStoreServerStartupTests : IDisposable
{
private readonly InMemoryStreamStore _streamStore;
private readonly IWebHost _host;
private TestServer _server;
private readonly HttpClient _httpClient;

public SqlStreamStoreServerStartupTests()
{
_streamStore = new InMemoryStreamStore();

_server = new TestServer(
new WebHostBuilder()
.UseStartup(new SqlStreamStoreServerStartup(
_streamStore,
new SqlStreamStoreMiddlewareOptions
{
UseCanonicalUrls = false
})));

_httpClient = new HttpClient(_server.CreateHandler())
{
BaseAddress = new UriBuilder().Uri
};
}

[Fact]
public async Task StartsUp()
{
using (await _httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, "/")
{
Headers = {Accept = {new MediaTypeWithQualityHeaderValue("application/hal+json")}}
}))
{
}
}

public void Dispose()
{
_streamStore?.Dispose();
_host?.Dispose();
_httpClient?.Dispose();
}
}
}