From 5499132c046b47618d9db1d0b48d5b58bb9a05f1 Mon Sep 17 00:00:00 2001 From: thefringeninja Date: Fri, 12 Oct 2018 13:39:05 +1000 Subject: [PATCH 1/5] build script updates - Bullseye 2.2.0 - SimpleExec 3.0.0 - Replaced versioning nightmare wih minver --- Dockerfile | 12 +----- build.sh | 13 +++---- build/Program.cs | 25 ++----------- build/build.csproj | 4 +- src/Directory.Build.props | 9 ++--- .../Properties/AssemblyInfo.cs | 37 ------------------- .../SqlStreamStore.HAL.Tests.csproj | 7 ---- 7 files changed, 17 insertions(+), 90 deletions(-) delete mode 100644 src/SqlStreamStore.HAL.Tests/Properties/AssemblyInfo.cs diff --git a/Dockerfile b/Dockerfile index 21ec4b6..7f2fd2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,5 @@ FROM microsoft/dotnet:2.1.403-sdk-alpine3.7 AS build -ARG TRAVIS_BUILD_NUMBER -ARG TRAVIS_PULL_REQUEST_SHA -ARG TRAVIS_COMMIT -ARG TRAVIS_PULL_REQUEST -ARG TRAVIS_BRANCH +ARG TRAVIS_OS_NAME ARG MYGET_API_KEY RUN apk add nodejs yarn --no-cache @@ -34,12 +30,8 @@ COPY ./build . WORKDIR / -RUN TRAVIS_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER \ +RUN TRAVIS_OS_NAME=$TRAVIS_OS_NAME \ MYGET_API_KEY=$MYGET_API_KEY \ - TRAVIS_PULL_REQUEST_SHA=$TRAVIS_PULL_REQUEST_SHA \ - TRAVIS_COMMIT=$TRAVIS_COMMIT \ - TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST \ - TRAVIS_BRANCH=$TRAVIS_BRANCH \ dotnet run --project build/build.csproj FROM microsoft/dotnet:2.1.5-runtime-deps-alpine3.7 AS runtime diff --git a/build.sh b/build.sh index 0bce2c7..807b170 100755 --- a/build.sh +++ b/build.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash +set -e + DOCKERTAG=${TRAVIS_TAG:-latest} docker build \ - --build-arg TRAVIS_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER \ + --build-arg TRAVIS_OS_NAME=$TRAVIS_OS_NAME \ --build-arg MYGET_API_KEY=$MYGET_API_KEY \ - --build-arg TRAVIS_PULL_REQUEST_SHA=$TRAVIS_PULL_REQUEST_SHA \ - --build-arg TRAVIS_COMMIT=$TRAVIS_COMMIT \ - --build-arg TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST \ - --build-arg TRAVIS_BRANCH=$TRAVIS_BRANCH \ --tag sql-stream-store-server:${DOCKERTAG} \ - . && \ -docker images --filter=reference="sql-stream-store-server:${DOCKERTAG}" + . + +docker images --filter=reference="sql-stream-store-server:${DOCKERTAG}" \ No newline at end of file diff --git a/build/Program.cs b/build/Program.cs index e611315..fd41fd7 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -21,10 +21,6 @@ static class Program public static void Main(string[] args) { - var buildNumber = GetBuildNumber(); - var branch = GetBranch(); - var commitHash = GetCommitHash(); - var buildMetadata = $"{branch}.{commitHash}"; var apiKey = Environment.GetEnvironmentVariable("MYGET_API_KEY"); Target(Clean, () => @@ -78,7 +74,7 @@ public static void Main(string[] args) DependsOn(GenerateDocumentation), () => Run( "dotnet", - $"build src/SqlStreamStore.HAL.sln -c Release /p:BuildNumber={buildNumber} /p:BuildMetadata={buildMetadata}")); + $"build src/SqlStreamStore.HAL.sln -c Release")); Target( RunTests, @@ -92,14 +88,14 @@ public static void Main(string[] args) DependsOn(Build), () => Run( "dotnet", - $"publish --configuration=Release --output=../../{PublishDir} --runtime=alpine.3.7-x64 /p:ShowLinkerSizeComparison=true /p:BuildNumber={buildNumber} /p:BuildMetadata={buildMetadata} src/SqlStreamStore.HAL.DevServer ")); + $"publish --configuration=Release --output=../../{PublishDir} --runtime=alpine.3.7-x64 /p:ShowLinkerSizeComparison=true src/SqlStreamStore.HAL.DevServer")); Target( Pack, DependsOn(Publish), () => Run( "dotnet", - $"pack src/SqlStreamStore.HAL -c Release -o ../../{ArtifactsDir} /p:BuildNumber={buildNumber} /p:BuildMetadata={buildMetadata} --no-build")); + $"pack src/SqlStreamStore.HAL -c Release -o ../../{ArtifactsDir} --no-build")); Target( Push, @@ -127,19 +123,4 @@ public static void Main(string[] args) RunTargets(args); } - - private static string GetBranch() - => (Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST")?.ToLower() == "false" - ? null - : $"pr-{Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST")}") - ?? Environment.GetEnvironmentVariable("TRAVIS_BRANCH") - ?? "none"; - - private static string GetCommitHash() - => Environment.GetEnvironmentVariable("TRAVIS_PULL_REQUEST_SHA") - ?? Environment.GetEnvironmentVariable("TRAVIS_COMMIT") - ?? "none"; - - private static string GetBuildNumber() - => (Environment.GetEnvironmentVariable("TRAVIS_BUILD_NUMBER") ?? "0"); } \ No newline at end of file diff --git a/build/build.csproj b/build/build.csproj index 96a1ebb..c0a0dfb 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 39be376..662e0d2 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,15 +1,14 @@  - 0 - local - 1.0.0 - rc3.$(BuildNumber) - $(VersionPrefix)-$(VersionSuffix)+$(BuildMetadata) João P. Bragança https://github.com/SqlStreamStore/SqlStreamStore.HAL https://github.com/SqlStreamStore/SqlStreamStore.HAL/blob/master/LICENSE true cqrs;event-sourcing;event-store;stream-store + + + + diff --git a/src/SqlStreamStore.HAL.Tests/Properties/AssemblyInfo.cs b/src/SqlStreamStore.HAL.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 8b42655..0000000 --- a/src/SqlStreamStore.HAL.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("SqlStreamStore.HAL.Tests")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SqlStreamStore.HAL.Tests")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("a2f4657c-2c11-44e8-8e19-a44af9ae543d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/src/SqlStreamStore.HAL.Tests/SqlStreamStore.HAL.Tests.csproj b/src/SqlStreamStore.HAL.Tests/SqlStreamStore.HAL.Tests.csproj index c4f12b8..470c88c 100644 --- a/src/SqlStreamStore.HAL.Tests/SqlStreamStore.HAL.Tests.csproj +++ b/src/SqlStreamStore.HAL.Tests/SqlStreamStore.HAL.Tests.csproj @@ -3,13 +3,6 @@ netcoreapp2.1 SqlStreamStore.HAL.Tests SqlStreamStore.HAL.Tests - false - false - false - false - false - false - false portable true true From dece5beeb8e9d48ad325af5b2bc79a6a9f7c7486 Mon Sep 17 00:00:00 2001 From: thefringeninja Date: Tue, 6 Nov 2018 09:20:39 +0100 Subject: [PATCH 2/5] parallelizing docs generation --- build/Program.cs | 49 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/build/Program.cs b/build/Program.cs index fd41fd7..63fba67 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -2,7 +2,6 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Threading.Tasks; using static Bullseye.Targets; using static SimpleExec.Command; @@ -12,6 +11,7 @@ static class Program private const string PublishDir = "publish"; private const string Clean = nameof(Clean); + private const string Init = nameof(Init); private const string GenerateDocumentation = nameof(GenerateDocumentation); private const string Build = nameof(Build); private const string RunTests = nameof(RunTests); @@ -22,6 +22,7 @@ static class Program public static void Main(string[] args) { var apiKey = Environment.GetEnvironmentVariable("MYGET_API_KEY"); + var srcDirectory = new DirectoryInfo("./src"); Target(Clean, () => { @@ -29,28 +30,17 @@ public static void Main(string[] args) { Directory.Delete(ArtifactsDir, true); } + if (Directory.Exists(PublishDir)) { Directory.Delete(PublishDir, true); } - }); Target( - GenerateDocumentation, + Init, () => { - var srcDirectory = new DirectoryInfo("./src"); - - var schemaFiles = srcDirectory.GetFiles("*.schema.json", SearchOption.AllDirectories); - - var schemaDirectories = schemaFiles - .Select(schemaFile => schemaFile.DirectoryName) - .Distinct() - .Select(schemaDirectory => - schemaDirectory.Replace(Path.DirectorySeparatorChar, - '/')); // normalize paths; yarn/node can handle forward slashes - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Run("cmd", "/c yarn", "docs"); @@ -59,22 +49,24 @@ public static void Main(string[] args) { Run("yarn", string.Empty, "docs"); } - - foreach (var schemaDirectory in schemaDirectories) - { - Run( - "node", - $"node_modules/@adobe/jsonschema2md/cli.js -n --input {schemaDirectory} --out {schemaDirectory} --schema-out=-", - "docs"); - } }); + Target( + GenerateDocumentation, + DependsOn(Init), + ForEach(SchemaDirectories(srcDirectory)), + schemaDirectory => + RunAsync( + "node", + $"node_modules/@adobe/jsonschema2md/cli.js -n --input {schemaDirectory} --out {schemaDirectory} --schema-out=-", + "docs")); + Target( Build, DependsOn(GenerateDocumentation), () => Run( "dotnet", - $"build src/SqlStreamStore.HAL.sln -c Release")); + "build src/SqlStreamStore.HAL.sln -c Release")); Target( RunTests, @@ -89,7 +81,7 @@ public static void Main(string[] args) () => Run( "dotnet", $"publish --configuration=Release --output=../../{PublishDir} --runtime=alpine.3.7-x64 /p:ShowLinkerSizeComparison=true src/SqlStreamStore.HAL.DevServer")); - + Target( Pack, DependsOn(Publish), @@ -121,6 +113,13 @@ public static void Main(string[] args) Target("default", DependsOn(Clean, RunTests, Push)); - RunTargets(args); + RunTargets(args.Concat(new[] {"--parallel"})); } + + private static string[] SchemaDirectories(DirectoryInfo srcDirectory) + => srcDirectory.GetFiles("*.schema.json", SearchOption.AllDirectories) + .Select(schemaFile => schemaFile.DirectoryName) + .Distinct() + .Select(schemaDirectory => schemaDirectory.Replace(Path.DirectorySeparatorChar, '/')) + .ToArray(); } \ No newline at end of file From 6a9bc3335407b293163d7bc62401fffeb01afef8 Mon Sep 17 00:00:00 2001 From: thefringeninja Date: Tue, 6 Nov 2018 09:20:47 +0100 Subject: [PATCH 3/5] added missing dependency for linux --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7f2fd2d..4b8cca5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,10 @@ FROM microsoft/dotnet:2.1.403-sdk-alpine3.7 AS build ARG TRAVIS_OS_NAME ARG MYGET_API_KEY -RUN apk add nodejs yarn --no-cache +RUN apk add --no-cache \ + nodejs \ + yarn \ + libcurl WORKDIR /src From a6a603a26c4d35aa22bae1c8e74907ad6c590f54 Mon Sep 17 00:00:00 2001 From: thefringeninja Date: Tue, 6 Nov 2018 10:26:36 +0100 Subject: [PATCH 4/5] remove sourcelink --- Dockerfile | 8 ++++++-- build.sh | 5 ++++- src/Directory.Build.props | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b8cca5..2ee50e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM microsoft/dotnet:2.1.403-sdk-alpine3.7 AS build -ARG TRAVIS_OS_NAME ARG MYGET_API_KEY +ARG MINVER_BUILD_METADATA RUN apk add --no-cache \ nodejs \ @@ -23,6 +23,10 @@ WORKDIR /docs COPY ./docs/package.json ./docs/yarn.lock ./ +WORKDIR /.git + +COPY ./.git . + WORKDIR /build COPY ./build/build.csproj . @@ -33,7 +37,7 @@ COPY ./build . WORKDIR / -RUN TRAVIS_OS_NAME=$TRAVIS_OS_NAME \ +RUN MINVER_BUILD_METADATA=$MINVER_BUILD_METADATA \ MYGET_API_KEY=$MYGET_API_KEY \ dotnet run --project build/build.csproj diff --git a/build.sh b/build.sh index 807b170..cb4c480 100755 --- a/build.sh +++ b/build.sh @@ -2,9 +2,12 @@ set -e DOCKERTAG=${TRAVIS_TAG:-latest} +BUILD_NUMBER=${TRAVIS_BUILD_NUMBER:-0} +COMMIT=${TRAVIS_PULL_REQUEST_SHA:-${TRAVIS_COMMIT:-unknown}} +MINVER_BUILD_METADATA="build.${BUILD_NUMBER}.${COMMIT}" docker build \ - --build-arg TRAVIS_OS_NAME=$TRAVIS_OS_NAME \ + --build-arg MINVER_BUILD_METADATA=$MINVER_BUILD_METADATA \ --build-arg MYGET_API_KEY=$MYGET_API_KEY \ --tag sql-stream-store-server:${DOCKERTAG} \ . diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 662e0d2..4dee970 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,7 +8,6 @@ cqrs;event-sourcing;event-store;stream-store - From 1daafe17d25865152965da107f062c704e4bb472 Mon Sep 17 00:00:00 2001 From: thefringeninja Date: Tue, 6 Nov 2018 10:39:42 +0100 Subject: [PATCH 5/5] deep clone --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a693c95..edbb6fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,5 @@ script: ./build.sh env: global: secure: pnK+4X/2WLLMqEv0A2GAXHYkjjRKT+HeIOkSWLYvQc/2H8lPjg0JmQvq7MQIZJxetGv+gxSJtX2cbG55j6mj+inlHHWm87wHPh8zljJztRpH9Fz0IR5GXADuUjCRuvoHq+PJI5MZlcFPYbcaAKVOsyYlejy5Ok5wlYD2WUMMw4NH+iFmffbAuycVynZrzeEGzfx33nocUObamrMOru8UTcHEmR041mwOwjjkzzQmNSLaSt/sQvSrnR8jte3zfrCUT5H7uczs0lkO3OzhJAwqA7vULyRH9iugkauv0HzAorKXOMLKey6E/GZElHviU8E1NnbAOyoBKcITe4EDI1HSbWNQ8C7nFP6w8Rv/O1lRXWL8SHucNXbmETgJ8zlrVWlRMBmnjnjbr0uF7cK4lIaJG3B/ZsY6pMn/93pPLTLrlsl7ZCjxuplU5pfNq/ORnZnAhlKe5W2uxvNdK1C6soFaGvcvyMlcAcjx8Jhjq3Yh8sHknAl70ga/AhvjAzWaTKe5zXTxfXcRXQp5mF9k707qTDkDIeGwXxY92QeiRmFfOuH56UI4CsLgpPgk3yyaHTYZsVuJRHRSqHcNo6ivgF/vYRzSXreEWfd89d8E750SMf90ON8GiCu0cfgBbUUFtsZ8AJdwmp9F7JB23sEB9Gj1OTLgRT247hOmP0b4tinZz5M= +git: + depth: false \ No newline at end of file