15 Commits

Author SHA1 Message Date
ITDancer13
aedbc1ed96 Fix broken paging (#136)
* Add unit tests
* Use calculated page size instead of page

Co-authored-by: ITDancer139 <kevinitdancersommer@gmail.com>
2021-05-16 16:34:36 +02:00
ITDancer13
2c9d907764 * Throw exceptions by default (#133)
* Doc strings for SieveOptions.cs
* Simplify MaxPageSize calculation

Co-authored-by: ITDancer139 <kevinitdancersommer@gmail.com>
2021-05-15 18:06:40 +02:00
Keivn Sommer
8bd9ce85d9 Fix nuget target path 2021-05-14 23:35:47 +02:00
Keivn Sommer
f738e3bf1e Use NUGET_API_KEY to publish first pre-release 2021-05-14 23:33:05 +02:00
Keivn Sommer
dd1b0a9edc Disable publish for master - should be activated as soon as it's merged back for the first time. 2021-05-14 23:28:18 +02:00
Keivn Sommer
27838b062c Set mode to 'ContinuousDeployment' to get unique NuGetPreReleaseTagV2 on releases/* 2021-05-14 23:28:18 +02:00
Keivn Sommer
38af9af982 Publish requires to be executed on server 2021-05-14 23:27:57 +02:00
Kevin Sommer
d188bed4f0 Setup NuGet push (without api key) 2021-05-14 23:27:57 +02:00
Kevin Sommer
1e29271fd9 Check if NUGET_API_KEY can be accessed 2021-05-14 23:27:57 +02:00
Kevin Sommer
034730bffb Use ci.yml for PRs only 2021-05-14 23:27:57 +02:00
Kevin Sommer
79c825cb7a Prepare publish on releases/* and master 2021-05-14 23:27:57 +02:00
Kevin Sommer
028ab1d196 Build an PRs to releases/* 2021-05-14 23:27:57 +02:00
ITDancer139
9277690e96 Replace features by releases 2021-05-14 23:27:57 +02:00
ITDancer139
d5474478b3 Update pipeline to build on feature branches 2021-05-14 23:27:57 +02:00
ITDancer139
4c5510772a build on feature branches 2021-05-14 23:27:57 +02:00
8 changed files with 141 additions and 16 deletions

View File

@@ -17,12 +17,10 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master
- 'releases/*'
jobs:
ubuntu-latest:

33
.github/workflows/ci_publish.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_ci_publish --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------
name: ci_publish
on:
push:
branches:
- 'releases/*'
jobs:
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run './build.cmd CiPublish'
run: ./build.cmd CiPublish
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

View File

@@ -43,6 +43,9 @@
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"NUGET_API_KEY": {
"type": "string"
},
"Plan": {
"type": "boolean",
"description": "Shows the execution plan (HTML)"
@@ -65,9 +68,11 @@
"type": "string",
"enum": [
"Ci",
"CiPublish",
"Clean",
"Compile",
"Package",
"Publish",
"Restore",
"Test"
]
@@ -84,9 +89,11 @@
"type": "string",
"enum": [
"Ci",
"CiPublish",
"Clean",
"Compile",
"Package",
"Publish",
"Restore",
"Test"
]

View File

@@ -0,0 +1,3 @@
branches:
release:
mode: ContinuousDeployment

View File

@@ -2,12 +2,27 @@
{
public class SieveOptions
{
/// <summary>
/// If flag is set, property names have to match including case sensitivity.
/// </summary>
public bool CaseSensitive { get; set; } = false;
/// <summary>
/// Fallback value of no page size is specified in the request.
/// </summary>
/// <remarks>Values less or equal to 0 disable paging.</remarks>
public int DefaultPageSize { get; set; } = 0;
/// <summary>
/// Specifies the upper limit of a page size to be requested.
/// </summary>
/// <remarks>Values less or equal to 0 are ignored.</remarks>
public int MaxPageSize { get; set; } = 0;
public bool ThrowExceptions { get; set; } = false;
/// <summary>
/// If flag is set, Sieve throws exception otherwise exceptions are caught and the already processed
/// result is returned.
/// </summary>
public bool ThrowExceptions { get; set; } = true;
}
}
}

View File

@@ -377,7 +377,11 @@ namespace Sieve.Services
{
var page = model?.Page ?? 1;
var pageSize = model?.PageSize ?? _options.Value.DefaultPageSize;
var maxPageSize = _options.Value.MaxPageSize > 0 ? _options.Value.MaxPageSize : pageSize;
if (_options.Value.MaxPageSize > 0)
{
pageSize = Math.Min(pageSize, _options.Value.MaxPageSize);
}
if (pageSize <= 0)
{
@@ -385,7 +389,7 @@ namespace Sieve.Services
}
result = result.Skip((page - 1) * pageSize);
result = result.Take(Math.Min(pageSize, maxPageSize));
result = result.Take(pageSize);
return result;
}

View File

@@ -613,5 +613,44 @@ namespace SieveUnitTests
Assert.Equal(1,posts[2].Id);
Assert.Equal(0,posts[3].Id);
}
[Theory]
[InlineData(1)]
[InlineData(2)]
[InlineData(3)]
[InlineData(4)]
public void Paging_DifferentPages(int page)
{
var model = new SieveModel
{
Page = page,
PageSize = 1,
};
var result = _processor.Apply(model, _posts);
var posts = result.ToList();
Assert.Single(posts);
var expectedId = page - 1;
Assert.Equal(expectedId, posts.First().Id);
}
[Theory]
[InlineData(1)]
[InlineData(2)]
[InlineData(3)]
[InlineData(4)]
public void Paging_DifferentPageSizes(int pageSize)
{
var model = new SieveModel
{
Page = 1,
PageSize = pageSize,
};
var result = _processor.Apply(model, _posts);
Assert.Equal(pageSize, result.Count());
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Linq;
using GlobExpressions;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.GitHubActions;
@@ -8,17 +9,23 @@ using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
[CheckBuildProjectConfigurations]
[ShutdownDotNetAfterServerBuild]
[GitHubActions("ci", GitHubActionsImage.UbuntuLatest,
OnPushBranches = new[] {"master"},
OnPullRequestBranches = new[] {"master"},
OnPullRequestBranches = new[] {"master", "releases/*"},
AutoGenerate = true,
InvokedTargets = new[] {nameof(Ci)},
CacheKeyFiles = new string[0])]
[GitHubActions("ci_publish", GitHubActionsImage.UbuntuLatest,
OnPushBranches = new[] {"releases/*"},
AutoGenerate = true,
InvokedTargets = new[] {nameof(CiPublish)},
CacheKeyFiles = new string[0],
ImportSecrets = new[] {"NUGET_API_KEY"})]
class Build : NukeBuild
{
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
@@ -30,6 +37,9 @@ class Build : NukeBuild
[Solution] readonly Solution Solution;
// ReSharper disable once InconsistentNaming
[Parameter] string NUGET_API_KEY;
Project SieveProject => Solution.AllProjects.First(p => p.Name == "Sieve");
AbsolutePath OutputDirectory => RootDirectory / "output";
@@ -83,13 +93,29 @@ class Build : NukeBuild
.EnableNoBuild());
});
Target Ci => _ => _
.DependsOn(Package);
Target Publish => _ => _
.DependsOn(Package)
.Requires(() => IsServerBuild)
.Requires(() => NUGET_API_KEY)
.Requires(() => Configuration.Equals(Configuration.Release))
.Executes(() =>
{
Glob.Files(OutputDirectory, "*.nupkg")
.NotEmpty()
.ForEach(x =>
{
DotNetNuGetPush(s => s
.SetTargetPath(OutputDirectory / x)
.SetSource("https://api.nuget.org/v3/index.json")
.SetApiKey(NUGET_API_KEY));
});
});
Target Ci => _ => _
.DependsOn(Test);
Target CiPublish => _ => _
.DependsOn(Publish);
/// Support plugins are available for:
/// - JetBrains ReSharper https://nuke.build/resharper
/// - JetBrains Rider https://nuke.build/rider
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode
public static int Main() => Execute<Build>(x => x.Package);
}