Skip to content

Commit 8bde0a9

Browse files
committed
Fixed synchronous tests hang on the GitHub CI
1 parent d7b1708 commit 8bde0a9

File tree

4 files changed

+58
-40
lines changed

4 files changed

+58
-40
lines changed

build/Program.fs

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ open Fake.IO.FileSystemOperators
1313
open Fake.IO.Globbing.Operators
1414
open Fake.Tools
1515

16-
Path.Combine(__SOURCE_DIRECTORY__, "..")
16+
Path.Combine (__SOURCE_DIRECTORY__, "..")
1717
|> Path.GetFullPath
1818
|> Directory.SetCurrentDirectory
1919

@@ -25,8 +25,8 @@ execContext
2525
|> Fake.Core.Context.setExecutionContext
2626

2727
module DotNetCli =
28-
let setVersion (o: DotNet.Options) = { o with Version = Some "7.0.401" }
29-
let setRestoreOptions (o: DotNet.RestoreOptions)= o.WithCommon setVersion
28+
let setVersion (o : DotNet.Options) = { o with Version = Some "7.0.401" }
29+
let setRestoreOptions (o : DotNet.RestoreOptions) = o.WithCommon setVersion
3030

3131
let configurationString = Environment.environVarOrDefault "CONFIGURATION" "Release"
3232
let configuration =
@@ -66,17 +66,19 @@ Target.create "Restore" <| fun _ ->
6666

6767
Target.create "Build" <| fun _ ->
6868
"FSharp.Data.GraphQL.sln"
69-
|> DotNet.build (fun o ->
70-
{ o with
69+
|> DotNet.build (fun o -> {
70+
o with
7171
Configuration = configuration
72-
MSBuildParams = { o.MSBuildParams with DisableInternalBinLog = true } })
72+
MSBuildParams = { o.MSBuildParams with DisableInternalBinLog = true }
73+
})
7374

7475
let startGraphQLServer (project : string) port (streamRef : DataRef<Stream>) =
7576
DotNet.build
76-
(fun options ->
77-
{ options with
77+
(fun options -> {
78+
options with
7879
Configuration = configuration
79-
MSBuildParams = { options.MSBuildParams with DisableInternalBinLog = true } })
80+
MSBuildParams = { options.MSBuildParams with DisableInternalBinLog = true }
81+
})
8082
project
8183

8284
let projectName = Path.GetFileNameWithoutExtension (project)
@@ -96,20 +98,27 @@ let startGraphQLServer (project : string) port (streamRef : DataRef<Stream>) =
9698

9799
System.Threading.Thread.Sleep (2000)
98100

99-
let runTests (project : string) =
101+
let runTests (project : string) (args : string) =
100102
DotNet.build
101-
(fun options ->
102-
{ options with
103+
(fun options -> {
104+
options with
103105
Configuration = configuration
104-
MSBuildParams = { options.MSBuildParams with DisableInternalBinLog = true } })
106+
MSBuildParams = { options.MSBuildParams with DisableInternalBinLog = true }
107+
})
105108
project
106109

110+
let customParams = String.Join (' ', "--no-build -v=normal", args)
111+
107112
DotNet.test
108113
(fun options ->
109-
{ options with
110-
Configuration = configuration
111-
MSBuildParams = { options.MSBuildParams with DisableInternalBinLog = true }
112-
Common = { options.Common with CustomParams = Some "--no-build -v=normal" } }.WithCommon DotNetCli.setVersion)
114+
{
115+
options with
116+
Configuration = configuration
117+
MSBuildParams = { options.MSBuildParams with DisableInternalBinLog = true }
118+
Common = { options.Common with CustomParams = Some customParams }
119+
}
120+
.WithCommon
121+
DotNetCli.setVersion)
113122
project
114123

115124
let starWarsServerStream = StreamRef.Empty
@@ -150,27 +159,29 @@ Target.createFinal "StopIntegrationServer" <| fun _ ->
150159

