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

[main] Add CI for building with previously source-built SDK #15603

Merged
merged 12 commits into from
Mar 4, 2023
43 changes: 36 additions & 7 deletions eng/pipelines/templates/jobs/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ parameters:
type: boolean
default: false

- name: withPreviousSDK
type: boolean
default: false

jobs:
- job: ${{ parameters.buildName }}_${{ parameters.architecture }}
timeoutInMinutes: 150
Expand All @@ -76,12 +80,8 @@ jobs:
- ${{ else }}:
- name: BotAccount-dotnet-bot-repo-PAT
value: N/A
- ${{ if eq(parameters.reuseBuildArtifactsFrom, '') }}:
- name: additionalBuildArgs
value: ''
- ${{ else }}:
- name: additionalBuildArgs
value: ' --with-sdk /vmr/.dotnet'
- name: additionalBuildArgs
value: ''

# Location of the VMR sources
# We either build the repo directly, or we extract them outside (which is what partners do)
Expand Down Expand Up @@ -147,16 +147,45 @@ jobs:
Contents: '*.tar.gz'
TargetFolder: ${{ variables.sourcesPath }}/prereqs/packages/archive/

- ${{ if eq(parameters.withPreviousSDK, 'true') }}:
- script: |
set -euo pipefail

packageVersionsPath="${{ variables.sourcesPath }}/eng/Versions.props"
notFoundMessage="No source-built SDK found to download..."

echo "Looking for source-built SDK to download..."
archiveUrlLine=`grep -m 1 "<PrivateSourceBuiltSdkUrl>" "$packageVersionsPath" || :`
urlPattern="<PrivateSourceBuiltSdkUrl>(.*)</PrivateSourceBuiltSdkUrl>"

if [[ $archiveUrlLine =~ $urlPattern ]]; then
archiveUrl="${BASH_REMATCH[1]}"
downloadDir="$(sourcesPath)/prereqs/packages/archive/"
(cd $downloadDir && curl --retry 5 -O $archiveUrl)
else
echo "$notFoundMessage"
exit 1
fi
displayName: Setup Previously Source-Built SDK

- script: |
set -x

if [[ -z '${{ parameters.reuseBuildArtifactsFrom }}' ]]; then
if [[ -z '${{ parameters.reuseBuildArtifactsFrom }}' && '${{ parameters.withPreviousSDK }}' != 'True' ]]; then
docker run --rm -v "$(sourcesPath):/vmr" -w /vmr ${{ parameters.container }} ./prep.sh
else
mkdir $(sourcesPath)/.dotnet
previousSdkPath="$(sourcesPath)/prereqs/packages/archive/dotnet-sdk-*.tar.gz"
eval tar -ozxf "$previousSdkPath" -C "$(sourcesPath)/.dotnet"
eval rm -f "$previousSdkPath"

if [[ '${{ parameters.withPreviousSDK }}' == 'True' ]]; then
# Source-built artifacts are from CentOS 8 Stream. We want to download them without
# downloading portable versions from the internet.
docker run --rm -v "$(sourcesPath):/vmr" -w /vmr ${{ parameters.container }} ./prep.sh --no-bootstrap
fi

echo "##vso[task.setvariable variable=additionalBuildArgs]--with-sdk /tarball/.dotnet"
lbussell marked this conversation as resolved.
Show resolved Hide resolved
fi
displayName: Prep the Build

Expand Down
40 changes: 33 additions & 7 deletions eng/pipelines/templates/stages/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ stages:
jobs:
- template: ../jobs/vmr-build.yml
parameters:
buildName: CentOSStream8_Online
buildName: CentOSStream8_Online_MsftSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
Expand All @@ -81,11 +81,31 @@ stages:
excludeSdkContentTests: true # ✅
overrideDistroDisablingSha1: false # 🚫
runOnline: true # ✅
withPreviousSDK: false # 🚫

