Skip to content

Commit 0e9456d

Browse files
authored
Merge pull request #167 from graphql-dotnet/actions-on-linux
Actions on linux
2 parents 2446f80 + 43e8201 commit 0e9456d

File tree

9 files changed

+230
-68
lines changed

9 files changed

+230
-68
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Branch workflow (Ubuntu)
2+
on:
3+
push:
4+
branches-ignore:
5+
- develop
6+
- 'release/**'
7+
- 'releases/**'
8+
env:
9+
DOTNET_CLI_TELEMETRY_OPTOUT: true
10+
jobs:
11+
generateVersionInfo:
12+
name: GenerateVersionInfo
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
- name: Restore dotnet tools
20+
run: dotnet tool restore
21+
- name: Fetch complete repository
22+
run: git fetch
23+
- name: Generate version info from git history
24+
run: dotnet gitversion /output json > gitversion.json
25+
- name: Upload version info file
26+
uses: actions/upload-artifact@v1
27+
with:
28+
name: gitversion
29+
path: gitversion.json
30+
31+
build:
32+
name: Build
33+
needs: generateVersionInfo
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v2
38+
- name: Download version info file
39+
uses: actions/download-artifact@v1
40+
with:
41+
name: gitversion
42+
path: ./
43+
- name: Inject version info into environment
44+
run: jq -r 'to_entries|map("::set-env name=GitVersion_\(.key)::\(.value|tostring)")|.[]' gitversion.json
45+
- name: Build solution
46+
run: echo "Current version is \"$GitVersion_SemVer\"" && dotnet build -c Release
47+
- name: Create NuGet packages
48+
run: dotnet pack -c Release --no-build -o nupkg
49+
- name: Upload nuget packages
50+
uses: actions/upload-artifact@v1
51+
with:
52+
name: nupkg
53+
path: nupkg
54+
55+
test:
56+
name: Test
57+
needs: [build, generateVersionInfo]
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v2
62+
- name: Download version info file
63+
uses: actions/download-artifact@v1
64+
with:
65+
name: gitversion
66+
path: ./
67+
- name: Inject version info into environment
68+
run: jq -r 'to_entries|map("::set-env name=GitVersion_\(.key)::\(.value|tostring)")|.[]' gitversion.json
69+
- name: Run tests
70+
run: echo "Current version is \"$GitVersion_SemVer\"" && dotnet test -c Release

.github/workflows/branches.yml renamed to .github/workflows/branches-windows.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: Branch workflow
2-
on:
2+
on:
33
push:
44
branches-ignore:
5-
- develop
6-
- 'release/**'
7-
- 'releases/**'
5+
- '**'
86
jobs:
97
generateVersionInfo:
108
name: GenerateVersionInfo

