mirror of
https://github.com/Biarity/Sieve.git
synced 2025-09-19 06:39:43 +02:00
Compare commits
15 Commits
ci-release
...
releases/3
Author | SHA1 | Date | |
---|---|---|---|
|
aedbc1ed96 | ||
|
2c9d907764 | ||
|
8bd9ce85d9 | ||
|
f738e3bf1e | ||
|
dd1b0a9edc | ||
|
27838b062c | ||
|
38af9af982 | ||
|
d188bed4f0 | ||
|
1e29271fd9 | ||
|
034730bffb | ||
|
79c825cb7a | ||
|
028ab1d196 | ||
|
9277690e96 | ||
|
d5474478b3 | ||
|
4c5510772a |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -17,12 +17,10 @@
|
|||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- 'releases/*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-latest:
|
ubuntu-latest:
|
||||||
|
33
.github/workflows/ci_publish.yml
vendored
Normal file
33
.github/workflows/ci_publish.yml
vendored
Normal 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 }}
|
@@ -43,6 +43,9 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Disables displaying the NUKE logo"
|
"description": "Disables displaying the NUKE logo"
|
||||||
},
|
},
|
||||||
|
"NUGET_API_KEY": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"Plan": {
|
"Plan": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Shows the execution plan (HTML)"
|
"description": "Shows the execution plan (HTML)"
|
||||||
@@ -65,9 +68,11 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"Ci",
|
"Ci",
|
||||||
|
"CiPublish",
|
||||||
"Clean",
|
"Clean",
|
||||||
"Compile",
|
"Compile",
|
||||||
"Package",
|
"Package",
|
||||||
|
"Publish",
|
||||||
"Restore",
|
"Restore",
|
||||||
"Test"
|
"Test"
|
||||||
]
|
]
|
||||||
@@ -84,9 +89,11 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"Ci",
|
"Ci",
|
||||||
|
"CiPublish",
|
||||||
"Clean",
|
"Clean",
|
||||||
"Compile",
|
"Compile",
|
||||||
"Package",
|
"Package",
|
||||||
|
"Publish",
|
||||||
"Restore",
|
"Restore",
|
||||||
"Test"
|
"Test"
|
||||||
]
|
]
|
||||||
|
@@ -0,0 +1,3 @@
|
|||||||
|
branches:
|
||||||
|
release:
|
||||||
|
mode: ContinuousDeployment
|
@@ -2,12 +2,27 @@
|
|||||||
{
|
{
|
||||||
public class SieveOptions
|
public class SieveOptions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// If flag is set, property names have to match including case sensitivity.
|
||||||
|
/// </summary>
|
||||||
public bool CaseSensitive { get; set; } = false;
|
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;
|
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 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -377,7 +377,11 @@ namespace Sieve.Services
|
|||||||
{
|
{
|
||||||
var page = model?.Page ?? 1;
|
var page = model?.Page ?? 1;
|
||||||
var pageSize = model?.PageSize ?? _options.Value.DefaultPageSize;
|
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)
|
if (pageSize <= 0)
|
||||||
{
|
{
|
||||||
@@ -385,7 +389,7 @@ namespace Sieve.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = result.Skip((page - 1) * pageSize);
|
result = result.Skip((page - 1) * pageSize);
|
||||||
result = result.Take(Math.Min(pageSize, maxPageSize));
|
result = result.Take(pageSize);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -613,5 +613,44 @@ namespace SieveUnitTests
|
|||||||
Assert.Equal(1,posts[2].Id);
|
Assert.Equal(1,posts[2].Id);
|
||||||
Assert.Equal(0,posts[3].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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using GlobExpressions;
|
||||||
using Nuke.Common;
|
using Nuke.Common;
|
||||||
using Nuke.Common.CI;
|
using Nuke.Common.CI;
|
||||||
using Nuke.Common.CI.GitHubActions;
|
using Nuke.Common.CI.GitHubActions;
|
||||||
@@ -8,17 +9,23 @@ using Nuke.Common.IO;
|
|||||||
using Nuke.Common.ProjectModel;
|
using Nuke.Common.ProjectModel;
|
||||||
using Nuke.Common.Tools.DotNet;
|
using Nuke.Common.Tools.DotNet;
|
||||||
using Nuke.Common.Tools.GitVersion;
|
using Nuke.Common.Tools.GitVersion;
|
||||||
|
using Nuke.Common.Utilities.Collections;
|
||||||
using static Nuke.Common.IO.FileSystemTasks;
|
using static Nuke.Common.IO.FileSystemTasks;
|
||||||
using static Nuke.Common.Tools.DotNet.DotNetTasks;
|
using static Nuke.Common.Tools.DotNet.DotNetTasks;
|
||||||
|
|
||||||
[CheckBuildProjectConfigurations]
|
[CheckBuildProjectConfigurations]
|
||||||
[ShutdownDotNetAfterServerBuild]
|
[ShutdownDotNetAfterServerBuild]
|
||||||
[GitHubActions("ci", GitHubActionsImage.UbuntuLatest,
|
[GitHubActions("ci", GitHubActionsImage.UbuntuLatest,
|
||||||
OnPushBranches = new[] {"master"},
|
OnPullRequestBranches = new[] {"master", "releases/*"},
|
||||||
OnPullRequestBranches = new[] {"master"},
|
|
||||||
AutoGenerate = true,
|
AutoGenerate = true,
|
||||||
InvokedTargets = new[] {nameof(Ci)},
|
InvokedTargets = new[] {nameof(Ci)},
|
||||||
CacheKeyFiles = new string[0])]
|
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
|
class Build : NukeBuild
|
||||||
{
|
{
|
||||||
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
||||||
@@ -30,6 +37,9 @@ class Build : NukeBuild
|
|||||||
|
|
||||||
[Solution] readonly Solution Solution;
|
[Solution] readonly Solution Solution;
|
||||||
|
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
[Parameter] string NUGET_API_KEY;
|
||||||
|
|
||||||
Project SieveProject => Solution.AllProjects.First(p => p.Name == "Sieve");
|
Project SieveProject => Solution.AllProjects.First(p => p.Name == "Sieve");
|
||||||
|
|
||||||
AbsolutePath OutputDirectory => RootDirectory / "output";
|
AbsolutePath OutputDirectory => RootDirectory / "output";
|
||||||
@@ -83,13 +93,29 @@ class Build : NukeBuild
|
|||||||
.EnableNoBuild());
|
.EnableNoBuild());
|
||||||
});
|
});
|
||||||
|
|
||||||
Target Ci => _ => _
|
Target Publish => _ => _
|
||||||
.DependsOn(Package);
|
.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);
|
public static int Main() => Execute<Build>(x => x.Package);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user