# Temporarily move this to PR build just to test the N-1 CI
- template: ../jobs/vmr-build.yml
parameters:
buildName: CentOSStream8_Online_PreviousSourceBuiltSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
pool:
name: ${{ variables.defaultPoolName }}
demands: ${{ variables.defaultPoolDemands }}
container: ${{ parameters.centOSStream8Container }}
buildFromArchive: false # 🚫
enablePoison: false # 🚫
excludeOmniSharpTests: true # ✅
excludeSdkContentTests: true # ✅
overrideDistroDisablingSha1: false # 🚫
runOnline: true # ✅
withPreviousSDK: true # ✅

- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
- template: ../jobs/vmr-build.yml
parameters:
buildName: CentOSStream8_Offline
buildName: CentOSStream8_Offline_MsftSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
Expand All @@ -99,10 +119,11 @@ stages:
excludeSdkContentTests: false # 🚫
overrideDistroDisablingSha1: false # 🚫
runOnline: false # 🚫
withPreviousSDK: false # 🚫

- template: ../jobs/vmr-build.yml
parameters:
buildName: CentOSStream9_Offline
buildName: CentOSStream9_Offline_MsftSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
Expand All @@ -116,10 +137,11 @@ stages:
excludeSdkContentTests: false # 🚫
overrideDistroDisablingSha1: true # ✅
runOnline: false # 🚫
withPreviousSDK: false # 🚫

- template: ../jobs/vmr-build.yml
parameters:
buildName: Fedora36_Offline
buildName: Fedora36_Offline_MsftSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
Expand All @@ -133,10 +155,11 @@ stages:
excludeSdkContentTests: false # 🚫
overrideDistroDisablingSha1: false # 🚫
runOnline: false # 🚫
withPreviousSDK: false # 🚫

- template: ../jobs/vmr-build.yml
parameters:
buildName: Ubuntu2004_Offline
buildName: Ubuntu2004_Offline_MsftSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
Expand All @@ -150,10 +173,11 @@ stages:
excludeSdkContentTests: false # 🚫
overrideDistroDisablingSha1: false # 🚫
runOnline: false # 🚫
withPreviousSDK: false # 🚫

- template: ../jobs/vmr-build.yml
parameters:
buildName: Debian11_Offline
buildName: Debian11_Offline_MsftSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: arm64
Expand All @@ -165,10 +189,11 @@ stages:
excludeSdkContentTests: false # 🚫
overrideDistroDisablingSha1: false # 🚫
runOnline: false # 🚫
withPreviousSDK: false # 🚫

- template: ../jobs/vmr-build.yml
parameters:
buildName: Fedora36_Offline_Using_Previous
buildName: Fedora36_Offline_CurrentSourceBuiltSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
Expand All @@ -182,4 +207,5 @@ stages:
excludeSdkContentTests: true # ✅
overrideDistroDisablingSha1: false # 🚫
runOnline: false # 🚫
withPreviousSDK: false # 🚫
reuseBuildArtifactsFrom: Fedora36_Offline
lbussell marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 6 additions & 11 deletions src/SourceBuild/content/eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@

<PropertyGroup>
<!--
Building .NET from source depends on one or two tar.gz files depending on the branch's current
Building .NET from source depends on several archives, depending on the branch's current
source-buildability status.

PrivateSourceBuiltArtifactsPackageVersion is a tar.gz of .NET build outputs from a previous
build needed to build the current version of .NET. This is always defined, because .NET needs
to be bootstrappable at any point in time.

