Skip to content

Commit

Permalink
Add default timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanSaeed committed Sep 8, 2020
1 parent 1f2c262 commit 05815cf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
++$count;
dotnet nuget push .\windows-latest\*.nupkg --source GitHub --skip-duplicate;
}
while ($count -lt 30 -and $LastExitCode -ne 0)
while ($count -lt 1000 -and $LastExitCode -ne 0)
shell: pwsh

push-nuget:
Expand Down
5 changes: 5 additions & 0 deletions Source/Boxed.DotnetNewTest/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace Boxed.DotnetNewTest
/// </summary>
public static class ConfigurationService
{
/// <summary>
/// Gets or sets the default timeout period.
/// </summary>
public static TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromMinutes(2);

/// <summary>
/// Gets the temporary directory path.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/Boxed.DotnetNewTest/DotnetNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static async Task InstallAsync(string source, TimeSpan? timeout = null, b
throw new ArgumentNullException(nameof(source));
}

using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await ProcessExtensions
.StartAsync(
Expand All @@ -84,7 +84,7 @@ await ProcessExtensions
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public static async Task ReinitialiseAsync(TimeSpan? timeout = null, bool showShellWindow = false)
{
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await ProcessExtensions
.StartAsync(
Expand Down
13 changes: 6 additions & 7 deletions Source/Boxed.DotnetNewTest/ProjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace Boxed.DotnetNewTest
using System.Linq;
using System.Net.Http;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -41,7 +40,7 @@ public static async Task DotnetRestoreAsync(
throw new ArgumentNullException(nameof(project));
}

using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await AssertStartAsync(
project.DirectoryPath,
Expand Down Expand Up @@ -73,7 +72,7 @@ public static async Task DotnetBuildAsync(
}

var noRestoreArgument = noRestore is null ? null : "--no-restore";
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await AssertStartAsync(
project.DirectoryPath,
Expand Down Expand Up @@ -105,7 +104,7 @@ public static async Task DotnetTestAsync(
}

var noRestoreArgument = noRestore is null ? null : "--no-restore";
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await AssertStartAsync(
project.DirectoryPath,
Expand Down Expand Up @@ -134,7 +133,7 @@ public static async Task DotnetToolRestoreAsync(
throw new ArgumentNullException(nameof(project));
}

using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await AssertStartAsync(
project.DirectoryPath,
Expand Down Expand Up @@ -166,7 +165,7 @@ public static async Task DotnetCakeAsync(
}

var targetArgument = target is null ? null : $"--target={target}";
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await AssertStartAsync(
project.DirectoryPath,
Expand Down Expand Up @@ -205,7 +204,7 @@ public static async Task DotnetPublishAsync(
var runtimeArgument = runtime is null ? null : $"--self-contained --runtime {runtime}";
var noRestoreArgument = noRestore is null ? null : "--no-restore";
DirectoryExtensions.CheckCreate(project.PublishDirectoryPath);
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await AssertStartAsync(
project.DirectoryPath,
Expand Down
2 changes: 1 addition & 1 deletion Source/Boxed.DotnetNewTest/TempDirectoryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static async Task<Project> DotnetNewAsync(
}
}

using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? ConfigurationService.DefaultTimeout))
{
await ProcessExtensions
.StartAsync(
Expand Down

0 comments on commit 05815cf

Please sign in to comment.