Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates SyncWork to target netstandard2.0 rather than net5 and net6 #24

Merged
merged 4 commits into from
Dec 12, 2021
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
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ on:
branches: [ main ]

jobs:
build:
build-and-test:

runs-on: ubuntu-latest
strategy:
matrix:
target-framework: [ 'net5.0', 'net6.0' ]
target-framework: [ 'netcoreapp3.1', 'net5.0', 'net6.0' ]

name: Dotnet build and test targetting ${{ matrix.target-framework }}
name: dotnet build and test targetting ${{ matrix.target-framework }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x

Expand All @@ -34,4 +35,4 @@ jobs:
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj -f net6.0 -c Release --no-build --verbosity normal --filter "Category!=LongRunning"
run: dotnet test test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj -f ${{ matrix.target-framework }} -c Release --no-build --verbosity normal --filter "Category!=LongRunning"
3 changes: 2 additions & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

jobs:
build:
build-test-and-deploy:

runs-on: ubuntu-latest

Expand All @@ -20,6 +20,7 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

jobs:
build:
calculate-code-coverage:

runs-on: ubuntu-latest

Expand All @@ -19,6 +19,7 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x

Expand All @@ -29,7 +30,7 @@ jobs:
run: dotnet build -c Release --no-restore

- name: Test w/ coverage
run: dotnet test test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj -f net6.0 -c Release --no-build --verbosity normal --filter "Category!=LongRunning" /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
run: dotnet test test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj -c Release --no-build --verbosity normal --filter "Category!=LongRunning" /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov

- name: Upload coverage
uses: coverallsapp/github-action@master
Expand Down
10 changes: 5 additions & 5 deletions samples/Orleans.SyncWork.Demo.Api.Benchmark/Benchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public class Benchy
private readonly IPasswordVerifier _passwordVerifier = new Services.PasswordVerifier();
private readonly PasswordVerifierRequest _request = new PasswordVerifierRequest()
{
Password = IPasswordVerifier.Password,
PasswordHash = IPasswordVerifier.PasswordHash
Password = PasswordConstants.Password,
PasswordHash = PasswordConstants.PasswordHash
};

[Benchmark]
public void Serial()
{
for (var i = 0; i < TotalNumberPerBenchmark; i++)
{
_passwordVerifier.VerifyPassword(IPasswordVerifier.PasswordHash, IPasswordVerifier.Password);
_passwordVerifier.VerifyPassword(PasswordConstants.PasswordHash, PasswordConstants.Password);
}
}

Expand All @@ -33,7 +33,7 @@ public async Task MultipleTasks()
var tasks = new List<Task>();
for (var i = 0; i < TotalNumberPerBenchmark; i++)
{
tasks.Add(_passwordVerifier.VerifyPassword(IPasswordVerifier.PasswordHash, IPasswordVerifier.Password));
tasks.Add(_passwordVerifier.VerifyPassword(PasswordConstants.PasswordHash, PasswordConstants.Password));
}

await Task.WhenAll(tasks);
Expand All @@ -46,7 +46,7 @@ public async Task MultipleParallelTasks()

Parallel.For(0, TotalNumberPerBenchmark, _ =>
{
tasks.Add(_passwordVerifier.VerifyPassword(IPasswordVerifier.PasswordHash, IPasswordVerifier.Password));
tasks.Add(_passwordVerifier.VerifyPassword(PasswordConstants.PasswordHash, PasswordConstants.Password));
});

await Task.WhenAll(tasks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ protected override async Task<PasswordVerifierResult> PerformWork(PasswordVerifi
}
public class PasswordVerifierRequest
{
public string Password { get; init; }
public string PasswordHash { get; init; }
public string Password { get; set; }
public string PasswordHash { get; set; }
}

public class PasswordVerifierResult
{
public bool IsValid { get; init; }
public bool IsValid { get; set; }
}
3 changes: 0 additions & 3 deletions samples/Orleans.SyncWork.Demo.Services/IPasswordVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ namespace Orleans.SyncWork.Demo.Services;
/// </summary>
public interface IPasswordVerifier
{
public const string Password = "my super neat password that's totally secure because it's super long";
public const string PasswordHash = "$2a$11$vBzJ4Ewx28C127AG5x3kT.QCCS8ai0l4JLX3VOX3MzHRkF4/A5twy";

/// <summary>
/// Exposes a means of verifying a password hash against a password
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
7 changes: 7 additions & 0 deletions samples/Orleans.SyncWork.Demo.Services/PasswordConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Orleans.SyncWork.Demo.Services;

public static class PasswordConstants
{
public const string Password = "my super neat password that's totally secure because it's super long";
public const string PasswordHash = "$2a$11$vBzJ4Ewx28C127AG5x3kT.QCCS8ai0l4JLX3VOX3MzHRkF4/A5twy";
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public TestGrainException(string message) : base(message) { }

public class TestDelayExceptionRequest
{
public int MsDelayPriorToResult { get; init; }
public int MsDelayPriorToResult { get; set; }
}

public class TestDelayExceptionResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace Orleans.SyncWork.Demo.Services.TestGrains;

public class TestDelaySuccessRequest
{
public DateTime Started { get; init; }
public int MsDelayPriorToResult { get; init; }
public DateTime Started { get; set; }
public int MsDelayPriorToResult { get; set; }
}

public class TestDelaySuccessResult
{
public DateTime Started { get; init; }
public DateTime Ended { get; init; }
public DateTime Started { get; set; }
public DateTime Ended { get; set; }

public TimeSpan Duration => Ended - Started;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.SyncWork/Orleans.SyncWork.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions test/Orleans.SyncWork.Tests/BCryptAssumptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ public class BCryptAssumptionTests
[Fact]
public void WhenGivenCorrectPasswordAndHash_ShouldReturnTrue()
{
var verifyResult = BCrypt.Net.BCrypt.Verify(IPasswordVerifier.Password, IPasswordVerifier.PasswordHash);
var verifyResult = BCrypt.Net.BCrypt.Verify(PasswordConstants.Password, PasswordConstants.PasswordHash);

verifyResult.Should().BeTrue();
}

[Fact]
public void WhenGivenIncorrectPasswordAndHash_ShouldReturnFalse()
{
var mangledPassword = IPasswordVerifier.Password + "doots ";
var mangledPassword = PasswordConstants.Password + "doots ";

var verifyResult = BCrypt.Net.BCrypt.Verify(mangledPassword, IPasswordVerifier.PasswordHash);
var verifyResult = BCrypt.Net.BCrypt.Verify(mangledPassword, PasswordConstants.PasswordHash);

verifyResult.Should().BeFalse();
}
Expand Down
2 changes: 1 addition & 1 deletion test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
10 changes: 5 additions & 5 deletions test/Orleans.SyncWork.Tests/SyncWorkerExtensionMethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public async Task WhenGivenValidPasswordAndHash_ShouldVerify()

var request = new PasswordVerifierRequest
{
Password = IPasswordVerifier.Password,
PasswordHash = IPasswordVerifier.PasswordHash
Password = PasswordConstants.Password,
PasswordHash = PasswordConstants.PasswordHash
};

var result = await grain.StartWorkAndPollUntilResult(request);
Expand All @@ -42,8 +42,8 @@ public async Task WhenGivenInvalidPasswordAndHash_ShouldNotVerify()

var request = new PasswordVerifierRequest
{
Password = IPasswordVerifier.Password + "doot",
PasswordHash = IPasswordVerifier.PasswordHash
Password = PasswordConstants.Password + "doot",
PasswordHash = PasswordConstants.PasswordHash
};

var result = await grain.StartWorkAndPollUntilResult(request);
Expand All @@ -58,7 +58,7 @@ public async Task WhenGivenBadHashFormat_ShouldException()

var request = new PasswordVerifierRequest
{
Password = IPasswordVerifier.Password,
Password = PasswordConstants.Password,
PasswordHash = "this is an invalid hash"
};

Expand Down
8 changes: 4 additions & 4 deletions test/Orleans.SyncWork.Tests/SyncWorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public async Task WhenGivenNumberOfRequests_SystemShouldNotBecomeOverloaded(int
var tasks = new List<Task<PasswordVerifierResult>>();
var request = new PasswordVerifierRequest
{
Password = IPasswordVerifier.Password,
PasswordHash = IPasswordVerifier.PasswordHash
Password = PasswordConstants.Password,
PasswordHash = PasswordConstants.PasswordHash
};
for (var i = 0; i < totalInvokes; i++)
{
Expand All @@ -57,8 +57,8 @@ public async Task WhenGivenLargeNumberOfRequests_SystemShouldNotBecomeOverloaded
var tasks = new List<Task<PasswordVerifierResult>>();
var request = new PasswordVerifierRequest
{
Password = IPasswordVerifier.Password,
PasswordHash = IPasswordVerifier.PasswordHash
Password = PasswordConstants.Password,
PasswordHash = PasswordConstants.PasswordHash
};
for (var i = 0; i < 10_000; i++)
{
Expand Down