151160
Target.create "UpdateIntrospectionFile" <| fun _ ->
152161
let client = new HttpClient ()
153-
(task{
154-
let! result = client.GetAsync("http://localhost:8086")
155-
let! contentStream = result.Content.ReadAsStreamAsync()
162+
(task {
163+
let! result = client.GetAsync ("http://localhost:8086")
164+
let! contentStream = result.Content.ReadAsStreamAsync ()
156165
let! jsonDocument = JsonDocument.ParseAsync contentStream
157-
let file = new FileStream("tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json", FileMode.Create, FileAccess.Write, FileShare.None)
166+
let file =
167+
new FileStream ("tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json", FileMode.Create, FileAccess.Write, FileShare.None)
158168
let encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
159-
let jsonWriterOptions = JsonWriterOptions(Indented = true, Encoder = encoder)
160-
let writer = new Utf8JsonWriter(file, jsonWriterOptions)
169+
let jsonWriterOptions = JsonWriterOptions (Indented = true, Encoder = encoder)
170+
let writer = new Utf8JsonWriter (file, jsonWriterOptions)
161171
jsonDocument.WriteTo writer
162-
do! writer.FlushAsync()
163-
do! writer.DisposeAsync()
164-
do! file.DisposeAsync()
165-
result.Dispose()
166-
}).Wait()
167-
client.Dispose()
172+
do! writer.FlushAsync ()
173+
do! writer.DisposeAsync ()
174+
do! file.DisposeAsync ()
175+
result.Dispose ()
176+
})
177+
.Wait ()
178+
client.Dispose ()
168179

169180
Target.create "RunUnitTests" <| fun _ ->
170-
runTests "tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj"
181+
runTests "tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj" ""
171182

172183
Target.create "RunIntegrationTests" <| fun _ ->
173-
runTests "tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj"
184+
runTests "tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj" "" //"--filter Execution=Sync"
174185

175186
let prepareDocGen () =
176187
Shell.rm "docs/release-notes.md"
@@ -224,9 +235,13 @@ let pack id =
224235

225236
projectPath
226237
|> DotNet.pack (fun p ->
227-
{ p with
228-
Common = { p.Common with Version = Some release.NugetVersion }
229-
OutputPath = Some packageDir }.WithCommon DotNetCli.setVersion)
238+
{
239+
p with
240+
Common = { p.Common with Version = Some release.NugetVersion }
241+
OutputPath = Some packageDir
242+
}
243+
.WithCommon
244+
DotNetCli.setVersion)
230245

231246
let publishPackage id =
232247
let packageName = getPackageName id

src/FSharp.Data.GraphQL.Client.DesignTime/ProvidedTypesHelper.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ module internal ProvidedOperation =
412412
if shouldUseMultipartRequest
413413
then Tracer.runAndMeasureExecutionTime "Ran a multipart GraphQL query request" (fun _ -> GraphQLClient.sendMultipartRequest context.Connection request)
414414
else Tracer.runAndMeasureExecutionTime "Ran a GraphQL query request" (fun _ -> GraphQLClient.sendRequest context.Connection request)
415-
let responseString = response.Content.ReadAsStringAsync().Result
415+
let responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
416416
let responseJson = Tracer.runAndMeasureExecutionTime "Parsed a GraphQL response to a JsonValue" (fun _ -> JsonValue.Parse responseString)
417417
// If the user does not provide a context, we should dispose the default one after running the query
418418
if isDefaultContext then (context :> IDisposable).Dispose()

src/FSharp.Data.GraphQL.Client/GraphQLClient.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module GraphQLClient =
7272
}
7373

7474
/// Sends a request to a GraphQL server.
75-
let sendRequest client request = (sendRequestAsync CancellationToken.None client request).Result
75+
let sendRequest client request = (sendRequestAsync CancellationToken.None client request).GetAwaiter().GetResult()
7676

7777
/// Executes an introspection schema request to a GraphQL server asynchronously.
7878
let sendIntrospectionRequestAsync ct (connection : GraphQLClientConnection) (serverUrl : string) httpHeaders =
@@ -102,7 +102,7 @@ module GraphQLClient =
102102

103103
/// Executes an introspection schema request to a GraphQL server.
104104
let sendIntrospectionRequest client serverUrl httpHeaders =
105-
(sendIntrospectionRequestAsync CancellationToken.None client serverUrl httpHeaders).Result
105+
(sendIntrospectionRequestAsync CancellationToken.None client serverUrl httpHeaders).GetAwaiter().GetResult()
106106

107107
/// Executes a multipart request to a GraphQL server asynchronously.
108108
let sendMultipartRequestAsync ct (connection : GraphQLClientConnection) (request : GraphQLRequest) = task {
@@ -167,4 +167,4 @@ module GraphQLClient =
167167

168168
/// Executes a multipart request to a GraphQL server.
169169
let sendMultipartRequest connection request =
170-
(sendMultipartRequestAsync CancellationToken.None connection request).Result
170+
(sendMultipartRequestAsync CancellationToken.None connection request).GetAwaiter().GetResult()
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"appDomain": "denied"
3-
}
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3+
"appDomain": "denied",
4+
"maxParallelThreads": -1,
5+
"parallelizeAssembly": true
6+
}

0 commit comments

Comments
 (0)