Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a RepoOrigin attribute within the AssetManifest.xml file. #14718

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Microsoft.DotNet.Arcade.Sdk/tools/Publish.proj
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@
ItemsToPush="@(ItemsToPushToBlobFeed)"
ItemsToSign="@(ItemsToSignPostBuild)"
StrongNameSignInfo="@(StrongNameSignInfo)"
CertificatesSignInfo="@(CertificatesSignInfo)"
CertificatesSignInfo="@(CertificatesSignInfo)"
FileSignInfo="@(FileSignInfo)"
FileExtensionSignInfo="@(FileExtensionSignInfo)"
ManifestBuildData="@(ManifestBuildData)"
ManifestRepoUri="$(BUILD_REPOSITORY_NAME)"
ManifestBranch="$(BUILD_SOURCEBRANCH)"
ManifestBuildId="$(BUILD_BUILDNUMBER)"
ManifestCommit="$(BUILD_SOURCEVERSION)"
ManifestRepoOrigin="$(GitHubRepositoryName)"
IsStableBuild="$(IsStableBuild)"
PublishingVersion="$(PublishingVersion)"
AssetManifestPath="$(AssetManifestFilePath)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@

<!-- We need to utilize publishing to copy packages, assets and manifest to shared source-build location. -->
<InnerBuildArgs>$(InnerBuildArgs) /p:DotNetPublishUsingPipelines=true</InnerBuildArgs>

<InnerBuildArgs Condition="'$(GitHubRepositoryName)' != ''">$(InnerBuildArgs) /p:GitHubRepositoryName=$(GitHubRepositoryName)</InnerBuildArgs>
andriipatsula marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class BuildModelFactoryTests

private const string _testAzdoRepoUri = "https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-buildtest";
private const string _normalizedTestAzdoRepoUri = "https://dev.azure.com/dnceng/internal/_git/dotnet-buildtest";
private const string _testRepoOrigin = "emsdk";
private const string _testBuildBranch = "foobranch";
private const string _testBuildCommit = "664996a16fa9228cfd7a55d767deb31f62a65f51";
private const string _testAzdoBuildId = "89999999";
Expand Down Expand Up @@ -71,9 +72,8 @@ public void AttemptToCreateModelWithNoArtifactsFails()
{
Action act = () =>
_buildModelFactory.CreateModelFromItems(null, null,
null, null, null, null, _testAzdoBuildId, null, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);
null, null, null, null, _testAzdoBuildId, null, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest, true);
act.Should().Throw<ArgumentNullException>();
}

Expand Down Expand Up @@ -126,9 +126,8 @@ public void ManifestArtifactParsingTest()
};

var model = _buildModelFactory.CreateModelFromItems(artifacts, null,
null, null, null, null, _testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);
null, null, null, null, _testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest, true);

_taskLoggingHelper.HasLoggedErrors.Should().BeFalse();
// When Maestro sees a symbol package, it is supposed to re-do the symbol package path to
Expand All @@ -141,6 +140,7 @@ public void ManifestArtifactParsingTest()
blob.Attributes.Should().Contain("NonShipping", "true");
blob.Attributes.Should().Contain("Category", "SMORKELER");
blob.Attributes.Should().Contain("Id", bobSymbolsExpectedId);
blob.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
},
blob =>
{
Expand All @@ -149,13 +149,15 @@ public void ManifestArtifactParsingTest()
blob.Attributes.Should().Contain("NonShipping", "false");
blob.Attributes.Should().Contain("Category", "SNORPKEG");
blob.Attributes.Should().Contain("Id", bopSnupkgExpectedId);
blob.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
},
blob =>
{
blob.Id.Should().Be(zipArtifact);
blob.NonShipping.Should().BeFalse();
blob.Attributes.Should().Contain("ARandomBitOfMAD", string.Empty);
blob.Attributes.Should().Contain("Id", zipArtifact);
blob.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
});

model.Artifacts.Packages.Should().SatisfyRespectively(
Expand All @@ -167,6 +169,7 @@ public void ManifestArtifactParsingTest()
package.Attributes.Should().Contain("ShouldWePushDaNorpKeg", "YES");
package.Attributes.Should().Contain("Id", "test-package-a");
package.Attributes.Should().Contain("Version", "1.0.0");
package.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
});

model.Identity.Attributes.Should().Contain("AzureDevOpsRepository", _normalizedTestAzdoRepoUri);
Expand All @@ -189,9 +192,8 @@ public void ArtifactMetadataIsCaseInsensitive()
};

var model = _buildModelFactory.CreateModelFromItems(artifacts, null,
null, null, null, null, _testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);
null, null, null, null, _testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest, true);

model.Artifacts.Blobs.Should().BeEmpty();
model.Artifacts.Packages.Should().SatisfyRespectively(
Expand All @@ -205,6 +207,7 @@ public void ArtifactMetadataIsCaseInsensitive()
package.Attributes.Should().Contain("Category", "CASE");
package.Attributes.Should().Contain("Id", "test-package-a");
package.Attributes.Should().Contain("Version", "1.0.0");
package.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
});
}

