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

Fix BuildPass>1 artifacts and asset manifest content #45323

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Dec 5, 2024

Fixes dotnet/source-build#4778

There are three problems with the current implementation:

  1. The asset manifest that gets produced in a BuildPass>2 build contains all the assets from the previous dependent vertical manifests. This is undesirable in general but also causes an issue when we merge all manifests together because there are duplicates that can't be resolved.

  2. Artifacts from the dependent verticals get uploaded to the "_Artifacts" pipeline artifact in CI in addition to the new artifacts produced which is a waste of resources. It also makes it harder to differentiate what actually got produced in the BuildPass>1 leg.

  3. The log that lists all the artifacts that got produced by the repo build also outputs the artifacts from the dependent verticals because their manifests were considered as well.

  4. Repo asset manifests from dependent verticals have the same name and therefore got ignored. Only the first one gets copied, all the other repo asset manifest files are ignored.


Isolate the asset manifests that get produced by the build and then later read to generated the merged (vertical) manifest, from the downloaded dependent vertical manifests. Upload the vertical manifest only, instead of all the inner repo manifests. Name the manifest based on the job name to avoid conflicts.

Don't upload everything under artifacts/assets and artifacts/packages. Instead read from the current vertical merged manifest to identify the assets to upload. Leverage an msbuild target to bin place the artifacts into the staging directory to upload. As part of that, also introduce a YML configuration property that defaults to Release and pass that into the build to be able to find the path to the vertical manifest without hardcoding a certain configuration.


Here's a build from this PR that demonstrates that the changes work as expected: https://dnceng-public.visualstudio.com/public/_build/results?buildId=888307&view=logs&s=56cc5bc2-3154-5d19-920f-2db03d3b8537&j=287a7939-eab3-5c36-8f0e-00afcd687924

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Request triage from a team member labels Dec 5, 2024
@ViktorHofer ViktorHofer force-pushed the FixBuildPass2VerticalArtifactsAndManifests branch 2 times, most recently from 8c9bacb to 93fa476 Compare December 5, 2024 12:44
Fixes dotnet/source-build#4778

There are three problems with the current implementation:

1. The asset manifest that gets produced in a BuildPass>2 build contains
all the assets from the previous dependent vertical manifests. This is
undesirable in general but also causes an issue when we merge all manifests
together because there are duplicates that can't be resolved.

2. Artifacts from the dependent verticals get uploaded to the
"<JobName>_Artifacts" pipeline artifact in CI in addition to the new
artifacts produced which is a waste of resources. It also makes it harder
to differentiate what actually got produced in the BuildPass>1 leg.

3. The log that lists all the artifacts that got produced by the repo build
also outputs the artifacts from the dependent verticals because
their manifests were considered as well.

4. Repo asset manifests from dependent verticals have the same name and
therefore got ignored. Only the first one gets copied, all the other
repo asset manifest files are ignored.

---

Isolate the asset manifests that get produced by the build and then later
read to generated the merged (vertical) manifest, from the downloaded dependent
vertical manifests. Upload the vertical manifest only, instead of all the inner
repo manifests. Name the manifest based on the job name to avoid conflicts.

Don't upload everything under artifacts/assets and artifacts/packages. Instead
read from the current vertical merged manifest to identify the assets to upload.
Leverage an msbuild project for this that prepares the directory to upload. As part
of that, also introduce a YML configuration property that defaults to Release and
pass that into the build to be able to find the path to the vertical manifest without
hardcoding a certain configuration.
@ViktorHofer
Copy link
Member Author

/azp run sdk-unified-build-full

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ViktorHofer ViktorHofer marked this pull request as ready for review December 6, 2024 15:37
@ViktorHofer ViktorHofer requested review from a team as code owners December 6, 2024 15:37
@ViktorHofer ViktorHofer requested a review from mmitche December 6, 2024 15:37
@ViktorHofer
Copy link
Member Author

This one is ready. @mmitche PTAL

@ViktorHofer ViktorHofer force-pushed the FixBuildPass2VerticalArtifactsAndManifests branch from 0aca7bc to 8ecc504 Compare December 7, 2024 10:00
# Must be a path under $(sourcesPath). Inside the docker container, we mount $(sourcesPath) to /vmr
# and can't write outside of that folder.
- name: artifactsStagingDir
value: $(sourcesPath)/artifacts/staging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we weren't running our own custom docker process, could we default this to AzDO's Artifacts.StagingDirectory?

Copy link
Member Author

@ViktorHofer ViktorHofer Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I believe that AzDO would pipe the inputs & outputs correctly. But I don't see an issue with creating the staging folder under artifacts (at least for now).

@@ -16,14 +16,14 @@

<!-- After building, generate a prebuilt usage report. -->
<Target Name="ReportPrebuiltUsage"
AfterTargets="Build"
BeforeTargets="Build"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these running in the wrong place, or is this just clean up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BinPlaceFiles target in the Directory.Build.targets file should run last so I hooked it up to run AfterTargets="Build". So I changed everything else to run BeforeTargets="Build". There were only a few places.

.Distinct()
.Select(package => new TaskItem(package.Attribute(IdAttributeName)!.Value, new Dictionary<string, string>
{
{ PackageVersionAttributeName, package.Attribute(PackageVersionAttributeName)!.Value },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you mainly adding the additional attributes here for completeness?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. We only need the NonShipping, RepoOrigin and Version ones. The DotNetReleaseShipping is just here for completeness. The other changes in this file allow filtering artiafcts based on RepoOrigin and enabling #nullable enable to check for nullrefs.

@ViktorHofer ViktorHofer enabled auto-merge (squash) December 9, 2024 17:21
@mmitche mmitche disabled auto-merge December 9, 2024 19:23
@mmitche mmitche merged commit 7361d85 into main Dec 9, 2024
34 of 38 checks passed
@mmitche mmitche deleted the FixBuildPass2VerticalArtifactsAndManifests branch December 9, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

win-x64 BuildPass=2 vertical's asset manifest contains assets from previously built verticals
2 participants