.github/workflows/main-ubuntu.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Main workflow (Ubuntu)
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- 'release/**'
7+
- 'releases/**'
8+
tags:
9+
- v*
10+
- V*
11+
env:
12+
DOTNET_CLI_TELEMETRY_OPTOUT: true
13+
jobs:
14+
generateVersionInfo:
15+
name: GenerateVersionInfo
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
- name: Restore dotnet tools
23+
run: dotnet tool restore
24+
- name: Fetch complete repository
25+
run: git fetch
26+
- name: Generate version info from git history
27+
run: dotnet gitversion /output json > gitversion.json
28+
- name: Upload version info file
29+
uses: actions/upload-artifact@v1
30+
with:
31+
name: gitversion
32+
path: gitversion.json
33+
34+
build:
35+
name: Build
36+
needs: generateVersionInfo
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v2
41+
- name: Download version info file
42+
uses: actions/download-artifact@v1
43+
with:
44+
name: gitversion
45+
path: ./
46+
- name: Inject version info into environment
47+
run: jq -r 'to_entries|map("::set-env name=GitVersion_\(.key)::\(.value|tostring)")|.[]' gitversion.json
48+
- name: Build solution
49+
run: echo "Current version is \"$GitVersion_SemVer\"" && dotnet build -c Release
50+
- name: Create NuGet packages
51+
run: dotnet pack -c Release --no-build -o nupkg
52+
- name: Upload nuget packages
53+
uses: actions/upload-artifact@v1
54+
with:
55+
name: nupkg
56+
path: nupkg
57+
58+
test:
59+
name: Test
60+
needs: [build, generateVersionInfo]
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v2
65+
- name: Download version info file
66+
uses: actions/download-artifact@v1
67+
with:
68+
name: gitversion
69+
path: ./
70+
- name: Inject version info into environment
71+
run: jq -r 'to_entries|map("::set-env name=GitVersion_\(.key)::\(.value|tostring)")|.[]' gitversion.json
72+
- name: Run tests
73+
run: echo "Current version is \"$GitVersion_SemVer\"" && dotnet test -c Release
74+
75+
publish:
76+
name: Publish
77+
needs: [test]
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v2
82+
- name: Download nuget packages
83+
uses: actions/download-artifact@v1
84+
with:
85+
name: nupkg
86+
- name: Publish the package to GPR
87+
# using workaround with CURL because of non-functioning upload via dotnet nuget (https://stackoverflow.com/a/58943251)
88+
run: |
89+
for f in ./nupkg/*.nupkg
90+
do
91+
curl -vX PUT -u "graphql-dotnet:${{secrets.GITHUB_TOKEN}}" -F package=@$f https://nuget.pkg.github.com/graphql-dotnet/
92+
done

.github/workflows/main.yml renamed to .github/workflows/main-windows.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
name: Main workflow
2-
on:
2+
on:
33
push:
4-
branches:
5-
- develop
6-
- 'release/**'
7-
- 'releases/**'
8-
tags:
9-
- v*
10-
- V*
4+
branches-ignore:
5+
- '**'
116
jobs:
127
generateVersionInfo:
138
name: GenerateVersionInfo

GitVersion.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
branches:
2-
release:
3-
mode: ContinuousDeployment
1+
mode: ContinuousDeployment

GraphQL.Client.sln

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@ EndProject
3232
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Server.Test", "tests\GraphQL.Server.Test\GraphQL.Server.Test.csproj", "{E95A1258-F666-4D4E-9101-E0C46F6A3CB3}"
3333
EndProject
3434
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{C42106CF-F685-4F29-BC18-A70616BD68A0}"
35-
ProjectSection(SolutionItems) = preProject
36-
.github\FUNDING.yml = .github\FUNDING.yml
37-
EndProjectSection
3835
EndProject
3936
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{05CAF9B2-981E-40C0-AE31-5FA56E351F12}"
4037
ProjectSection(SolutionItems) = preProject
38+
.github\workflows\branches-ubuntu.yml = .github\workflows\branches-ubuntu.yml
4139
.github\workflows\branches.yml = .github\workflows\branches.yml
4240
.github\workflows\main.yml = .github\workflows\main.yml
4341
EndProjectSection
@@ -68,7 +66,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Client.Serializer.T
6866
EndProject
6967
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Client.Tests.Common", "tests\GraphQL.Client.Tests.Common\GraphQL.Client.Tests.Common.csproj", "{0D307BAD-27AE-4A5D-8764-4AA2620B01E9}"
7068
EndProject
71-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL.Client.Serializer.SystemTextJson", "src\GraphQL.Client.Serializer.SystemTextJson\GraphQL.Client.Serializer.SystemTextJson.csproj", "{7FFFEC00-D751-4FFC-9FD4-E91858F9A1C5}"
69+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Client.Serializer.SystemTextJson", "src\GraphQL.Client.Serializer.SystemTextJson\GraphQL.Client.Serializer.SystemTextJson.csproj", "{7FFFEC00-D751-4FFC-9FD4-E91858F9A1C5}"
7270
EndProject
7371
Global
7472
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -138,6 +136,7 @@ Global
138136
EndGlobalSection
139137
GlobalSection(NestedProjects) = preSolution
140138
{E95A1258-F666-4D4E-9101-E0C46F6A3CB3} = {0B0EDB0F-FF67-4B78-A8DB-B5C23E1FEE8C}
139+
{05CAF9B2-981E-40C0-AE31-5FA56E351F12} = {C42106CF-F685-4F29-BC18-A70616BD68A0}
141140
{95D78D57-3232-491D-BAD6-F373D76EA34D} = {D61415CA-D822-43DD-9AE7-993B8B60E855}
142141
{87FC440E-6A4D-47D8-9EB2-416FC31CC4A6} = {47C98B55-08F1-4428-863E-2C5C876DEEFE}
143142
{C212983F-67DB-44EB-BFB0-5DA75A86DF55} = {0B0EDB0F-FF67-4B78-A8DB-B5C23E1FEE8C}

src/GraphQL.Client/GraphQL.Client.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
<ItemGroup>
2828
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
29+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
2930
</ItemGroup>
3031

3132
<ItemGroup Condition=" '$(TargetFramework)' == 'net461'">
@@ -38,4 +39,7 @@
3839
<ProjectReference Include="..\GraphQL.Client.Serializer.Newtonsoft\GraphQL.Client.Serializer.Newtonsoft.csproj" />
3940
</ItemGroup>
4041

42+
43+
44+
4145
</Project>

tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using FluentAssertions.Primitives;
88

99
namespace GraphQL.Client.Tests.Common.Helpers {
10-
public class ObservableTester<TPayload> : IDisposable {
10+
public class ObservableTester<TSubscriptionPayload> : IDisposable {
1111
private readonly IDisposable subscription;
1212
private readonly ManualResetEventSlim updateReceived = new ManualResetEventSlim();
1313
private readonly ManualResetEventSlim completed = new ManualResetEventSlim();
@@ -25,15 +25,15 @@ public class ObservableTester<TPayload> : IDisposable {
2525
/// <summary>
2626
/// The last payload which was received.
2727
/// </summary>
28-
public TPayload LastPayload { get; private set; }
28+
public TSubscriptionPayload LastPayload { get; private set; }
2929

3030
public Exception Error { get; private set; }
3131

3232
/// <summary>
3333
/// Creates a new <see cref="ObservableTester{T}"/> which subscribes to the supplied <see cref="IObservable{T}"/>
3434
/// </summary>
3535
/// <param name="observable">the <see cref="IObservable{T}"/> under test</param>
36-
public ObservableTester(IObservable<TPayload> observable) {
36+
public ObservableTester(IObservable<TSubscriptionPayload> observable) {
3737
subscription = observable.ObserveOn(TaskPoolScheduler.Default).Subscribe(
3838
obj => {
3939
LastPayload = obj;
@@ -59,8 +59,8 @@ public void Dispose() {
5959
subscription?.Dispose();
6060
}
6161

62-
public SubscriptionAssertions<TPayload> Should() {
63-
return new SubscriptionAssertions<TPayload>(this);
62+
public SubscriptionAssertions<TSubscriptionPayload> Should() {
63+
return new SubscriptionAssertions<TSubscriptionPayload>(this);
6464
}
6565

6666
public class SubscriptionAssertions<TPayload> : ReferenceTypeAssertions<ObservableTester<TPayload>, SubscriptionAssertions<TPayload>> {

tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
2+
using System.Collections.Concurrent;
23
using System.Diagnostics;
34
using System.Net.WebSockets;
45
using System.Threading;
5-
using System.Threading.Tasks;
66
using FluentAssertions;
77
using GraphQL.Client.Abstractions;
88
using GraphQL.Client.Abstractions.Websocket;
@@ -247,49 +247,55 @@ public async void CanHandleConnectionTimeout() {
247247
return TimeSpan.Zero;
248248
};
249249

250-
var statusMonitor = client.WebsocketConnectionState.Monitor();
251-
statusMonitor.Should().HaveReceivedPayload().Which.Should()
252-
.Be(GraphQLWebsocketConnectionState.Disconnected);
253-
254-
Debug.WriteLine("creating subscription stream");
255-
IObservable<GraphQLResponse<MessageAddedSubscriptionResult>> observable = client.CreateSubscriptionStream<MessageAddedSubscriptionResult>(SubscriptionRequest, errorMonitor.Invoke);
256-
257-
Debug.WriteLine("subscribing...");
258-
var tester = observable.Monitor();
259-
statusMonitor.Should().HaveReceivedPayload().Which.Should()
260-
.Be(GraphQLWebsocketConnectionState.Connecting);
261-
statusMonitor.Should().HaveReceivedPayload().Which.Should()
262-
.Be(GraphQLWebsocketConnectionState.Connected);
263-
callbackMonitor.Should().HaveBeenInvokedWithPayload();
264-
const string message1 = "Hello World";
265-
266-
var response = await client.AddMessageAsync(message1).ConfigureAwait(false);
267-
response.Data.AddMessage.Content.Should().Be(message1);
268-
tester.Should().HaveReceivedPayload()
269-
.Which.Data.MessageAdded.Content.Should().Be(message1);
270-
271-
Debug.WriteLine("stopping web host...");
272-
await server.StopAsync(CancellationToken.None).ConfigureAwait(false);
273-
server.Dispose();
274-
Debug.WriteLine("web host stopped...");
275-
276-
errorMonitor.Should().HaveBeenInvokedWithPayload(TimeSpan.FromSeconds(10))
277-
.Which.Should().BeOfType<WebSocketException>();
278-
statusMonitor.Should().HaveReceivedPayload().Which.Should()
279-
.Be(GraphQLWebsocketConnectionState.Disconnected);
280-
281-
server = CreateServer(port);
282-
reconnectBlocker.Set();
283-
statusMonitor.Should().HaveReceivedPayload(TimeSpan.FromSeconds(10)).Which.Should()
284-
.Be(GraphQLWebsocketConnectionState.Connecting);
285-
statusMonitor.Should().HaveReceivedPayload(TimeSpan.FromSeconds(10)).Which.Should()
286-
.Be(GraphQLWebsocketConnectionState.Connected);
287-
callbackMonitor.Should().HaveBeenInvokedWithPayload();
288-
289-
// disposing the client should complete the subscription
290-
client.Dispose();
291-
tester.Should().HaveCompleted(TimeSpan.FromSeconds(5));
292-
server.Dispose();
250+
var websocketStates = new ConcurrentQueue<GraphQLWebsocketConnectionState>();
251+
252+
using (client.WebsocketConnectionState.Subscribe(websocketStates.Enqueue)) {
253+
websocketStates.Should().ContainSingle(state => state == GraphQLWebsocketConnectionState.Disconnected);
254+
255+
Debug.WriteLine("creating subscription stream");
256+
IObservable<GraphQLResponse<MessageAddedSubscriptionResult>> observable =
257+
client.CreateSubscriptionStream<MessageAddedSubscriptionResult>(SubscriptionRequest,
258+
errorMonitor.Invoke);
259+
260+
Debug.WriteLine("subscribing...");
261+
var tester = observable.Monitor();
262+
callbackMonitor.Should().HaveBeenInvokedWithPayload();
263+
264+
websocketStates.Should().ContainInOrder(
265+
GraphQLWebsocketConnectionState.Disconnected,
266+
GraphQLWebsocketConnectionState.Connecting,
267+
GraphQLWebsocketConnectionState.Connected);
268+
// clear the collection so the next tests on the collection work as expected
269+
websocketStates.Clear();
270+
271+
const string message1 = "Hello World";
272+
var response = await client.AddMessageAsync(message1).ConfigureAwait(false);
273+
response.Data.AddMessage.Content.Should().Be(message1);
274+
tester.Should().HaveReceivedPayload()
275+
.Which.Data.MessageAdded.Content.Should().Be(message1);
276+
277+
Debug.WriteLine("stopping web host...");
278+
await server.StopAsync(CancellationToken.None).ConfigureAwait(false);
279+
server.Dispose();
280+
Debug.WriteLine("web host stopped...");
281+
282+
errorMonitor.Should().HaveBeenInvokedWithPayload(TimeSpan.FromSeconds(10))
283+
.Which.Should().BeOfType<WebSocketException>();
284+
websocketStates.Should().Contain(GraphQLWebsocketConnectionState.Disconnected);
285+
286+
server = CreateServer(port);
287+
reconnectBlocker.Set();
288+
callbackMonitor.Should().HaveBeenInvokedWithPayload();
289+
websocketStates.Should().ContainInOrder(
290+
GraphQLWebsocketConnectionState.Disconnected,
291+
GraphQLWebsocketConnectionState.Connecting,
292+
GraphQLWebsocketConnectionState.Connected);
293+
294+
// disposing the client should complete the subscription
295+
client.Dispose();
296+
tester.Should().HaveCompleted(TimeSpan.FromSeconds(5));
297+
server.Dispose();
298+
}
293299
}
294300

295301

0 commit comments

Comments
 (0)