Skip to content

Commit e71de15

Browse files
authored
Merge pull request #803 from dotnet-maestro-bot/merge/release/2.1-to-release/2.2
[automated] Merge branch 'release/2.1' => 'release/2.2'
2 parents c5ec332 + 47633d2 commit e71de15

16 files changed

+877
-6
lines changed

build-source-tarball.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -euo pipefail
33
IFS=$'\n\t'
44

55
usage() {
6-
echo "usage: $0 <path-to-tarball-root> [--skip-build]"
6+
echo "usage: $0 <path-to-tarball-root> [--skip-build] [--enable-leak-detection]"
77
echo ""
88
}
99

@@ -16,6 +16,8 @@ TARBALL_ROOT=$1
1616
shift
1717

1818
SKIP_BUILD=0
19+
INCLUDE_LEAK_DETECTION=0
20+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
1921

2022
while :; do
2123
if [ $# -le 0 ]; then
@@ -31,6 +33,9 @@ while :; do
3133
--skip-build)
3234
SKIP_BUILD=1
3335
;;
36+
--enable-leak-detection)
37+
INCLUDE_LEAK_DETECTION=1
38+
;;
3439
*)
3540
echo "Unrecognized argument '$1'"
3641
usage
@@ -158,6 +163,12 @@ SOURCE_BUILT_SDK_TOOLS_DIR="$TARBALL_ROOT/Tools/source-built/$ROSLYN_TOOLS_PACKA
158163
cp "$REPO_TOOLSET_PACKAGE_DIR/tools/"*.props "$SOURCE_BUILT_SDK_TOOLS_DIR"
159164
cp "$REPO_TOOLSET_PACKAGE_DIR/tools/"*.targets "$SOURCE_BUILT_SDK_TOOLS_DIR"
160165

166+
if [ $INCLUDE_LEAK_DETECTION -eq 1 ]; then
167+
echo 'Building leak detection MSBuild tasks...'
168+
./Tools/dotnetcli/dotnet restore $SCRIPT_ROOT/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj --source $FULL_TARBALL_ROOT/prebuilt/source-built --source $FULL_TARBALL_ROOT/prebuilt/nuget-packages
169+
./Tools/dotnetcli/dotnet publish -o $FULL_TARBALL_ROOT/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection $SCRIPT_ROOT/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj
170+
fi
171+
161172
echo 'Recording commits for the source-build repo and all submodules, to aid in reproducibility...'
162173

163174
cat >$TARBALL_ROOT/source-build-info.txt << EOF

build.proj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<Project ToolsVersion="15.0" InitialTargets="PrepareOutput" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="dir.props" />
44

5+
<UsingTask AssemblyFile="$(LeakDetectionTasksBinDir)Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.dll" TaskName="CheckForPoison" />
6+
57
<Target Name="Build" DependsOnTargets="PrepareOutput;InitBuild">
68
<Message Text="Build Environment: $(Platform) $(Configuration) $(TargetOS) $(TargetRid)" />
79

@@ -45,6 +47,18 @@
4547
<MSBuild Projects="repos\$(RootRepo).proj" Targets="ReportPrebuiltUsage" />
4648
</Target>
4749

50+
<Target Name="ReportPoisonUsage"
51+
AfterTargets="Build"
52+
Condition="'$(EnablePoison)' == 'true' and '$(OfflineBuild)' == 'true'">
53+
<ItemGroup>
54+
<FinalCliTarball Include="$(SourceBuiltTarBallPath)**/*$(TarBallExtension)" />
55+
</ItemGroup>
56+
<CheckForPoison FilesToCheck="@(FinalCliTarball)"
57+
HashCatalogFilePath="$(PoisonReportDataFile)"
58+
MarkerFileName="$(PoisonMarkerFile)"
59+
PoisonReportOutputFilePath="$(PoisonUsageReportFile)" />
60+
</Target>
61+
4862
<Target Name="RunSmokeTest" DependsOnTargets="GetProdConBlobFeedUrl">
4963
<!--
5064
Pass prodConBlobFeedUrl via EnvironmentVariables because it has '//' in it, which is

