diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df0f17c..7a801aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -24,6 +24,7 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: | + 3.1.x 5.0.x 6.0.x @@ -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" diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 256f258..c68b7e2 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: jobs: - build: + build-test-and-deploy: runs-on: ubuntu-latest @@ -20,6 +20,7 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: | + 3.1.x 5.0.x 6.0.x diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 8cbf13a..3f6407a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: jobs: - build: + calculate-code-coverage: runs-on: ubuntu-latest @@ -19,6 +19,7 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: | + 3.1.x 5.0.x 6.0.x @@ -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 diff --git a/samples/Orleans.SyncWork.Demo.Api.Benchmark/Benchy.cs b/samples/Orleans.SyncWork.Demo.Api.Benchmark/Benchy.cs index dcabcfc..02c275d 100644 --- a/samples/Orleans.SyncWork.Demo.Api.Benchmark/Benchy.cs +++ b/samples/Orleans.SyncWork.Demo.Api.Benchmark/Benchy.cs @@ -14,8 +14,8 @@ 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] @@ -23,7 +23,7 @@ public void Serial() { for (var i = 0; i < TotalNumberPerBenchmark; i++) { - _passwordVerifier.VerifyPassword(IPasswordVerifier.PasswordHash, IPasswordVerifier.Password); + _passwordVerifier.VerifyPassword(PasswordConstants.PasswordHash, PasswordConstants.Password); } } @@ -33,7 +33,7 @@ public async Task MultipleTasks() var tasks = new List(); 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); @@ -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); diff --git a/samples/Orleans.SyncWork.Demo.Services/Grains/PasswordVerifier.cs b/samples/Orleans.SyncWork.Demo.Services/Grains/PasswordVerifier.cs index 75bdd1c..aa4a730 100644 --- a/samples/Orleans.SyncWork.Demo.Services/Grains/PasswordVerifier.cs +++ b/samples/Orleans.SyncWork.Demo.Services/Grains/PasswordVerifier.cs @@ -27,11 +27,11 @@ protected override async Task 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; } } diff --git a/samples/Orleans.SyncWork.Demo.Services/IPasswordVerifier.cs b/samples/Orleans.SyncWork.Demo.Services/IPasswordVerifier.cs index 464b467..0111643 100644 --- a/samples/Orleans.SyncWork.Demo.Services/IPasswordVerifier.cs +++ b/samples/Orleans.SyncWork.Demo.Services/IPasswordVerifier.cs @@ -7,9 +7,6 @@ namespace Orleans.SyncWork.Demo.Services; /// 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"; - /// /// Exposes a means of verifying a password hash against a password /// diff --git a/samples/Orleans.SyncWork.Demo.Services/Orleans.SyncWork.Demo.Services.csproj b/samples/Orleans.SyncWork.Demo.Services/Orleans.SyncWork.Demo.Services.csproj index 1170c7a..3f07d66 100644 --- a/samples/Orleans.SyncWork.Demo.Services/Orleans.SyncWork.Demo.Services.csproj +++ b/samples/Orleans.SyncWork.Demo.Services/Orleans.SyncWork.Demo.Services.csproj @@ -1,7 +1,7 @@ - net5.0;net6.0 + netstandard2.0 10 false diff --git a/samples/Orleans.SyncWork.Demo.Services/PasswordConstants.cs b/samples/Orleans.SyncWork.Demo.Services/PasswordConstants.cs new file mode 100644 index 0000000..7482dba --- /dev/null +++ b/samples/Orleans.SyncWork.Demo.Services/PasswordConstants.cs @@ -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"; +} diff --git a/samples/Orleans.SyncWork.Demo.Services/TestGrains/GrainThatWaitsSetTimePriorToExceptionResultBecomingAvailable.cs b/samples/Orleans.SyncWork.Demo.Services/TestGrains/GrainThatWaitsSetTimePriorToExceptionResultBecomingAvailable.cs index aa92a02..92ceb07 100644 --- a/samples/Orleans.SyncWork.Demo.Services/TestGrains/GrainThatWaitsSetTimePriorToExceptionResultBecomingAvailable.cs +++ b/samples/Orleans.SyncWork.Demo.Services/TestGrains/GrainThatWaitsSetTimePriorToExceptionResultBecomingAvailable.cs @@ -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 diff --git a/samples/Orleans.SyncWork.Demo.Services/TestGrains/GrainThatWaitsSetTimePriorToSuccessResultBecomingAvailable.cs b/samples/Orleans.SyncWork.Demo.Services/TestGrains/GrainThatWaitsSetTimePriorToSuccessResultBecomingAvailable.cs index 7179767..4bb324b 100644 --- a/samples/Orleans.SyncWork.Demo.Services/TestGrains/GrainThatWaitsSetTimePriorToSuccessResultBecomingAvailable.cs +++ b/samples/Orleans.SyncWork.Demo.Services/TestGrains/GrainThatWaitsSetTimePriorToSuccessResultBecomingAvailable.cs @@ -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; } diff --git a/src/Orleans.SyncWork/Orleans.SyncWork.csproj b/src/Orleans.SyncWork/Orleans.SyncWork.csproj index 3d8c944..c903be4 100644 --- a/src/Orleans.SyncWork/Orleans.SyncWork.csproj +++ b/src/Orleans.SyncWork/Orleans.SyncWork.csproj @@ -1,7 +1,7 @@  - net5.0;net6.0 + netstandard2.0 10 diff --git a/test/Orleans.SyncWork.Tests/BCryptAssumptionTests.cs b/test/Orleans.SyncWork.Tests/BCryptAssumptionTests.cs index 80dc2c3..a69ce5b 100644 --- a/test/Orleans.SyncWork.Tests/BCryptAssumptionTests.cs +++ b/test/Orleans.SyncWork.Tests/BCryptAssumptionTests.cs @@ -9,7 +9,7 @@ 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(); } @@ -17,9 +17,9 @@ public void WhenGivenCorrectPasswordAndHash_ShouldReturnTrue() [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(); } diff --git a/test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj b/test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj index 996437a..4c51d77 100644 --- a/test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj +++ b/test/Orleans.SyncWork.Tests/Orleans.SyncWork.Tests.csproj @@ -1,7 +1,7 @@  - net5.0;net6.0 + netcoreapp3.1;net5.0;net6.0 10 false diff --git a/test/Orleans.SyncWork.Tests/SyncWorkerExtensionMethodTests.cs b/test/Orleans.SyncWork.Tests/SyncWorkerExtensionMethodTests.cs index df8abec..7a7b1cb 100644 --- a/test/Orleans.SyncWork.Tests/SyncWorkerExtensionMethodTests.cs +++ b/test/Orleans.SyncWork.Tests/SyncWorkerExtensionMethodTests.cs @@ -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); @@ -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); @@ -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" }; diff --git a/test/Orleans.SyncWork.Tests/SyncWorkerTests.cs b/test/Orleans.SyncWork.Tests/SyncWorkerTests.cs index 64f9984..a9e946c 100644 --- a/test/Orleans.SyncWork.Tests/SyncWorkerTests.cs +++ b/test/Orleans.SyncWork.Tests/SyncWorkerTests.cs @@ -30,8 +30,8 @@ public async Task WhenGivenNumberOfRequests_SystemShouldNotBecomeOverloaded(int var tasks = new List>(); var request = new PasswordVerifierRequest { - Password = IPasswordVerifier.Password, - PasswordHash = IPasswordVerifier.PasswordHash + Password = PasswordConstants.Password, + PasswordHash = PasswordConstants.PasswordHash }; for (var i = 0; i < totalInvokes; i++) { @@ -57,8 +57,8 @@ public async Task WhenGivenLargeNumberOfRequests_SystemShouldNotBecomeOverloaded var tasks = new List>(); var request = new PasswordVerifierRequest { - Password = IPasswordVerifier.Password, - PasswordHash = IPasswordVerifier.PasswordHash + Password = PasswordConstants.Password, + PasswordHash = PasswordConstants.PasswordHash }; for (var i = 0; i < 10_000; i++) {