[ArPow] Reduce the size of the tarball. (#11662)

* Copy instead of clone and remove .git/objects directories

* Add depth 1 to fetch command

* Add commit count to git-info for installer repo

* Update targets to fix dependency ordering

Some repos take a dependency on PrepareInnerSourceBuildRepoRoot,
assuming that the inner repo will be setup.  The condition for copy
instead of clone caused a conflict.
Keep PrepareInnerSourceBuildRepoRoot and make it depend on
either copy or clone completing.

* Don't copy artifacts dir

* Actually don't remove artifacts directory

* Update prebuilt version
This commit is contained in:
Dan Seefeldt 2021-09-01 03:31:15 -05:00 committed by GitHub
parent f0066a6f95
commit 290df5778e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 3 deletions

View file

@ -57,7 +57,8 @@ namespace Microsoft.DotNet.SourceBuild.Tasks
SourceBuildRepoName = dep.GetMetadata("SourceBuildRepoName"),
Version = dep.GetMetadata("ExactVersion"),
Sha = dep.GetMetadata("Sha"),
Uri = dep.GetMetadata("Uri")
Uri = dep.GetMetadata("Uri"),
GitCommitCount = dep.GetMetadata("GitCommitCount")
}))
{
string repoName = dependency.SourceBuildRepoName;
@ -72,6 +73,10 @@ namespace Microsoft.DotNet.SourceBuild.Tasks
["PreReleaseVersionLabel"] = derivedVersion.PreReleaseVersionLabel,
["IsStable"] = string.IsNullOrWhiteSpace(derivedVersion.PreReleaseVersionLabel) ? "true" : "false",
};
if (!string.IsNullOrEmpty(dependency.GitCommitCount))
{
repoProps.Add("GitCommitCount", dependency.GitCommitCount);
}
WritePropsFile(propsPath, repoProps);
allRepoProps[$"{safeRepoName}GitCommitHash"] = dependency.Sha;
allRepoProps[$"{safeRepoName}OutputPackageVersion"] = dependency.Version;

View file

@ -60,6 +60,14 @@
<Output TaskParameter="ConsoleOutput" ItemName="RootRepoCommitSha" />
</Exec>
<!-- Get commit count for installer repo only -->
<Exec
Command="cd $(RepoRoot);git rev-list --count HEAD"
ConsoleToMSBuild="true"
WorkingDirectory="$(RepoRoot)">
<Output TaskParameter="ConsoleOutput" ItemName="RootRepoCommitCount" />
</Exec>
<!-- This is hardcoding version for the root repo (installer), since there
isn't a Version.Details.xml file to read it from.
See https://github.com/dotnet/source-build/issues/2250 -->
@ -70,6 +78,7 @@
<ExactVersion>1.0.0</ExactVersion>
<Sha>@(RootRepoCommitSha)</Sha>
<Uri>@(RootRepoUri)</Uri>
<GitCommitCount>@(RootRepoCommitCount)</GitCommitCount>
<SourceBuildRepoName>$(GitHubRepositoryName)</SourceBuildRepoName>
<IsRootRepo>true</IsRootRepo>
</SourceBuildRepos>
@ -133,7 +142,7 @@
<!-- Fetching a sha requires git 2.5.0 or newer -->
<Exec
Command="git fetch origin $(RepoSha)"
Command="git fetch --depth 1 origin $(RepoSha)"
WorkingDirectory="$(TarballRepoSourceDir)"
Condition="$(IsRootRepo) != 'true'" />
@ -146,6 +155,11 @@
Command="git submodule update --init --recursive"
WorkingDirectory="$(TarballRepoSourceDir)" />
<!-- Remove the git objects folder to free up tarball space -->
<Exec
Command="rm -rf objects"
WorkingDirectory="$(TarballRepoSourceDir).git" />
<Message Text="--> Done Cloning Repo $(SourceBuildRepoName)" Importance="High" />
<!-- Override to use a temporary SourceBuild specific Version.Details.xml file in installer for Preview 6

View file

@ -97,6 +97,29 @@
</ItemGroup>
</Target>
<!--
PrepareInnerSourceBuildRepoRoot either clones the source to the inner repo
or copies the source to the inner repo depending on CopySrcInsteadOfClone.
Repos take a dependency on PrepareInnerSourceBuildRepoRoot, so this target
exists to wait until either the source is cloned or copied.
-->
<Target Name="PrepareInnerSourceBuildRepoRoot"
DependsOnTargets="CopyInnerSourceBuildRepoRoot;CloneInnerSourceBuildRepoRoot">
</Target>
<Target Name="CopyInnerSourceBuildRepoRoot" Condition=" '$(CopySrcInsteadOfClone)' == 'true' ">
<ItemGroup>
<SourceBuildFilesToCopy Include="$(RepoRoot)/**/*" />
<SourceBuildFilesToCopy Include="$(RepoRoot)/**/.*" />
<SourceBuildFilesToCopy Remove="$(RepoRoot)/artifacts/**/*" />
<SourceBuildFilesToCopy Remove="$(RepoRoot)/artifacts/**/.*" />
</ItemGroup>
<Copy
SourceFiles="@(SourceBuildFilesToCopy)"
DestinationFolder="$(InnerSourceBuildRepoRoot)%(RecursiveDir)" />
</Target>
<!--
Clone the repo to a new location. Source-build targets will change the source dynamically.
Creating a fresh clone avoids overwriting existing work or making subtle changes that might
@ -104,7 +127,7 @@
access to the git data, this also makes it easy to see what changes the source-build infra has
made, for diagnosis or exploratory purposes.
-->
<Target Name="PrepareInnerSourceBuildRepoRoot">
<Target Name="CloneInnerSourceBuildRepoRoot" Condition=" '$(CopySrcInsteadOfClone)' != 'true' ">
<PropertyGroup>
<!--
By default, copy WIP. WIP copy helps with local machine dev work. Don't copy WIP if this is

View file

@ -147,6 +147,7 @@
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:ArcadeBuildFromSource=true</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:CopyWipIntoInnerSourceBuildRepo=true</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:DotNetBuildOffline=true</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:CopySrcInsteadOfClone=true</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:DotNetPackageVersionPropsPath="$(PackageVersionPropsPath)"</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:AdditionalSourceBuiltNupkgCacheDir="$(SourceBuiltPackagesPath)"</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:ReferencePackageNupkgCacheDir="$(ReferencePackagesDir)"</StandardSourceBuildArgs>