Skip to content

Commit 2842b74

Browse files
Refactor smoke-test to capture prereqs (#13145)
1 parent 701b769 commit 2842b74

12 files changed

Lines changed: 146 additions & 77 deletions

File tree

src/SourceBuild/Arcade/eng/common/templates/job/source-build-run-tarball-build.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,24 @@ jobs:
6969
_ExcludeOmniSharpTests: false
7070
_RunOnline: false
7171
timeoutInMinutes: 300
72+
variables:
73+
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
74+
- group: AzureDevOps-Artifact-Feeds-Pats
7275
workspace:
7376
clean: all
7477

7578
steps:
76-
- checkout: none
79+
- checkout: self
80+
clean: true
81+
82+
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
83+
- task: Bash@3
84+
displayName: Setup Private Feeds Credentials
85+
inputs:
86+
filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh
87+
arguments: $(Build.SourcesDirectory)/NuGet.config $Token
88+
env:
89+
Token: $(dn-bot-dnceng-artifact-feeds-rw)
7790

7891
- template: /src/SourceBuild/Arcade/eng/common/templates/steps/source-build-build-tarball.yml
7992
parameters:
@@ -110,11 +123,24 @@ jobs:
110123
_Container: ${{ parameters.fedora33Container }}
111124
_RunOnline: false
112125
timeoutInMinutes: 180
126+
variables:
127+
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
128+
- group: AzureDevOps-Artifact-Feeds-Pats
113129
workspace:
114130
clean: all
115131

116132
steps:
117-
- checkout: none
133+
- checkout: self
134+
clean: true
135+
136+
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
137+
- task: Bash@3
138+
displayName: Setup Private Feeds Credentials
139+
inputs:
140+
filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh
141+
arguments: $(Build.SourcesDirectory)/NuGet.config $Token
142+
env:
143+
Token: $(dn-bot-dnceng-artifact-feeds-rw)
118144

119145
- download: current
120146
artifact: $(_PreviousSourceBuildArtifact)

src/SourceBuild/Arcade/eng/common/templates/steps/source-build-build-tarball.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ steps:
6666
- script: |
6767
set -x
6868
69-
docker run --rm -v ${{ parameters.tarballDir }}:/tarball -w /tarball -e excludeOmniSharpTests=${{ parameters.excludeOmniSharpTests}} ${{ parameters.container }} ./build.sh --run-smoke-test ${{ parameters.additionalBuildArgs }}
69+
# Use installer repo's NuGet.config during online testing to utilize internal feeds
70+
rm -f ${{ parameters.tarballDir }}/test/Microsoft.DotNet.SourceBuild.SmokeTests/smoke-tests/online.NuGet.Config
71+
cp NuGet.config ${{ parameters.tarballDir }}/test/Microsoft.DotNet.SourceBuild.SmokeTests/smoke-tests/online.NuGet.Config
72+
73+
docker run --rm -v ${{ parameters.tarballDir }}:/tarball -w /tarball -e EXCLUDE_OMNISHARP_TESTS=${{ parameters.excludeOmniSharpTests}} ${{ parameters.container }} ./build.sh --run-smoke-test ${{ parameters.additionalBuildArgs }}
7074
displayName: Run Tests
7175
7276
# Don't use CopyFiles@2 as it encounters permissions issues because it indexes all files in the source directory graph.
@@ -82,7 +86,7 @@ steps:
8286
find artifacts/prebuilt-report/ -exec cp {} --parents -t ${targetFolder} \;
8387
find src/ -type f -name "*.binlog" -exec cp {} --parents -t ${targetFolder} \;
8488
find src/ -type f -name "*.log" -exec cp {} --parents -t ${targetFolder} \;
85-
find test/*/*/*/*/*/testing-smoke/logs -exec cp {} --parents -t ${targetFolder} \;
89+
find test/*/*/*/*/*/testing-smoke*/logs -exec cp {} --parents -t ${targetFolder} \;
8690
displayName: Prepare BuildLogs staging directory
8791
continueOnError: true
8892
condition: succeededOrFailed()

src/SourceBuild/tarball/content/build.proj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,26 @@
9999
<SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath>
100100
</PropertyGroup>
101101

102-
<Exec Command="$(DotnetToolCommand) test ./test/Microsoft.DotNet.SourceBuild.SmokeTests --logger:trx"
102+
<Exec Command="$(DotnetToolCommand) test ./test/Microsoft.DotNet.SourceBuild.SmokeTests --logger:trx -c $(Configuration)"
103103
EnvironmentVariables="
104104
DOTNET_TARBALL_PATH=$(SdkTarballPath);
105105
TARGET_RID=$(TargetRid);
106106
" />
107107
</Target>
108108

109+
<Target Name="CreateSmokeTestPrereqs"
110+
AfterTargets="RunSmokeTest"
111+
Condition="'$(SkipSmokeTestPrereqsTarballCreation)' != 'true'" >
112+
<PropertyGroup>
113+
<SmokeTestPrereqsTarballName>$(OutputPath)dotnet-smoke-test-prereqs.$(installerOutputPackageVersion).tar.gz</SmokeTestPrereqsTarballName>
114+
</PropertyGroup>
115+
116+
<Exec Command="tar --numeric-owner -czf $(SmokeTestPrereqsTarballName) ."
117+
WorkingDirectory="./test/Microsoft.DotNet.SourceBuild.SmokeTests/bin/$(Configuration)/net6.0/smoke-tests/prereq-packages/"/>
118+
119+
<Message Importance="High" Text="Packaged smoke-test prereqs to $(SmokeTestPrereqsTarballName)" />
120+
</Target>
121+
109122
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="UploadToAzure" />
110123

111124
<Target Name="PublishPrebuiltReportData">

src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Config.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ internal static class Config
1111
public static string DotNetDirectory { get; } = Environment.GetEnvironmentVariable("DOTNET_DIR") ?? "./.dotnet";
1212
public static string DotNetTarballPath { get; } = Environment.GetEnvironmentVariable(DotNetTarballPathEnv) ?? string.Empty;
1313
public const string DotNetTarballPathEnv = "DOTNET_TARBALL_PATH";
14+
public static bool ExcludeOmniSharpTests { get; } =
15+
bool.TryParse(Environment.GetEnvironmentVariable("EXCLUDE_OMNISHARP_TESTS"), out bool excludeOmniSharpTests) ? excludeOmniSharpTests : false;
16+
public static bool ExcludeOnlineTests { get; } =
17+
bool.TryParse(Environment.GetEnvironmentVariable("EXCLUDE_ONLINE_TESTS"), out bool excludeOnlineTests) ? excludeOnlineTests : false;
1418
public static string TargetRid { get; } = Environment.GetEnvironmentVariable("TARGET_RID") ?? string.Empty;
1519
}