dir.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<ToolsLocalDir>$(ProjectDir)tools-local/</ToolsLocalDir>
4848
<TaskDirectory>$(ToolsLocalDir)tasks/</TaskDirectory>
4949
<TasksBinDir>$(TaskDirectory)Microsoft.DotNet.SourceBuild.Tasks/bin/Debug/netstandard1.5/</TasksBinDir>
50+
<LeakDetectionTasksBinDir>$(TaskDirectory)Microsoft.DotNet.SourceBuild.Tasks.LeakDetection/</LeakDetectionTasksBinDir>
5051
<BaseIntermediatePath>$(BaseOutputPath)obj/</BaseIntermediatePath>
5152
<OutputPath>$(BaseOutputPath)$(Platform)/$(Configuration)/</OutputPath>
5253
<IntermediatePath>$(BaseIntermediatePath)$(Platform)/$(Configuration)/</IntermediatePath>
@@ -70,6 +71,11 @@
7071
<GitInfoOfflineDir>$(ProjectDir)git-info/</GitInfoOfflineDir>
7172
<PackageReportDir>$(BaseOutputPath)prebuilt-report/</PackageReportDir>
7273
<PackageReportDataFile>$(PackageReportDir)prebuilt-usage.xml</PackageReportDataFile>
74+
<PoisonUsageReportFile>$(PackageReportDir)poison-usage.xml</PoisonUsageReportFile>
75+
<PoisonReportDataFile>$(PackageReportDir)poison-catalog.xml</PoisonReportDataFile>
76+
<PoisonMarkerFile>.prebuilt.xml</PoisonMarkerFile>
77+
<SourceBuiltPoisonReportDataFile>$(PackageReportDir)poison-source-built-catalog.xml</SourceBuiltPoisonReportDataFile>
78+
<SourceBuiltPoisonMarkerFile>.source-built.xml</SourceBuiltPoisonMarkerFile>
7379
<ProjectAssetsJsonArchiveFile>$(PackageReportDir)all-project-assets-json-files.zip</ProjectAssetsJsonArchiveFile>
7480
<ProdConManifestFile>$(PackageReportDir)prodcon-build.xml</ProdConManifestFile>
7581
<PoisonedReportFile>$(PackageReportDir)poisoned.txt</PoisonedReportFile>