Expand All @@ -228,9 +231,8 @@ public void BlobsWithoutARelativeBlobPathIsInvalid()
};

_buildModelFactory.CreateModelFromItems(artifacts, null,
null, null, null, null, _testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);
null, null, null, null, _testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest, true);

_taskLoggingHelper.HasLoggedErrors.Should().BeTrue();
_buildEngine.BuildErrorEvents.Should().Contain(e => e.Message.Equals($"Missing 'RelativeBlobPath' property on blob {zipArtifact}"));
Expand All @@ -253,9 +255,8 @@ public void MissingLocationInformationThrowsError()
};

_buildModelFactory.CreateModelFromItems(artifacts, null,
null, null, null, null, _testAzdoBuildId, null, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);
null, null, null, null, _testAzdoBuildId, null, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest, true);

// Should have logged an error that an initial location was not present.
_taskLoggingHelper.HasLoggedErrors.Should().BeTrue();
Expand Down Expand Up @@ -287,9 +288,8 @@ public void InitialLocationInformationAttributesAreAccepted(string attributeName
};

var model = _buildModelFactory.CreateModelFromItems(artifacts, null,
null, null, null, null, _testAzdoBuildId, manifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);
null, null, null, null, _testAzdoBuildId, manifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest, true);

// Should have logged an error that an initial location was not present.
_taskLoggingHelper.HasLoggedErrors.Should().BeFalse();
Expand Down Expand Up @@ -409,7 +409,7 @@ public void RoundTripFromTaskItemsToFileToXml()
{
var modelFromItems = _buildModelFactory.CreateModelFromItems(artifacts, itemsToSign,
strongNameSignInfo, fileSignInfo, fileExtensionSignInfo, certificatesSignInfo, _testAzdoBuildId,
_defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, true,
_defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, _testRepoOrigin, true,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
false);

Expand Down Expand Up @@ -448,6 +448,7 @@ public void RoundTripFromTaskItemsToFileToXml()
blob.Attributes.Should().Contain("Id", bobSymbolsExpectedId);
blob.Attributes.Should().Contain("Category", "SMORKELER");
blob.Attributes.Should().Contain("NonShipping", "true");
blob.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
},
blob =>
{
Expand All @@ -456,13 +457,15 @@ public void RoundTripFromTaskItemsToFileToXml()
blob.Attributes.Should().Contain("Id", bopSnupkgExpectedId);
blob.Attributes.Should().Contain("Category", "SNORPKEG");
blob.Attributes.Should().Contain("NonShipping", "false");
blob.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
},
blob =>
{
blob.Id.Should().Be(zipArtifact);
blob.NonShipping.Should().BeFalse();
blob.Attributes.Should().Contain("Id", zipArtifact);
blob.Attributes.Should().Contain("ARandomBitOfMAD", string.Empty);
blob.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
});

modelFromFile.Artifacts.Packages.Should().SatisfyRespectively(
Expand All @@ -474,6 +477,7 @@ public void RoundTripFromTaskItemsToFileToXml()
package.Attributes.Should().Contain("Id", "test-package-a");
package.Attributes.Should().Contain("Version", "1.0.0");
package.Attributes.Should().Contain("ShouldWePushDaNorpKeg", "YES");
package.Attributes.Should().Contain("RepoOrigin", _testRepoOrigin);
});

modelFromFile.SigningInformation.Should().NotBeNull();
Expand Down Expand Up @@ -562,8 +566,8 @@ public void NoSigningInformationDoesNotThrowAnError()
};

var model = _buildModelFactory.CreateModelFromItems(artifacts, null,
null, null, null, null, _testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
null, null, null, null, _testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);

_taskLoggingHelper.HasLoggedErrors.Should().BeFalse();
Expand Down Expand Up @@ -638,9 +642,8 @@ public void SignInfoIsCorrectlyPopulatedFromItems()

var model = _buildModelFactory.CreateModelFromItems(artifacts, itemsToSign,
strongNameSignInfo, fileSignInfo, fileExtensionSignInfo, certificatesSignInfo,
_testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);
_testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest, true);

_taskLoggingHelper.HasLoggedErrors.Should().BeFalse();
model.SigningInformation.Should().NotBeNull();
Expand Down Expand Up @@ -713,9 +716,8 @@ public void ArtifactToSignMustExistInArtifacts()

var model = _buildModelFactory.CreateModelFromItems(artifacts, itemsToSign,
null, null, null, null,
_testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit, false,
VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest,
true);
_testAzdoBuildId, _defaultManifestBuildData, _testAzdoRepoUri, _testBuildBranch, _testBuildCommit,
_testRepoOrigin, false, VersionTools.BuildManifest.Model.PublishingInfraVersion.Latest, true);

