зеркало из https://github.com/microsoft/BuildXL.git
Merged PR 780952: Bug fix for disabling server mode by default in ADO builds
There was a bug in !777896 where that didn't apply to the light config. So in practice it didn't do anything. This brings the light config to parity with the real one as well as adds unit tests to ensure their infra defaults evaluate to the same thing.
This commit is contained in:
Родитель
89a60c4fd1
Коммит
1124658d7d
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using BuildXL.ToolSupport;
|
||||
using BuildXL.Utilities.Core;
|
||||
|
@ -22,7 +23,7 @@ namespace BuildXL
|
|||
/// stays in sync with the full blown configuration
|
||||
/// </summary>
|
||||
#region options
|
||||
public ServerMode Server = OperatingSystemHelper.IsUnixOS ? ServerMode.Disabled : ServerMode.Enabled;
|
||||
public ServerMode? Server;
|
||||
public string ServerDeploymentDirectory;
|
||||
public string Config;
|
||||
public bool NoLogo;
|
||||
|
@ -35,6 +36,7 @@ namespace BuildXL
|
|||
public bool DisablePathTranslation;
|
||||
public bool EnableDedup;
|
||||
public string HashType;
|
||||
public bool InCloudbuild;
|
||||
public bool RunInSubst;
|
||||
|
||||
// Strangely, this is not configurable via Args.cs
|
||||
|
@ -95,6 +97,9 @@ namespace BuildXL
|
|||
case "HASHTYPE":
|
||||
lightConfig.HashType = CommandLineUtilities.ParseStringOption(option);
|
||||
break;
|
||||
case "INCLOUDBUILD":
|
||||
lightConfig.InCloudbuild = CommandLineUtilities.ParseBooleanOption(option);
|
||||
break;
|
||||
case "SERVER":
|
||||
lightConfig.Server = CommandLineUtilities.ParseBoolEnumOption(option, true, ServerMode.Enabled, ServerMode.Disabled);
|
||||
break;
|
||||
|
@ -126,6 +131,33 @@ namespace BuildXL
|
|||
}
|
||||
}
|
||||
|
||||
// Process Infra specific defaults.
|
||||
// CODESYNC This is the counterpart to ConfigurationProvider.GetMutableDefaultConfig()
|
||||
if (lightConfig.InCloudbuild)
|
||||
{
|
||||
// CloudBuild
|
||||
if (!lightConfig.Server.HasValue)
|
||||
{
|
||||
lightConfig.Server = ServerMode.Disabled;
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(CaptureBuildInfo.AdoEnvVariableForInfra)))
|
||||
{
|
||||
// Azure DevOps
|
||||
if (!lightConfig.Server.HasValue)
|
||||
{
|
||||
lightConfig.Server = ServerMode.Disabled;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Dev
|
||||
if (!lightConfig.Server.HasValue)
|
||||
{
|
||||
lightConfig.Server = OperatingSystemHelper.IsUnixOS ? ServerMode.Disabled : ServerMode.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
// This has no attempt at any sort of error handling. Leave that to the real argument parser. Only detect errors
|
||||
// If RunInSubst is specified without an explicit subst source, we fail if the config file does not exist since we need to compute the parent directory of the main config during light config interpretation
|
||||
return !string.IsNullOrWhiteSpace(lightConfig.Config) && (!lightConfig.RunInSubst || !string.IsNullOrEmpty(lightConfig.SubstSource) || File.Exists(lightConfig.Config));
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.IO;
|
||||
using System;
|
||||
using BuildXL;
|
||||
using BuildXL.Utilities.Core;
|
||||
using BuildXL.Utilities.Configuration;
|
||||
using BuildXL.Utilities.Core;
|
||||
using Test.BuildXL.TestUtilities.Xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
@ -22,8 +22,26 @@ namespace Test.BuildXL
|
|||
[Fact]
|
||||
public void DefaultsMatch()
|
||||
{
|
||||
// Need to always provide a config file otherwise the arg parser fails
|
||||
// Run a test case to match each default config variant. In all cases a config files is required
|
||||
// otherwise the arg parser fails
|
||||
|
||||
// Infra = dev by default
|
||||
RunCongruentTest(new[] { @"/c:" + m_specFilePath });
|
||||
|
||||
// Infra = CloudBuild
|
||||
RunCongruentTest(new[] { @"/c:" + m_specFilePath , "/incloudbuild"});
|
||||
|
||||
// Infra = Azure DevOps
|
||||
var original = Environment.GetEnvironmentVariable(CaptureBuildInfo.AdoEnvVariableForInfra);
|
||||
try
|
||||
{
|
||||
Environment.SetEnvironmentVariable(CaptureBuildInfo.AdoEnvVariableForInfra, "TotallyRunningInADO");
|
||||
RunCongruentTest(new[] { @"/c:" + m_specFilePath });
|
||||
}
|
||||
finally
|
||||
{
|
||||
Environment.SetEnvironmentVariable(CaptureBuildInfo.AdoEnvVariableForInfra, original);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
Загрузка…
Ссылка в новой задаче