netci.groovy

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,29 @@ def addPushJob(String project, String branch, String os, String configuration, b
145145

146146
def shortJobName = "${os}_Tarball_${configuration}";
147147
def contextString = "${os} Tarball ${configuration}";
148+
def poisonProductionBuildArgument = ""
149+
def poisonConsumptionBuildArugment = ""
148150

149151
if (portable) {
150152
shortJobName += "_Portable"
151153
contextString += " Portable"
152154
}
153155

156+
// only run poisoning on one platform for now
157+
if (os == "CentOS7.1") {
158+
poisonProductionBuildArgument = "--enable-leak-detection"
159+
poisonConsumptionBuildArugment = "/p:EnablePoison=true"
160+
}
161+
154162
def triggerPhrase = "(?i).*test\\W+${contextString}.*";
155163

156164
def newJob = job(Utilities.getFullJobName(project, shortJobName, isPR)){
157165
steps{
158166
shell("cd ./source-build;git submodule update --init --recursive");
159167
shell("cd ./source-build;./build.sh /p:ArchiveDownloadedPackages=true /p:Configuration=${configuration} /p:PortableBuild=${portable} ${loggingOptions}");
160-
shell("cd ./source-build;./build-source-tarball.sh ../tarball-output --skip-build");
168+
shell("cd ./source-build;./build-source-tarball.sh ../tarball-output --skip-build ${poisonProductionBuildArgument}");
161169

162-
shell("cd ./tarball-output;./build.sh /p:Configuration=${configuration} /p:PortableBuild=${portable} /p:FailOnPrebuiltBaselineError=true ${loggingOptions}")
170+
shell("cd ./tarball-output;./build.sh /p:Configuration=${configuration} /p:PortableBuild=${portable} /p:FailOnPrebuiltBaselineError=true ${poisonConsumptionBuildArugment} ${loggingOptions}")
163171
shell("cd ./tarball-output;./smoke-test.sh --minimal --configuration ${configuration}")
164172
}
165173
}
@@ -200,12 +208,20 @@ def addPushJob(String project, String branch, String os, String configuration, b
200208

201209
def shortJobName = "${os}_Unshared_${configuration}";
202210
def contextString = "${os} Unshared ${configuration}";
211+
def poisonProductionBuildArgument = ""
212+
def poisonConsumptionBuildArugment = ""
203213

204214
if (portable) {
205215
shortJobName += "_Portable"
206216
contextString += " Portable"
207217
}
208218

219+
// only run poisoning on one platform for now
220+
if (os == "CentOS7.1") {
221+
poisonProductionBuildArgument = "--enable-leak-detection"
222+
poisonConsumptionBuildArugment = "/p:EnablePoison=true"
223+
}
224+
209225
def triggerPhrase = "(?i).*test\\W+${contextString}.*";
210226
def imageName = getDockerImageForOs(os);
211227

@@ -217,9 +233,9 @@ def addPushJob(String project, String branch, String os, String configuration, b
217233
// Have to make this directory before volume-sharing it unlike non-docker build - existing directory is really only a warning in build-source-tarball.sh
218234
shell("mkdir tarball-output");
219235
// now build the tarball
220-
shell("docker run -u=\"\$(id -u):\$(id -g)\" -t --sig-proxy=true -e HOME=/opt/code/home --network none -v \$(pwd)/source-build:/opt/code -v \$(pwd)/tarball-output:/opt/tarball --rm -w /opt/code ${imageName} /opt/code/build-source-tarball.sh /opt/tarball --skip-build");
236+
shell("docker run -u=\"\$(id -u):\$(id -g)\" -t --sig-proxy=true -e HOME=/opt/code/home --network none -v \$(pwd)/source-build:/opt/code -v \$(pwd)/tarball-output:/opt/tarball --rm -w /opt/code ${imageName} /opt/code/build-source-tarball.sh /opt/tarball --skip-build ${poisonProductionBuildArgument}");
221237
// now build from the tarball offline and without access to the regular non-tarball build
222-
shell("docker run -u=\"\$(id -u):\$(id -g)\" -t --sig-proxy=true -e HOME=/opt/tarball/home --network none -v \$(pwd)/tarball-output:/opt/tarball --rm -w /opt/tarball ${imageName} /opt/tarball/build.sh /p:Configuration=${configuration} /p:PortableBuild=${portable} /p:FailOnPrebuiltBaselineError=true ${loggingOptions}");
238+
shell("docker run -u=\"\$(id -u):\$(id -g)\" -t --sig-proxy=true -e HOME=/opt/tarball/home --network none -v \$(pwd)/tarball-output:/opt/tarball --rm -w /opt/tarball ${imageName} /opt/tarball/build.sh /p:Configuration=${configuration} /p:PortableBuild=${portable} /p:FailOnPrebuiltBaselineError=true ${poisonConsumptionBuildArugment} ${loggingOptions}");
223239
// finally, run a smoke-test on the result
224240
shell("docker run -u=\"\$(id -u):\$(id -g)\" -t --sig-proxy=true -e HOME=/opt/tarball/home -v \$(pwd)/tarball-output:/opt/tarball --rm -w /opt/tarball ${imageName} /opt/tarball/smoke-test.sh --minimal --configuration ${configuration}");
225241
}

tools-local/init-build.proj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<Import Project="..\dir.props" />
88

99
<UsingTask AssemblyFile="$(TasksBinDir)Microsoft.DotNet.SourceBuild.Tasks.dll" TaskName="GetHostInformation" />
10+
<UsingTask AssemblyFile="$(LeakDetectionTasksBinDir)Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.dll" TaskName="MarkAndCatalogPackages" />
1011

1112
<PropertyGroup>
1213
<BuildCompetedSuccessSemaphore>$(BaseIntermediatePath)/init-build-proj.complete</BuildCompetedSuccessSemaphore>
@@ -17,7 +18,7 @@
1718
Inputs="$(TargetInfoProps)"
1819
Outputs="$(BuildCompetedSuccessSemaphore)"
1920
>
20-
<CallTarget Targets="BuildTasks;InstallSourceBuildSdkResolver;WriteDynamicPropsToStaticPropsFiles;GenerateRootFs;CreateAllGitInfoProps;ApplyPatches" />
21+
<CallTarget Targets="BuildTasks;InstallSourceBuildSdkResolver;WriteDynamicPropsToStaticPropsFiles;GenerateRootFs;CreateAllGitInfoProps;ApplyPatches;PoisonPrebuiltPackages" />
2122
<Touch Files="$(BuildCompetedSuccessSemaphore)" AlwaysCreate="true" />
2223
</Target>
2324

@@ -93,4 +94,13 @@
9394
<WriteLinesToFile File="$(TargetInfoProps)" Lines="$(TargetInfoPropsContent)" Overwrite="True" />
9495
</Target>
9596

97+
<Target Name="PoisonPrebuiltPackages" Condition="'$(EnablePoison)' == 'true' and '$(OfflineBuild)' == 'true'">
98+
<ItemGroup>
99+
<PrebuiltPackages Include="$(PrebuiltPackagesPath)**/*.nupkg" />
100+
<PrebuiltSourceBuiltPackages Include="$(PrebuiltSourceBuiltPackagesPath)**/*.nupkg" />
101+
</ItemGroup>
102+
<MarkAndCatalogPackages PackagesToMark="@(PrebuiltPackages)" CatalogOutputFilePath="$(PoisonReportDataFile)" MarkerFileName="$(PoisonMarkerFile)" />
103+
<MarkAndCatalogPackages PackagesToMark="@(PrebuiltSourceBuiltPackages)" CatalogOutputFilePath="$(SourceBuiltPoisonReportDataFile)" MarkerFileName="$(SourceBuiltPoisonMarkerFile)" />
104+
</Target>
105+
96106
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
using System.Xml.Linq;
9+
10+
namespace Microsoft.DotNet.SourceBuild.Tasks.LeakDetection
11+
{
12+
internal class CatalogFileEntry
13+
{
14+
const string ElementName = "File";
15+
16+
internal string Path { get; set; }
17+
internal byte[] OriginalHash { get; set; }
18+
internal byte[] PoisonedHash { get; set; }
19+
20+
public XElement ToXml() => new XElement(ElementName,
21+
new XAttribute(nameof(Path), Path),
22+
new XAttribute(nameof(OriginalHash), OriginalHash.ToHexString()),
23+
PoisonedHash == null ? null : new XAttribute(nameof(PoisonedHash), PoisonedHash.ToHexString())
24+
);
25+
}
26+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Xml.Linq;
10+
11+
namespace Microsoft.DotNet.SourceBuild.Tasks.LeakDetection
12+
{
13+
internal class CatalogPackageEntry
14+
{
15+
const string ElementName = "Package";
16+
17+
internal string Path { get; set; }
18+
internal string Id { get; set; }
19+
internal string Version { get; set; }
20+
internal byte[] OriginalHash { get; set; }
21+
internal byte[] PoisonedHash { get; set; }
22+
internal List<CatalogFileEntry> Files { get; }
23+
24+
public CatalogPackageEntry()
25+
{
26+
this.Files = new List<CatalogFileEntry>();
27+
}
28+
29+
public XElement ToXml() => new XElement(ElementName,
30+
new XAttribute(nameof(Path), Path),
31+
new XAttribute(nameof(Id), Id),
32+
new XAttribute(nameof(Version), Version),
33+
new XAttribute(nameof(OriginalHash), OriginalHash.ToHexString()),
34+
PoisonedHash == null ? null : new XAttribute(nameof(PoisonedHash), PoisonedHash.ToHexString()),
35+
Files.Select(f => f.ToXml())
36+
);
37+
}
38+
}

0 commit comments

Comments
 (0)