src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Diagnostics;
6+
using System.Linq;
67
using System.Text;
78
using Xunit.Abstractions;
89

@@ -27,6 +28,13 @@ public static (Process Process, string StdOut, string StdErr) ExecuteProcess(
2728
}
2829
};
2930

31+
// The `dotnet test` execution context sets a number of dotnet related ENVs that cause issues when executing
32+
// dotnet commands. Clear these to avoid side effects.
33+
foreach (string key in process.StartInfo.Environment.Keys.Where(key => key != "HOME").ToList())
34+
{
35+
process.StartInfo.Environment.Remove(key);
36+
}
37+
3038
StringBuilder stdOutput = new();
3139
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) => stdOutput.AppendLine(e.Data));
3240

src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Microsoft.DotNet.SourceBuild.SmokeTests.csproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@
1919

2020
<ItemGroup>
2121
<Content Include="baselines/*">
22-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2323
</Content>
2424
<Content Include="smoke-tests/*">
25-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2626
</Content>
2727
</ItemGroup>
28+
29+
<ItemGroup>
30+
<SmokeTestPrereqs Include="..\..\packages\smoke-test-prereqs\*" />
31+
</ItemGroup>
32+
33+
<Target Name="CopySmokeTestPrereqs" BeforeTargets="Build">
34+
<Copy SourceFiles="@(SmokeTestPrereqs)" DestinationFolder="$(OutputPath)\smoke-tests\prereq-packages" />
35+
</Target>
2836
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Source Build Smoke Tests
2+
3+
* Run these tests via `build.sh --run-smoke-test`
4+
* Various configuration settings are stored in `Config.cs`
5+
6+
## Prereq Packages
7+
Some prerelease scenarios, usually security updates, require non-source-built packages which are not publicly available.
8+
Place these packages in the tarball's `packages/smoke-test-prereqs`. When prereq packages are required, the
9+
`EXCLUDE_ONLINE_TESTS=true` environment variable should be set when running tests via `build.sh --run-smoke-test`.

src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SmokeTests.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,19 @@ public SmokeTests(ITestOutputHelper outputHelper)
2424
[Fact]
2525
public void SmokeTestsScript()
2626
{
27-
string smokeTestArgs = $"--dotnetDir {Directory.GetParent(DotNetHelper.DotNetPath)} --minimal --projectOutput --archiveRestoredPackages --targetRid {Config.TargetRid}";
27+
string smokeTestArgs = $"--dotnetDir {Directory.GetParent(DotNetHelper.DotNetPath)} --projectOutput --archiveRestoredPackages --targetRid {Config.TargetRid}";
2828
if (Config.TargetRid.Contains("osx"))
2929
{
3030
smokeTestArgs += " --excludeWebHttpsTests";
3131
}
32+
if (Config.ExcludeOmniSharpTests)
33+
{
34+
smokeTestArgs += " --excludeOmniSharpTests";
35+
}
36+
if (Config.ExcludeOnlineTests)
37+
{
38+
smokeTestArgs += " --excludeOnlineTests";
39+
}
3240

3341
(Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess("./smoke-tests/smoke-test.sh", smokeTestArgs, OutputHelper);
3442

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="source-built-packages" value="SOURCE_BUILT_PACKAGES" />
6+
<add key="smoke-test-prereqs" value="SMOKE_TEST_PACKAGE_FEED" />
7+
</packageSources>
8+
</configuration>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
6+
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
7+
<add key="dotnet6-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6-transport/nuget/v3/index.json" />
8+
</packageSources>
9+
</configuration>

0 commit comments

Comments
 (0)