PrivateSourceBuiltPrebuiltsPackageVersion is a tar.gz of assets downloaded from the internet
that are needed to build the current version of .NET. Early in the lifecycle of a .NET major
or minor release, prebuilts may be needed. When the release is mature, prebuilts are not
necessary, and this property is removed from the file.
These URLs can't be composed from their base URL and version as we read them from the
prep.sh and pipeline scripts, outside of MSBuild.
-->
<PrivateSourceBuiltArtifactsPackageVersion>0.1.0-8.0.100-5.centos.8-x64</PrivateSourceBuiltArtifactsPackageVersion>
<PrivateSourceBuiltPrebuiltsPackageVersion>0.1.0-8.0.100-8.centos.8-x64</PrivateSourceBuiltPrebuiltsPackageVersion>
<PrivateSourceBuiltArtifactsUrl>https://dotnetcli.azureedge.net/dotnet/source-built-artifacts/assets/Private.SourceBuilt.Artifacts.0.1.0-8.0.100-5.centos.8-x64.tar.gz</PrivateSourceBuiltArtifactsUrl>
<PrivateSourceBuiltPrebuiltsUrl>https://dotnetcli.azureedge.net/dotnet/source-built-artifacts/assets/Private.SourceBuilt.Prebuilts.0.1.0-8.0.100-8.centos.8-x64.tar.gz</PrivateSourceBuiltPrebuiltsUrl>
<PrivateSourceBuiltSdkUrl>https://dotnetcli.azureedge.net/dotnet/source-built-artifacts/sdks/dotnet-sdk-8.0.100-preview.1.23115.1-centos.8-x64.tar.gz</PrivateSourceBuiltSdkUrl>
lbussell marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
</Project>
16 changes: 11 additions & 5 deletions src/SourceBuild/content/prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ usage() {
echo ""
echo " Prepares the environment to be built by downloading Private.SourceBuilt.Artifacts.*.tar.gz and"
echo " installing the version of dotnet referenced in global.json"
echo "options:"
lbussell marked this conversation as resolved.
Show resolved Hide resolved
echo " --no-bootstrap Don't replace portable packages in the download source-built artifacts"
echo ""
}

Expand All @@ -24,6 +26,9 @@ while :; do
usage
exit 0
;;
--no-bootstrap)
buildBootstrap=false
lbussell marked this conversation as resolved.
Show resolved Hide resolved
;;
*)
positional_args+=("$1")
;;
Expand Down Expand Up @@ -69,15 +74,14 @@ function DownloadArchive {
baseFileName="$2"
isRequired="$3"

sourceBuiltArtifactsTarballUrl="https://dotnetcli.azureedge.net/source-built-artifacts/assets/"
packageVersionsPath="$SCRIPT_ROOT/eng/Versions.props"
notFoundMessage="No source-built $archiveType found to download..."

echo " Looking for source-built $archiveType to download..."
archiveVersionLine=`grep -m 1 "<PrivateSourceBuilt${archiveType}PackageVersion>" "$packageVersionsPath" || :`
versionPattern="<PrivateSourceBuilt${archiveType}PackageVersion>(.*)</PrivateSourceBuilt${archiveType}PackageVersion>"
archiveVersionLine=`grep -m 1 "<PrivateSourceBuilt${archiveType}Url>" "$packageVersionsPath" || :`
versionPattern="<PrivateSourceBuilt${archiveType}Url>(.*)</PrivateSourceBuilt${archiveType}Url>"
if [[ $archiveVersionLine =~ $versionPattern ]]; then
archiveUrl="${sourceBuiltArtifactsTarballUrl}${baseFileName}.${BASH_REMATCH[1]}.tar.gz"
lbussell marked this conversation as resolved.
Show resolved Hide resolved
archiveUrl="${BASH_REMATCH[1]}"
echo " Downloading source-built $archiveType from $archiveUrl..."
(cd $packagesArchiveDir && curl --retry 5 -O $archiveUrl)
elif [ "$isRequired" == "true" ]; then
Expand Down Expand Up @@ -124,7 +128,9 @@ fi
# Read the eng/Versions.props to get the archives to download and download them
if [ "$downloadArtifacts" == "true" ]; then
DownloadArchive "Artifacts" $artifactsBaseFileName "true"
BootstrapArtifacts
if [ "$buildBootstrap" == "true" ]; then
BootstrapArtifacts
fi
fi

if [ "$downloadPrebuilts" == "true" ]; then
Expand Down