Skip to content

Commit

Permalink
[CI] Upload build asset data to darc/maestro (#11189)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcollins authored Apr 14, 2021
1 parent 737a191 commit 2dc113e
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ endif

-include $(TOP)/dotnet.config
$(TOP)/dotnet.config: $(TOP)/eng/Versions.props
$(Q) grep -A1 sdk $(TOP)/global.json | sed -e '1d' -e 's/[ \t]*"version": /DOTNET_VERSION=/' -e 's/"//g' > $@.tmp
$(Q) grep -A1 \"sdk\": $(TOP)/global.json | sed -e '1d' -e 's/[ \t]*"version": /DOTNET_VERSION=/' -e 's/"//g' > $@.tmp
$(Q) grep MicrosoftDotnetSdkInternalPackageVersion $(TOP)/eng/Versions.props | sed -e 's/<*\/*MicrosoftDotnetSdkInternalPackageVersion>//g' -e 's/[ \t]*/DOTNET6_VERSION=/' >> $@.tmp
$(Q) mv $@.tmp $@

Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ all-local:: global6.json
global6.json: $(TOP)/Make.config.inc Makefile $(TOP)/.git/HEAD $(TOP)/.git/index
$(Q_GEN) \
printf "{\n" > $@; \
printf "\t\"sdk\": { \"version\": \"$(DOTNET6_VERSION)\" },\n" >> $@; \
printf "\t\"msbuild-sdks\": {\n" >> $@; \
printf "\t\t\"Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk\": \"5.0.0-beta.20120.1\"\n" >> $@; \
printf "\t}\n}\n" >> $@
printf "\t\"sdk\": { \"version\": \"$(DOTNET6_VERSION)\" }\n" >> $@; \
printf "\n}\n" >> $@

install-hook::
@$(MAKE) check-permissions
Expand Down
73 changes: 65 additions & 8 deletions dotnet/package/common.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project>
<Import Project="../targets/Microsoft.$(_PlatformName).Sdk.Versions.props" />
<Import Project="..\..\eng\Versions.props" />

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageType Condition="'$(PackageType)'==''">DotnetPlatform</PackageType>
<PackageVersion>$(_PackageVersion)</PackageVersion>
Expand All @@ -11,15 +12,21 @@
<RepositoryCommit>$(CurrentHash)</RepositoryCommit>
<Authors>Xamarin</Authors>

<GenerateDependencyFile>false</GenerateDependencyFile>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<!-- Remove the `<group targetFramework=".NETStandard2.0" />` entry from the .nuspec. -->
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<!-- Ignore TargetFramework reference group related warnings, these are workload packs not functional NuGets. -->
<!-- NU5105: The package version '#.#.#-alpha.##+hash' uses SemVer 2.0.0 or components of SemVer 1.0.0 that are not supported on legacy clients. Change the package version to a SemVer 1.0.0 string. If the version contains a release label it must start with a letter. This message can be ignored if the package is not intended for older clients. -->
<NoWarn>$(NoWarn);NU5105</NoWarn>
<NoWarn>$(NoWarn);NU5105;NU5128;NU5131</NoWarn>
</PropertyGroup>

<PropertyGroup>
<_RepositoryPath>$(MSBuildThisFileDirectory)/../..</_RepositoryPath>
<_buildPath>$(_RepositoryPath)/_build</_buildPath>
<_packagePath Condition="'$(_packagePath)' == ''">$(_buildPath)\$(PackageId)\</_packagePath>

<NupkgPath Condition=" '$(NupkgPath)' == '' ">$([MSBuild]::NormalizeDirectory ('$(_buildPath)\nupkgs\'))</NupkgPath>
<BarManifestOutputPath Condition=" '$(BarManifestOutputPath)' == '' ">$(NupkgPath)\bar-manifests</BarManifestOutputPath>
<_AssemblyInfix Condition="'$(_PlatformName)' == 'iOS'">iOS</_AssemblyInfix>
<_AssemblyInfix Condition="'$(_PlatformName)' == 'tvOS'">TVOS</_AssemblyInfix>
<_AssemblyInfix Condition="'$(_PlatformName)' == 'watchOS'">WatchOS</_AssemblyInfix>
Expand All @@ -36,12 +43,14 @@

<!-- Code to automatically create FrameworkList.xml or RuntimeList.xml -->
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Packaging" Version="5.0.0-beta.20120.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk" Version="5.0.0-beta.20120.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Feed" Version="$(MicrosoftDotNetBuildTasksFeedPackageVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Packaging" Version="$(MicrosoftDotNetBuildTasksFeedPackageVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.DotNet.Arcade.Sdk" Version="$(MicrosoftDotNetBuildTasksFeedPackageVersion)" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup>

<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk" />
<UsingTask TaskName="CreateFrameworkListFile" AssemblyFile="$(DotNetBuildTasksSharedFrameworkTaskFile)"/>
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.SharedFramework.Sdk" Version="$(MicrosoftDotNetBuildTasksFeedPackageVersion)" />
<UsingTask TaskName="CreateFrameworkListFile" AssemblyFile="$(DotNetSharedFrameworkTaskFile)"/>
<UsingTask TaskName="GenerateBuildManifest" AssemblyFile="$(_MicrosoftDotNetBuildTasksFeedTaskDir)Microsoft.DotNet.Build.Tasks.Feed.dll" />

<Target Name="_GenerateFrameworkListFile" Condition=" '$(_CreateFrameworkList)' == 'true' Or '$(_CreateRuntimeList)' == 'true' ">
<!-- https://github.com/dotnet/runtime/blob/0647ec314948904319da5eb15e9931f7c85ed1e2/src/installer/pkg/projects/Directory.Build.targets#L281 -->
Expand Down Expand Up @@ -73,7 +82,7 @@
<!-- The CreateFrameworkListFile task will add _PackageFiles to the files to pack, so remove them if they're already there -->
<Content Remove="@(_PackageFiles)" />
</ItemGroup>
<!-- https://github.com/dotnet/arcade/blob/1924d7ea148c9f26ca3d82b60f0a775a5389ed22/src/Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk/src/CreateFrameworkListFile.cs -->
<!-- https://github.com/dotnet/arcade/blob/5824baf1c9a900ee00c167f96201c750bba6a574/src/Microsoft.DotNet.SharedFramework.Sdk/src/CreateFrameworkListFile.cs -->
<CreateFrameworkListFile
Files="@(_PackageFiles)"
FileClassifications="@(_FrameworkListFileClass)"
Expand All @@ -100,4 +109,52 @@
<PackagePath>data</PackagePath>
</Content>
</ItemGroup>

<Target Name="GenerateBuildAssetRegistryManifest" >
<ItemGroup>
<BuildArtifacts Include="$(NupkgPath)\*.nupkg" />
</ItemGroup>

<Error Condition="'@(BuildArtifacts)' == ''" Text="No packages to create manifest from." />

<ItemGroup>
<ManifestBuildData Include="InitialAssetsLocation=https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json" />
<ManifestBuildData Include="AzureDevOpsBuildId=$(BUILD_BUILDID)" />
<ManifestBuildData Include="AzureDevOpsBuildDefinitionId=$(SYSTEM_DEFINITIONID)" />
<ManifestBuildData Include="AzureDevOpsProject=$(SYSTEM_TEAMPROJECT)" />
<ManifestBuildData Include="AzureDevOpsBuildNumber=$(BUILD_BUILDNUMBER)" />
<ManifestBuildData Include="AzureDevOpsRepository=$(BUILD_REPOSITORY_URI)" />
<ManifestBuildData Include="AzureDevOpsBranch=$(BUILD_SOURCEBRANCH)" />
</ItemGroup>

<GenerateBuildManifest
Artifacts="@(BuildArtifacts)"
OutputPath="$(BarManifestOutputPath)\AssetManifest.xml"
BuildId="$(BUILD_BUILDNUMBER)"
BuildData="@(ManifestBuildData)"
RepoUri="$(BUILD_REPOSITORY_URI)"
RepoBranch="$(BUILD_SOURCEBRANCH)"
RepoCommit="$(BUILD_SOURCEVERSION)"
PublishingVersion="3" />

<Message Importance="high" Text="##vso[artifact.upload containerfolder=AssetManifests;artifactname=AssetManifests]$(BarManifestOutputPath)/AssetManifest.xml" />
</Target>

<Target Name="PushManifestToBuildAssetRegistry" >
<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
</PropertyGroup>

<MSBuild
Targets="Restore"
Projects="$(PkgMicrosoft_DotNet_Arcade_Sdk)\tools\SdkTasks\PublishBuildAssets.proj"
Properties="Configuration=$(Configuration);RepoRoot=$(_RepositoryPath);VersionPrefix=$(VersionPrefix)"
/>

<MSBuild
Projects="$(PkgMicrosoft_DotNet_Arcade_Sdk)\tools\SdkTasks\PublishBuildAssets.proj"
Properties="Configuration=$(Configuration);RepoRoot=$(_RepositoryPath);VersionPrefix=$(VersionPrefix);ManifestsPath=$(BarManifestOutputPath);MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com"
/>
</Target>

</Project>
18 changes: 18 additions & 0 deletions eng/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,27 @@ release branch is created, someone with `darc` installed locally will need to
run the `add-subscription` command to configure updates against that new branch.


#### Build Asset Manifest Promotion

Builds from main and release branches will push NuGet package metadata to the
darc/maestro Build Asset Registry. This build information will also be promoted
to a default darc/maestro channel if one is configured. Default channels are
manually managed at this time. To configure a new default repo+branch <-> channel
association, run the [`darc add-default-channel`][6] command:
```
darc add-default-channel --channel ".NET 6" --branch "main" --repo https://github.com/xamarin/xamarin-macios
```

When a new release branch is created, this command should look something like this:
```
darc add-default-channel --channel ".NET 6.0.1xx SDK Preview 4" --branch "release/6.0.1xx-preview4" --repo https://github.com/xamarin/xamarin-macios
```


[0]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md
[1]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#setting-up-your-darc-client
[2]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#authenticate
[3]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#add-dependency
[4]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#update-dependencies
[5]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#add-subscription
[6]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#add-default-channel
6 changes: 6 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
<Sha>6bfa2c0657d2dcfd6dce684ab34b470ce567631a</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="6.0.0-beta.21212.6">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>db49d790a4bfa977a9ed7436bf2aa242cefae45e</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<MicrosoftDotnetSdkInternalPackageVersion>6.0.100-preview.3.21202.5</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkPackageVersion>6.0.100-preview.2.21212.1</MicrosoftNETILLinkPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>6.0.100-preview.2.21212.1</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>6.0.0-beta.21212.6</MicrosoftDotNetBuildTasksFeedPackageVersion>
</PropertyGroup>
</Project>
61 changes: 61 additions & 0 deletions tools/devops/automation/post-build-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# YAML pipeline for post build operations.
# This pipeline will trigger automatically after successful completion of the `build_packages` stage against the specified branches.

trigger: none
pr: none

resources:
pipelines:
- pipeline: macios
source: xamarin-macios
trigger:
branches:
- main
- release/*
stages:
- build_packages

jobs:
- job: post_build
displayName: Post Build
pool:
vmImage: windows-2019
workspace:
clean: all
variables:
- group: Publish-Build-Assets
steps:
- checkout: self
clean: true

- task: UseDotNet@2
inputs:
version: 5.0.200

- download: macios
artifact: AssetManifests

- script: make -C $(Build.SourcesDirectory)/dotnet targets/Microsoft.iOS.Sdk.Versions.props
displayName: make Microsoft.iOS.Sdk.Versions.props

- powershell: >-
& dotnet build -v:n -t:PushManifestToBuildAssetRegistry
-p:BarManifestOutputPath=$(Agent.BuildDirectory)\macios\AssetManifests -p:BuildAssetRegistryToken=$(MaestroAccessToken)
$(Build.SourcesDirectory)\dotnet\package\Microsoft.iOS.Ref\package.csproj
-bl:$(Build.ArtifactStagingDirectory)\post-build-binlogs\push-bar-manifest.binlog
displayName: push manifest to build asset registry
- powershell: |
$versionEndpoint = 'https://maestro-prod.westus2.cloudapp.azure.com/api/assets/darc-version?api-version=2019-01-16'
$darcVersion = $(Invoke-WebRequest -Uri $versionEndpoint -UseBasicParsing).Content
$arcadeServicesSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json'
& dotnet tool update microsoft.dotnet.darc --version "$darcVersion" --add-source "$arcadeServicesSource" --tool-path $(Agent.ToolsDirectory)\darc -v n
& $(Agent.ToolsDirectory)\darc\darc add-build-to-channel --default-channels --id $(BARBuildId) --publishing-infra-version 3 --skip-assets-publishing --password $(MaestroAccessToken) --azdev-pat $(publishing-dnceng-devdiv-code-r-build-re)
displayName: add build to default darc channel
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: post-build-binlogs'
inputs:
targetPath: $(Build.ArtifactStagingDirectory)\post-build-binlogs
artifactName: post-build-binlogs
condition: succeededOrFailed()
14 changes: 14 additions & 0 deletions tools/devops/automation/templates/build/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,20 @@ steps:
continueOnError: true # should not stop the build since is not official just yet.
timeoutInMinutes: 180

- script: >-
dotnet build -t:GenerateBuildAssetRegistryManifest /v:n
$(Build.SourcesDirectory)/xamarin-macios/dotnet/package/Microsoft.iOS.Ref/package.csproj
-bl:$(Build.ArtifactStagingDirectory)/build-binlogs/generate-bar-manifest.binlog
displayName: Generate and Upload Build Asset Registry Manifest
condition: and(succeeded(), contains(variables['configuration.BuildNugets'], 'True'))

- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: build-binlogs'
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/build-binlogs
artifactName: build-binlogs
condition: and(succeededOrFailed(), contains(variables['configuration.BuildNugets'], 'True'))

- task: NuGetCommand@2
displayName: 'Publish Nugets'
inputs:
Expand Down

4 comments on commit 2dc113e

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

Packages generated

View packages

Test results

2 tests failed, 180 tests passed.

Failed tests

  • monotouch-test/Mac [dotnet]/Debug [dotnet]: Failed (Test run crashed (exit code: 134).
    No test log file was produced)
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 5.0): LaunchFailure

Pipeline on Agent XAMBOT-1017

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests iOS32b). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent

Please sign in to comment.