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

Add publish test github action #25

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 8 additions & 24 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,24 @@
name: Build and Test

on:
pull_request:
pull_request:

env:
TEST_RESULTS_PATH: ${{ github.workspace }}/test-results.trx

permissions:
contents: read
actions: read
checks: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup .NET
uses: actions/[email protected]
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
dotnet-version: 8.0.100
- name: Dotnet Build
run: dotnet build --configuration Release
- name: Dotnet Test
run: |
dotnet test --configuration Release --no-restore --no-build --logger "trx;LogFileName=${{ env.TEST_RESULTS_PATH }}"
- name: Upload test results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-results
path: ${{ env.TEST_RESULTS_PATH }}
- name: Upload test results
uses: dorny/[email protected]
if: success() || failure()
- run: dotnet build --configuration Release
- run: |
dotnet test --configuration Release --no-restore --no-build \
--logger "trx;LogFileName=${{ env.TEST_RESULTS_PATH }}"
- uses: dorny/test-reporter@v1
with:
name: XUnit Tests
path: ${{ env.TEST_RESULTS_PATH }}
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/check-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Check Changelog

on:
pull_request:

jobs:
check-changelog:
runs-on: ubuntu-latest
steps:
- uses: tarides/changelog-check-action@v2
with:
changelog: CHANGES.md
14 changes: 14 additions & 0 deletions .github/workflows/publish-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Publish Test

on:
pull_request:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
dotnet-version: 8.0.100
- run: dotnet publish
11 changes: 11 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check Typos

on:
pull_request:

jobs:
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: crate-ci/typos@v1.22.9
18 changes: 9 additions & 9 deletions src/JSSoft.Communication/Extensions/ISerializerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,34 @@ public static string[] SerializeMany(this ISerializer @this, Type[] types, objec
return items;
}

public static object?[] DeserializeMany(this ISerializer @this, Type[] types, string[] datas)
public static object?[] DeserializeMany(this ISerializer @this, Type[] types, string[] data)
{
var items = new object?[datas.Length];
for (var i = 0; i < datas.Length; i++)
var items = new object?[data.Length];
for (var i = 0; i < data.Length; i++)
{
var type = types[i];
var value = datas[i];
var value = data[i];
items[i] = @this.Deserialize(type, value);
}

return items;
}

public static object?[] DeserializeMany(
this ISerializer @this, Type[] types, string[] datas, CancellationToken? cancellationToken)
this ISerializer @this, Type[] types, string[] data, CancellationToken? cancellationToken)
{
var length = cancellationToken != null ? datas.Length + 1 : datas.Length;
var length = cancellationToken != null ? data.Length + 1 : data.Length;
var items = new object?[length];
for (var i = 0; i < datas.Length; i++)
for (var i = 0; i < data.Length; i++)
{
var type = types[i];
var value = datas[i];
var value = data[i];
items[i] = @this.Deserialize(type, value);
}

if (cancellationToken != null)
{
items[datas.Length] = cancellationToken;
items[data.Length] = cancellationToken;
}

return items;
Expand Down
2 changes: 1 addition & 1 deletion src/JSSoft.Communication/Grpc/AdaptorServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public async Task<InvokeReply> InvokeAsync(InvokeRequest request, ServerCallCont
var instance = peer.Services[service];
var args = _serializer.DeserializeMany(
types: methodDescriptor.ParameterTypes,
datas: [.. request.Data],
data: [.. request.Data],
cancellationToken: cancellationToken);
if (methodDescriptor.IsOneWay == true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/JSSoft.Communication/Grpc/Peer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void EndPolling()
}
}

public void Disconect(int closeCode)
public void Disconnect(int closeCode)
{
lock (_lockObject)
{
Expand Down
4 changes: 2 additions & 2 deletions src/JSSoft.Communication/Grpc/PeerCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public bool Remove(IServiceContext serviceContext, string id, int closeCode)
{
peer.Descriptor = null;
_instanceContext.DestroyInstance(peer);
peer.Disconect(closeCode);
peer.Disconnect(closeCode);
serviceContext.Debug($"{id} Disconnected ({closeCode})");
return true;
}
Expand All @@ -53,7 +53,7 @@ public async Task DisconnectAsync(
using var cancellationTokenSource = new CancellationTokenSource(millisecondsDelay: 3000);
foreach (var item in items)
{
item.Disconect(closeCode: 0);
item.Disconnect(closeCode: 0);
}

while (Count > 0 && cancellationTokenSource.IsCancellationRequested != true)
Expand Down
16 changes: 8 additions & 8 deletions src/JSSoft.Communication/MethodDescriptorCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace JSSoft.Communication;

public sealed class MethodDescriptorCollection : IEnumerable<MethodDescriptor>
{
private readonly Dictionary<string, MethodDescriptor> _discriptorByName;
private readonly Dictionary<string, MethodDescriptor> _descriptorByName;

internal MethodDescriptorCollection(Type type)
{
Expand All @@ -25,23 +25,23 @@ internal MethodDescriptorCollection(Type type)
{
var methodInfos = type.GetMethods();
var methodDescriptors = methodInfos.Select(item => new MethodDescriptor(item));
_discriptorByName = methodDescriptors.ToDictionary(item => item.Name);
_descriptorByName = methodDescriptors.ToDictionary(item => item.Name);
}
else
{
_discriptorByName = [];
_descriptorByName = [];
}
}

public int Count => _discriptorByName.Count;
public int Count => _descriptorByName.Count;

public MethodDescriptor this[string name] => _discriptorByName[name];
public MethodDescriptor this[string name] => _descriptorByName[name];

public bool Contains(string name) => _discriptorByName.ContainsKey(name);
public bool Contains(string name) => _descriptorByName.ContainsKey(name);

public IEnumerator<MethodDescriptor> GetEnumerator()
=> _discriptorByName.Values.GetEnumerator();
=> _descriptorByName.Values.GetEnumerator();

IEnumerator IEnumerable.GetEnumerator()
=> _discriptorByName.Values.GetEnumerator();
=> _descriptorByName.Values.GetEnumerator();
}
8 changes: 4 additions & 4 deletions test/JSSoft.Communication.Tests/ClientTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public async Task DisposeAsync()
}
}

public abstract class ClientTestBase<TService, TServerSevice> : IAsyncLifetime
public abstract class ClientTestBase<TService, TServerService> : IAsyncLifetime
where TService : class
where TServerSevice : ServerService<TService>
where TServerService : ServerService<TService>
{
private readonly ClientService<TService> _clientService = new();
private readonly ServerContext _serverContext;
Expand All @@ -70,7 +70,7 @@ public abstract class ClientTestBase<TService, TServerSevice> : IAsyncLifetime
private Guid _clientToken;
private Guid _serverToken;

protected ClientTestBase(ITestOutputHelper logger, TServerSevice serverService)
protected ClientTestBase(ITestOutputHelper logger, TServerService serverService)
{
Logger = logger;
ServerService = serverService;
Expand All @@ -82,7 +82,7 @@ protected ClientTestBase(ITestOutputHelper logger, TServerSevice serverService)

protected TService Client => _client!;

protected TServerSevice ServerService { get; }
protected TServerService ServerService { get; }

public async Task InitializeAsync()
{
Expand Down
Loading