_taskLoggingHelper.HasLoggedErrors.Should().BeTrue();
_buildEngine.BuildErrorEvents.Should().HaveCount(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.DotNet.Build.Tasks.Feed
{
public interface IBlobArtifactModelFactory
{
BlobArtifactModel CreateBlobArtifactModel(ITaskItem item);
BlobArtifactModel CreateBlobArtifactModel(ITaskItem item, string repoOrigin);
}

public class BlobArtifactModelFactory : IBlobArtifactModelFactory
Expand All @@ -22,7 +22,7 @@ public BlobArtifactModelFactory(TaskLoggingHelper logger)
}

/// <summary>
/// Creates a BlobArtifactModel based on the datat in the ITaskItem provided. Logs errors that may occur,
/// Creates a BlobArtifactModel based on the data in the ITaskItem provided. Logs errors that may occur,
/// but does not prevent the creation of the BlobArtifactModel. Errors do not prevent the creation because
/// we want to allow for the capture of all errors that may occur and report back all to the user so they can
/// mitigate all the errors found instead of one at a time, which would require continual re-runs of this code
Expand All @@ -31,7 +31,7 @@ public BlobArtifactModelFactory(TaskLoggingHelper logger)
/// <param name="item"></param>
/// <param name="log"></param>
/// <returns></returns>
public BlobArtifactModel CreateBlobArtifactModel(ITaskItem item)
public BlobArtifactModel CreateBlobArtifactModel(ITaskItem item, string repoOrigin)
{
string path = item.GetMetadata("RelativeBlobPath");
if (string.IsNullOrEmpty(path))
Expand All @@ -42,7 +42,8 @@ public BlobArtifactModel CreateBlobArtifactModel(ITaskItem item)
return new BlobArtifactModel
{
Attributes = MSBuildListSplitter.GetNamedProperties(item.GetMetadata("ManifestArtifactData")),
Id = path
Id = path,
RepoOrigin = repoOrigin
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ BuildModel CreateModelFromItems(
string repoUri,
string repoBranch,
string repoCommit,
string repoOrigin,
bool isStableBuild,
PublishingInfraVersion publishingVersion,
bool isReleaseOnlyPackageVersion);
Expand Down Expand Up @@ -137,6 +138,7 @@ public BuildModel CreateModelFromItems(
string repoUri,
string repoBranch,
string repoCommit,
string repoOrigin,
bool isStableBuild,
PublishingInfraVersion publishingVersion,
bool isReleaseOnlyPackageVersion)
Expand All @@ -160,7 +162,7 @@ public BuildModel CreateModelFromItems(

if (artifact.ItemSpec.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase) && !isSymbolsPackage)
{
packageArtifacts.Add(_packageArtifactModelFactory.CreatePackageArtifactModel(artifact));
packageArtifacts.Add(_packageArtifactModelFactory.CreatePackageArtifactModel(artifact, repoOrigin));
}
else
{
Expand All @@ -170,7 +172,7 @@ public BuildModel CreateModelFromItems(
artifact.SetMetadata("RelativeBlobPath", $"{AssetsVirtualDir}symbols/{fileName}");
}

blobArtifacts.Add(_blobArtifactModelFactory.CreateBlobArtifactModel(artifact));
blobArtifacts.Add(_blobArtifactModelFactory.CreateBlobArtifactModel(artifact, repoOrigin));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public class GenerateBuildManifest : MSBuildTaskBase
/// </summary>
public string RepoCommit { get; set; }

/// <summary>
/// Indicates the source of the artifacts. For a VMR build, the repository name is dotnet/dotnet,
/// while the repository origin name corresponds to the actual product repository.
/// </summary>
public string RepoOrigin { get; set; }

/// <summary>
/// Is this manifest for a stable build?
/// </summary>
Expand Down Expand Up @@ -136,6 +142,7 @@ public bool ExecuteTask(IFileSystem fileSystem,
RepoUri,
RepoBranch,
RepoCommit,
RepoOrigin,
IsStableBuild,
targetPublishingVersion,
IsReleaseOnlyPackageVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Build.Tasks.Feed
{
public interface IPackageArtifactModelFactory
{
PackageArtifactModel CreatePackageArtifactModel(ITaskItem item);
PackageArtifactModel CreatePackageArtifactModel(ITaskItem item, string repoOrigin);
}

public class PackageArtifactModelFactory : IPackageArtifactModelFactory
Expand All @@ -25,7 +25,7 @@ public PackageArtifactModelFactory(INupkgInfoFactory nupkgInfoFactory,
_log = logger;
}

public PackageArtifactModel CreatePackageArtifactModel(ITaskItem item)
public PackageArtifactModel CreatePackageArtifactModel(ITaskItem item, string repoOrigin)
{
_log.LogMessage($"Creating NupkgInfo based on '{item.ItemSpec}'");

Expand All @@ -35,7 +35,8 @@ public PackageArtifactModel CreatePackageArtifactModel(ITaskItem item)
{
Attributes = MSBuildListSplitter.GetNamedProperties(item.GetMetadata("ManifestArtifactData")),
Id = info.Id,
Version = info.Version
Version = info.Version,
RepoOrigin = repoOrigin
};
}
}
Expand Down
Loading
Loading