diff --git a/.github/workflows/github_build_and_publish.yml b/.github/workflows/github_build_and_publish.yml index 64efc6d..e7d58c7 100644 --- a/.github/workflows/github_build_and_publish.yml +++ b/.github/workflows/github_build_and_publish.yml @@ -9,7 +9,11 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest] steps: # Шаг 1: Клонируем репозиторий @@ -23,13 +27,18 @@ jobs: 8.0.x 9.0.x + - name: Build Windows + if: runner.os == 'Windows' + run: | + ./build.ps1 --target=Travis --verbosity=normal --ForceUploadPackages=false + shell: powershell + # Шаг 3: Сборка проекта - name: Build + if: runner.os == 'Linux' env: UPLOAD_NUGET: ${{ secrets.UPLOAD_NUGET }} UPLOAD_NUGET_API_KEY: ${{ secrets.UPLOAD_NUGET_API_KEY }} run: | chmod a+x ./build.sh ./build.sh --target=Travis --verbosity=normal --ForceUploadPackages=true - - diff --git a/build.cake b/build.cake index 6a6cf6b..38eb29d 100644 --- a/build.cake +++ b/build.cake @@ -2,7 +2,7 @@ // IMPORTS /////////////////////////////////////////////////////////////////////////////// -#load tools/microelements.devops/1.9.1/scripts/imports.cake +#load tools/microelements.devops/1.11.0/scripts/imports.cake /////////////////////////////////////////////////////////////////////////////// // SCRIPT ARGS AND CONVENTIONS @@ -21,9 +21,28 @@ ScriptArgs args = new ScriptArgs(Context) Task("Build") .Does(() => args.Build().BuildSamples()); -Task("Test") - .WithCriteria(()=>args.RunTests) - .Does(() => RunTests(args)); +var isWindows = Environment.Platform.Family == PlatformFamily.Windows; +Task("Tests") + .Does(() => + { + var solution = "MicroElements.Swashbuckle.FluentValidation.sln"; + + if (isWindows) + { + Information("Executing tests net481, net8.0, net9.0 on Windows"); + + DotNetTest(solution, new DotNetTestSettings { Framework = "net481" }); + DotNetTest(solution, new DotNetTestSettings { Framework = "net8.0" }); + DotNetTest(solution, new DotNetTestSettings { Framework = "net9.0" }); + } + else + { + Information("Executing tests net8.0 y net9.0 on Linux/macOS"); + + DotNetTest(solution, new DotNetTestSettings { Framework = "net8.0" }); + DotNetTest(solution, new DotNetTestSettings { Framework = "net9.0" }); + } + }); Task("UploadTestResultsToAppVeyor") .WithCriteria(()=>args.RunTests) @@ -68,4 +87,4 @@ Task("AppVeyor") .IsDependentOn("UploadTestResultsToAppVeyor") ; -RunTarget(args.Target); +RunTarget(args.Target); \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index edd41c5..47dca38 100644 --- a/build.ps1 +++ b/build.ps1 @@ -20,7 +20,7 @@ if(!$PSScriptRoot){ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } -$CAKE_VERSION = "0.38.0" +$CAKE_VERSION = "1.3.0" $DEVOPS_VERSION = "1.11.0" $NUGET_URL = "https://api.nuget.org/v3/index.json" $NUGET_BETA_URL = "https://www.myget.org/F/micro-elements/api/v3/index.json" @@ -63,6 +63,7 @@ if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } $cakeArguments += ("--rootDir="+@("$PSScriptRoot")); $cakeArguments += ("--devOpsVersion=$DEVOPS_VERSION"); $cakeArguments += ("--devOpsRoot=""$TOOLS_DIR/microelements.devops/$DEVOPS_VERSION"""); +$cakeArguments += ("--ForceUploadPackages=false") $cakeArguments += $ScriptArgs # Start Cake diff --git a/build.sh b/build.sh index eb69310..7282e69 100644 --- a/build.sh +++ b/build.sh @@ -18,7 +18,7 @@ TOOLS_DIR=$SCRIPT_DIR/tools SCRIPT=$TOOLS_DIR/microelements.devops/$DEVOPS_VERSION/scripts/main.cake CAKE_PROPS_PATH=$TOOLS_DIR/cake.props -CAKE_VERSION="0.38.0" +CAKE_VERSION="1.3.0" CAKE_ARGUMENTS=() # Parse arguments. @@ -26,6 +26,7 @@ for i in "$@"; do case $1 in -s|--script) SCRIPT="$2"; shift ;; --cake-version) CAKE_VERSION="--version=$2"; shift ;; + --ForceUploadPackages=*|--ForceUploadPackages) ;; --) shift; CAKE_ARGUMENTS+=("$@"); break ;; *) CAKE_ARGUMENTS+=("$1") ;; esac @@ -35,6 +36,7 @@ done CAKE_ARGUMENTS+=("--rootDir=$SCRIPT_DIR"); CAKE_ARGUMENTS+=("--devOpsVersion=$DEVOPS_VERSION"); CAKE_ARGUMENTS+=("--devOpsRoot=$TOOLS_DIR/microelements.devops/$DEVOPS_VERSION"); +CAKE_ARGUMENTS+=("--ForceUploadPackages=false") echo "===========VARIABLES============" echo "SCRIPT_DIR: $SCRIPT_DIR" @@ -80,4 +82,4 @@ dotnet tool restore echo "Running build script..." CMD="dotnet cake $SCRIPT ${CAKE_ARGUMENTS[@]}" echo $CMD -exec $CMD +exec $CMD \ No newline at end of file diff --git a/samples/MinimalApi/MinimalApi.csproj b/samples/MinimalApi/MinimalApi.csproj index e8fba71..de332ee 100644 --- a/samples/MinimalApi/MinimalApi.csproj +++ b/samples/MinimalApi/MinimalApi.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj b/samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj index b827cce..ef6d5a8 100644 --- a/samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj +++ b/samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj @@ -9,7 +9,7 @@ - + diff --git a/samples/SampleWebApi/SampleWebApi.csproj b/samples/SampleWebApi/SampleWebApi.csproj index 4958832..f6b0688 100644 --- a/samples/SampleWebApi/SampleWebApi.csproj +++ b/samples/SampleWebApi/SampleWebApi.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9ea8743..312d3a8 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - + diff --git a/src/MicroElements.NSwag.FluentValidation/MicroElements.NSwag.FluentValidation.csproj b/src/MicroElements.NSwag.FluentValidation/MicroElements.NSwag.FluentValidation.csproj index 0714ff6..cad1dba 100644 --- a/src/MicroElements.NSwag.FluentValidation/MicroElements.NSwag.FluentValidation.csproj +++ b/src/MicroElements.NSwag.FluentValidation/MicroElements.NSwag.FluentValidation.csproj @@ -13,6 +13,7 @@ + diff --git a/src/MicroElements.OpenApi.FluentValidation/MicroElements.OpenApi.FluentValidation.csproj b/src/MicroElements.OpenApi.FluentValidation/MicroElements.OpenApi.FluentValidation.csproj index ed2e2a7..1acf69b 100644 --- a/src/MicroElements.OpenApi.FluentValidation/MicroElements.OpenApi.FluentValidation.csproj +++ b/src/MicroElements.OpenApi.FluentValidation/MicroElements.OpenApi.FluentValidation.csproj @@ -16,8 +16,8 @@ - - + + \ No newline at end of file diff --git a/src/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation.csproj b/src/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation.csproj index 6ea7d7f..08934ac 100644 --- a/src/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation.csproj +++ b/src/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation.csproj @@ -13,7 +13,9 @@ - + + + diff --git a/src/MicroElements.Swashbuckle.FluentValidation/Swashbuckle/ScopedSwaggerMiddleware.cs b/src/MicroElements.Swashbuckle.FluentValidation/Swashbuckle/ScopedSwaggerMiddleware.cs index 13edcd9..86a9a8d 100644 --- a/src/MicroElements.Swashbuckle.FluentValidation/Swashbuckle/ScopedSwaggerMiddleware.cs +++ b/src/MicroElements.Swashbuckle.FluentValidation/Swashbuckle/ScopedSwaggerMiddleware.cs @@ -1,51 +1,51 @@ -// Copyright (c) MicroElements. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. +//// Copyright (c) MicroElements. All rights reserved. +//// Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Swashbuckle.AspNetCore.Swagger; +//using Microsoft.AspNetCore.Builder; +//using Microsoft.AspNetCore.Http; +//using Swashbuckle.AspNetCore.Swagger; +//using System; +//using System.Threading.Tasks; -namespace MicroElements.Swashbuckle.FluentValidation -{ - /// - /// SwaggerMiddleware that resolves on scope. - /// Resolves problems with validators with dependency on scoped services. - /// - public class ScopedSwaggerMiddleware - { - private readonly RequestDelegate _next; - private readonly SwaggerOptions _options; +//namespace MicroElements.Swashbuckle.FluentValidation +//{ +// /// +// /// SwaggerMiddleware that resolves on scope. +// /// Resolves problems with validators with dependency on scoped services. +// /// +// public class ScopedSwaggerMiddleware +// { +// private readonly RequestDelegate _next; +// private readonly SwaggerOptions _options; - /// - /// ctor. - /// - /// - /// - public ScopedSwaggerMiddleware(RequestDelegate next, SwaggerOptions options) - { - _next = next; - _options = options; - } +// /// +// /// ctor. +// /// +// /// +// /// +// public ScopedSwaggerMiddleware(RequestDelegate next, SwaggerOptions options) +// { +// _next = next; +// _options = options; +// } - public async Task Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) - { - await new SwaggerMiddleware(_next, _options).Invoke(httpContext, swaggerProvider); - } - } +// public async Task Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) +// { +// await new SwaggerMiddleware(_next, _options).Invoke(httpContext, swaggerProvider); +// } +// } - public static class SwaggerBuilderExtensions - { - /// - /// Replaces standard with . - /// Use instead of if you have services with scoped services like DbContext. - /// - public static IApplicationBuilder UseScopedSwagger(this IApplicationBuilder app, Action setupAction = null) - { - SwaggerOptions swaggerOptions = new SwaggerOptions(); - setupAction?.Invoke(swaggerOptions); - return app.UseMiddleware(swaggerOptions); - } - } -} \ No newline at end of file +// public static class SwaggerBuilderExtensions +// { +// /// +// /// Replaces standard with . +// /// Use instead of if you have services with scoped services like DbContext. +// /// +// public static IApplicationBuilder UseScopedSwagger(this IApplicationBuilder app, Action setupAction = null) +// { +// SwaggerOptions swaggerOptions = new SwaggerOptions(); +// setupAction?.Invoke(swaggerOptions); +// return app.UseMiddleware(swaggerOptions); +// } +// } +//} \ No newline at end of file diff --git a/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj b/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj index 7116aac..41d41e1 100644 --- a/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj +++ b/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj @@ -1,17 +1,17 @@  - net481;net8.0;net9.0 + net8.0;net9.0 enable latest false - + - +