Skip to content

Commit

Permalink
Remove source build support for test prereqs tarballs (#45544)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSimons authored Dec 18, 2024
1 parent 77d763f commit c3d462b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ internal static class Config
public static string? LicenseScanPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(LicenseScanPath))!;
public static string? MsftSdkTarballPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(MsftSdkTarballPath))!;
public static string? PoisonReportPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(PoisonReportPath))!;
public static string? PrereqsPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(PrereqsPath))!;
public static string? SdkTarballPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(SdkTarballPath))!;
public static string? SourceBuiltArtifactsPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(SourceBuiltArtifactsPath))!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,24 @@ public DotNetHelper(ITestOutputHelper outputHelper)

private static void InitNugetConfig()
{
bool useLocalPackages = !string.IsNullOrEmpty(Config.PrereqsPath);
string nugetConfigPrefix = useLocalPackages ? "local" : "online";
bool useCustomPackages = !string.IsNullOrEmpty(Config.CustomPackagesPath);
string nugetConfigPrefix = useCustomPackages ? "custom" : "default";
string nugetConfigPath = Path.Combine(ProjectsDirectory, "NuGet.Config");
File.Copy(
Path.Combine(BaselineHelper.GetAssetsDirectory(), $"{nugetConfigPrefix}.NuGet.Config"),
nugetConfigPath);

if (useLocalPackages)
if (useCustomPackages)
{
// When using local packages this feed is always required. It contains packages that are
// not produced by source-build but are required by the various project templates.
if (!Directory.Exists(Config.PrereqsPath))
// This package feed is optional. You can use an alternative feed of dependency packages which can be
// required in sandboxed scenarios where public feeds need to be avoided.
if (!Directory.Exists(Config.CustomPackagesPath))
{
throw new InvalidOperationException(
$"Prereqs path '{Config.PrereqsPath}' specified via /p:SourceBuildTestsPrereqsPath='...' does not exist.");
throw new ArgumentException($"Specified CustomPackagesPath '{Config.CustomPackagesPath}' does not exist.");
}

string nugetConfig = File.ReadAllText(nugetConfigPath);
nugetConfig = nugetConfig.Replace("SMOKE_TEST_PACKAGE_FEED", Config.PrereqsPath);

// This package feed is optional. You can use an additional feed of source-built packages to run the
// smoke-tests as offline as possible.
if (Config.CustomPackagesPath != null)
{
if (!Directory.Exists(Config.CustomPackagesPath))
{
throw new ArgumentException($"Specified --with-packages {Config.CustomPackagesPath} does not exist.");
}
nugetConfig = nugetConfig.Replace("CUSTOM_PACKAGE_FEED", Config.CustomPackagesPath);
}
else
{
nugetConfig = string.Join(Environment.NewLine, nugetConfig.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Where(s => !s.Contains("CUSTOM_PACKAGE_FEED")).ToArray());
}
string nugetConfig = File.ReadAllText(nugetConfigPath)
.Replace("CUSTOM_PACKAGE_FEED", Config.CustomPackagesPath);
File.WriteAllText(nugetConfigPath, nugetConfig);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@
Condition="'$(EnablePoison)' == 'true'">
<Value>$(PoisonUsageReportFile)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).PrereqsPath">
<Value>$(SourceBuildTestsPrereqsPath)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).SdkTarballPath">
<Value>$(SdkTarballPath)</Value>
</RuntimeHostConfigurationOption>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
# Source Build Smoke Tests

Run these tests via `build.sh --test`
Run these tests via `build.sh -sb --test`

The following properties are automatically available during test execution but can be overwritten:

- PoisonUsageReportFile
- SdkTarballPath
- SourceBuiltArtifactsPath

Optional msbuild properties:

- MsftSdkTarballPath
- SourceBuildTestsConsoleVerbosity
- SourceBuildTestsCustomSourceBuiltPackagesPath
- SourceBuildTestsExcludeOmniSharpTests
- SourceBuildTestsLicenseScanPath
- SourceBuildTestsPrereqsPath

Make sure to rebuild the test project when changing one of those values.
See the [Microsoft.DotNet.SourceBuild.Tests.csproj](Microsoft.DotNet.SourceBuild.Tests.csproj) for the available
RuntimeHostConfigurationOptions that can be used to configure the tests.

## Dependencies

Expand All @@ -31,5 +17,5 @@ The following programs are used by some tests:
## Prereq Packages

Some prerelease scenarios, usually security updates, require non-source-built packages which are not publicly available.
Specify the directory where these packages can be found via the `SourceBuildTestsPrereqsPath` msbuild property when running tests via `build.sh ---test` e.g.
`/p:SourceBuildTestsPrereqsPath=prereqs/packages/smoke-test-prereqs`.
You can specify a custom nuget feed for where these packages can be loaded from via the `SourceBuildTestsCustomSourceBuiltPackagesPath`
msbuild property when running tests via `build.sh ---test` e.g. `/p:SourceBuildTestsCustomSourceBuiltPackagesPath=<FEED URL OR LOCAL PATH>`.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<configuration>
<packageSources>
<clear />
<add key="smoke-test-prereqs" value="SMOKE_TEST_PACKAGE_FEED" />
<add key="custom-packages" value="CUSTOM_PACKAGE_FEED" />
</packageSources>
</configuration>

0 comments on commit c3d462b

Please sign in to comment.