2022-12-01 09:51:39 +00:00
|
|
|
### This job source-builds https://github.com/dotnet/dotnet with given parameters
|
|
|
|
### If run in a PR, new changes are applied to a local copy of the VMR, then it is source-built and tested
|
|
|
|
|
|
|
|
parameters:
|
2022-12-15 08:33:09 +00:00
|
|
|
- name: isBuiltFromVmr
|
|
|
|
displayName: True when build is running from dotnet/dotnet directly
|
|
|
|
type: boolean
|
2022-12-01 09:51:39 +00:00
|
|
|
|
|
|
|
- name: vmrPath
|
|
|
|
type: string
|
|
|
|
default: $(Agent.BuildDirectory)/vmr
|
|
|
|
|
|
|
|
- name: vmrBranch
|
|
|
|
displayName: dotnet/dotnet branch to use
|
|
|
|
type: string
|
2023-01-31 17:30:25 +00:00
|
|
|
default: $(Build.SourceBranch)
|
2022-12-01 09:51:39 +00:00
|
|
|
|
|
|
|
- name: buildName
|
|
|
|
type: string
|
|
|
|
|
|
|
|
- name: architecture
|
|
|
|
type: string
|
|
|
|
|
2023-11-07 16:54:50 +00:00
|
|
|
- name: artifactsRid
|
|
|
|
type: string
|
|
|
|
default: ''
|
|
|
|
|
2022-12-01 09:51:39 +00:00
|
|
|
- name: container
|
|
|
|
type: string
|
|
|
|
|
|
|
|
- name: pool
|
|
|
|
type: object
|
|
|
|
|
|
|
|
# Allow downloading artifacts from the internet during the build
|
|
|
|
- name: runOnline
|
|
|
|
type: boolean
|
|
|
|
|
|
|
|
# Name of a previous job (from the same template as this) whose output will be used to build this job
|
|
|
|
# The SDK from its artifacts is copied to vmr/.dotnet
|
|
|
|
- name: reuseBuildArtifactsFrom
|
|
|
|
type: string
|
|
|
|
default: ''
|
|
|
|
|
|
|
|
- name: excludeOmniSharpTests
|
|
|
|
type: boolean
|
|
|
|
|
|
|
|
- name: enablePoison
|
|
|
|
type: boolean
|
|
|
|
|
2023-01-13 18:14:44 +00:00
|
|
|
# Instead of building the VMR directly, exports the sources into a tarball and builds from that
|
|
|
|
- name: buildFromArchive
|
|
|
|
type: boolean
|
|
|
|
|
2023-03-14 16:17:21 +00:00
|
|
|
# Use the previous version's SDK to build the current one
|
2023-03-04 01:53:19 +00:00
|
|
|
- name: withPreviousSDK
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
|
2023-05-18 19:07:54 +00:00
|
|
|
- name: useMonoRuntime
|
|
|
|
displayName: True when build output uses the mono runtime
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
|
2023-12-04 21:07:43 +00:00
|
|
|
- name: crossRootFS
|
|
|
|
type: string
|
|
|
|
default: ''
|
|
|
|
|
|
|
|
- name: targetRid
|
|
|
|
type: string
|
|
|
|
default: ''
|
|
|
|
|
2022-12-01 09:51:39 +00:00
|
|
|
jobs:
|
|
|
|
- job: ${{ parameters.buildName }}_${{ parameters.architecture }}
|
|
|
|
timeoutInMinutes: 150
|
|
|
|
pool: ${{ parameters.pool }}
|
|
|
|
${{ if ne(parameters.reuseBuildArtifactsFrom, '') }}:
|
|
|
|
# Always attempt to run the bootstrap leg (e.g. even when stage 1 tests fail) in order to get a complete accessment of the build status.
|
|
|
|
# The build shortcuts when stage 1 build fails and doesn't produce the SDK.
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
dependsOn: ${{ parameters.reuseBuildArtifactsFrom }}_${{ parameters.architecture }}
|
|
|
|
variables:
|
|
|
|
- template: /eng/common/templates/variables/pool-providers.yml
|
2023-01-18 09:35:23 +00:00
|
|
|
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
|
|
|
|
- group: AzureDevOps-Artifact-Feeds-Pats
|
2023-08-17 17:27:03 +00:00
|
|
|
- ${{ if and(not(parameters.isBuiltFromVmr), eq(variables['System.TeamProject'], 'internal'), not(startswith(parameters.vmrBranch, 'internal/release/')), not(eq(variables['Build.Reason'], 'PullRequest'))) }}:
|
2022-12-01 09:51:39 +00:00
|
|
|
- group: DotNetBot-GitHub
|
|
|
|
- ${{ else }}:
|
|
|
|
- name: BotAccount-dotnet-bot-repo-PAT
|
|
|
|
value: N/A
|
2023-03-04 01:53:19 +00:00
|
|
|
- name: additionalBuildArgs
|
|
|
|
value: ''
|
2022-12-01 09:51:39 +00:00
|
|
|
|
2023-01-13 18:14:44 +00:00
|
|
|
# Location of the VMR sources
|
|
|
|
# We either build the repo directly, or we extract them outside (which is what partners do)
|
|
|
|
- ${{ if parameters.buildFromArchive }}:
|
|
|
|
- name: sourcesPath
|
|
|
|
value: $(Build.StagingDirectory)/dotnet-sources/
|
|
|
|
- ${{ else }}:
|
|
|
|
- name: sourcesPath
|
|
|
|
value: ${{ parameters.vmrPath }}
|
|
|
|
|
2022-12-01 09:51:39 +00:00
|
|
|
steps:
|
|
|
|
- template: ../steps/vmr-prepare.yml
|
|
|
|
parameters:
|
2023-10-30 16:39:58 +00:00
|
|
|
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
|
|
|
|
vmrBranch: $(System.PullRequest.TargetBranch)
|
|
|
|
${{ else }}:
|
|
|
|
vmrBranch: ${{ parameters.vmrBranch }}
|
2022-12-15 08:33:09 +00:00
|
|
|
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
|
2022-12-01 09:51:39 +00:00
|
|
|
skipComponentGovernanceDetection: true
|
|
|
|
|
|
|
|
# Synchronize new content in the VMR during PRs (we expect this to come
|
2022-12-15 08:33:09 +00:00
|
|
|
- ${{ if and(not(parameters.isBuiltFromVmr), eq(variables['Build.Reason'], 'PullRequest')) }}:
|
2022-12-01 09:51:39 +00:00
|
|
|
- template: ../steps/vmr-pull-updates.yml
|
|
|
|
parameters:
|
|
|
|
vmrPath: ${{ parameters.vmrPath }}
|
|
|
|
vmrBranch: ${{ parameters.vmrBranch }}
|
|
|
|
targetRef: $(Build.SourceVersion) # Synchronize the current installer commit
|
|
|
|
|
2023-01-13 18:14:44 +00:00
|
|
|
- ${{ if parameters.buildFromArchive }}:
|
|
|
|
- script: |
|
|
|
|
set -ex
|
2023-04-03 16:55:55 +00:00
|
|
|
cp -r "${{ parameters.vmrPath }}" "$(sourcesPath)"
|
|
|
|
rm -rf "$(sourcesPath)/.git"
|
2023-01-13 18:14:44 +00:00
|
|
|
displayName: Export VMR sources
|
|
|
|
workingDirectory: $(Build.StagingDirectory)
|
|
|
|
|
2022-12-01 09:51:39 +00:00
|
|
|
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
|
2023-01-13 18:14:44 +00:00
|
|
|
- script: cp "$(sourcesPath)/src/installer/NuGet.config" "$(sourcesPath)/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/online.NuGet.Config"
|
2022-12-01 09:51:39 +00:00
|
|
|
displayName: Copy Test NuGet Config
|
|
|
|
|
|
|
|
- task: Bash@3
|
|
|
|
displayName: Setup Private Feeds Credentials
|
|
|
|
inputs:
|
2023-01-13 18:14:44 +00:00
|
|
|
filePath: $(sourcesPath)/src/installer/eng/common/SetupNugetSources.sh
|
|
|
|
arguments: $(sourcesPath)/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/online.NuGet.Config $Token
|
2022-12-01 09:51:39 +00:00
|
|
|
env:
|
|
|
|
Token: $(dn-bot-dnceng-artifact-feeds-rw)
|
|
|
|
|
|
|
|
- ${{ if ne(parameters.reuseBuildArtifactsFrom, '') }}:
|
|
|
|
- download: current
|
|
|
|
artifact: ${{ parameters.reuseBuildArtifactsFrom }}_${{ parameters.architecture }}_Artifacts
|
2023-04-05 14:51:46 +00:00
|
|
|
patterns: |
|
|
|
|
**/Private.SourceBuilt.Artifacts.*.tar.gz
|
2023-10-12 20:06:02 +00:00
|
|
|
**/dotnet-sdk-*.tar.gz
|
2022-12-01 09:51:39 +00:00
|
|
|
displayName: Download Previous Build
|
|
|
|
|
|
|
|
- task: CopyFiles@2
|
|
|
|
displayName: Copy Previous Build
|
|
|
|
inputs:
|
|
|
|
SourceFolder: $(Pipeline.Workspace)/${{ parameters.reuseBuildArtifactsFrom }}_${{ parameters.architecture }}_Artifacts
|
|
|
|
Contents: '*.tar.gz'
|
2023-02-09 18:19:09 +00:00
|
|
|
TargetFolder: ${{ variables.sourcesPath }}/prereqs/packages/archive/
|
2022-12-01 09:51:39 +00:00
|
|
|
|
2023-03-04 01:53:19 +00:00
|
|
|
- ${{ if eq(parameters.withPreviousSDK, 'true') }}:
|
|
|
|
- script: |
|
|
|
|
set -euo pipefail
|
|
|
|
|
2023-11-07 16:54:50 +00:00
|
|
|
if [[ '${{ parameters.artifactsRid }}' == '' ]]; then
|
|
|
|
echo "'artifactsRid' is not specified. Cannot download source-built SDK."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-04 01:53:19 +00:00
|
|
|
packageVersionsPath="${{ variables.sourcesPath }}/eng/Versions.props"
|
|
|
|
notFoundMessage="No source-built SDK found to download..."
|
|
|
|
|
|
|
|
echo "Looking for source-built SDK to download..."
|
2023-11-07 16:54:50 +00:00
|
|
|
archiveVersionLine=$(grep -m 1 "<PrivateSourceBuiltSdkVersion>" "$packageVersionsPath" || :)
|
|
|
|
versionPattern="<PrivateSourceBuiltSdkVersion>(.*)</PrivateSourceBuiltSdkVersion>"
|
2023-03-04 01:53:19 +00:00
|
|
|
|
2023-11-07 16:54:50 +00:00
|
|
|
if [[ $archiveVersionLine =~ $versionPattern ]]; then
|
|
|
|
archiveVersion="${BASH_REMATCH[1]}"
|
|
|
|
archiveUrl="https://dotnetcli.azureedge.net/source-built-artifacts/sdks/dotnet-sdk-$archiveVersion-${{ parameters.artifactsRid }}.tar.gz"
|
2023-03-04 01:53:19 +00:00
|
|
|
downloadDir="$(sourcesPath)/prereqs/packages/archive/"
|
2023-11-07 16:54:50 +00:00
|
|
|
|
|
|
|
echo "Downloading source-built SDK from $archiveUrl..."
|
|
|
|
(cd "$downloadDir" && curl --retry 5 -O "$archiveUrl")
|
2023-03-04 01:53:19 +00:00
|
|
|
else
|
|
|
|
echo "$notFoundMessage"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
displayName: Setup Previously Source-Built SDK
|
|
|
|
|
2022-12-01 09:51:39 +00:00
|
|
|
- script: |
|
|
|
|
set -x
|
|
|
|
|
2023-03-14 16:17:21 +00:00
|
|
|
customPrepArgs=""
|
|
|
|
prepSdk=true
|
2023-11-07 16:54:50 +00:00
|
|
|
|
|
|
|
if [[ -n '${{ parameters.artifactsRid }}' ]]; then
|
|
|
|
customPrepArgs="${customPrepArgs} --artifacts-rid ${{ parameters.artifactsRid }}"
|
|
|
|
fi
|
|
|
|
|
2023-03-14 16:17:21 +00:00
|
|
|
if [[ '${{ parameters.withPreviousSDK }}' == 'True' ]]; then
|
2023-11-07 16:54:50 +00:00
|
|
|
# Source-built artifacts are from CentOS 8 Stream or Alpine 3.17. We want to download them without
|
2023-03-14 16:17:21 +00:00
|
|
|
# downloading portable versions from the internet.
|
|
|
|
customPrepArgs="${customPrepArgs} --no-sdk --no-bootstrap"
|
|
|
|
prepSdk=false
|
|
|
|
elif [[ -n '${{ parameters.reuseBuildArtifactsFrom }}' ]]; then
|
|
|
|
customPrepArgs="${customPrepArgs} --no-sdk --no-artifacts"
|
|
|
|
prepSdk=false
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$prepSdk" == "false" ]]; then
|
2023-01-13 18:14:44 +00:00
|
|
|
mkdir $(sourcesPath)/.dotnet
|
2023-02-09 18:19:09 +00:00
|
|
|
previousSdkPath="$(sourcesPath)/prereqs/packages/archive/dotnet-sdk-*.tar.gz"
|
2023-01-13 18:14:44 +00:00
|
|
|
eval tar -ozxf "$previousSdkPath" -C "$(sourcesPath)/.dotnet"
|
2022-12-01 09:51:39 +00:00
|
|
|
eval rm -f "$previousSdkPath"
|
2023-03-04 01:53:19 +00:00
|
|
|
|
|
|
|
echo "##vso[task.setvariable variable=additionalBuildArgs]--with-sdk /vmr/.dotnet"
|
2022-12-01 09:51:39 +00:00
|
|
|
fi
|
2023-03-14 16:17:21 +00:00
|
|
|
|
2023-12-08 16:51:37 +00:00
|
|
|
# Only use Docker stuff on Linux
|
|
|
|
if [[ "`uname -s`" == "Linux" ]]; then
|
2023-12-08 17:12:49 +00:00
|
|
|
docker run --rm -v "$(sourcesPath):/vmr" -w /vmr ${{ parameters.container }} ./prep.sh $customPrepArgs
|
2023-12-08 16:51:37 +00:00
|
|
|
else
|
2023-12-08 20:58:57 +00:00
|
|
|
cd $(sourcesPath)
|
2023-12-08 17:12:49 +00:00
|
|
|
./prep.sh $customPrepArgs
|
2023-12-08 16:51:37 +00:00
|
|
|
fi
|
2022-12-01 09:51:39 +00:00
|
|
|
displayName: Prep the Build
|
|
|
|
|
|
|
|
- script: |
|
|
|
|
set -x
|
|
|
|
df -h
|
|
|
|
|
2023-02-02 17:14:58 +00:00
|
|
|
# Allows Arcade to have access to the commit for the build
|
|
|
|
customRunArgs="-e BUILD_SOURCEVERSION"
|
2022-12-01 09:51:39 +00:00
|
|
|
customBuildArgs=
|
|
|
|
if [[ '${{ parameters.runOnline }}' == 'True' ]]; then
|
|
|
|
customBuildArgs='--online'
|
|
|
|
else
|
2023-02-02 17:14:58 +00:00
|
|
|
customRunArgs="$customRunArgs --network none"
|
2023-01-19 16:35:37 +00:00
|
|
|
fi
|
|
|
|
|
2022-12-01 09:51:39 +00:00
|
|
|
if [[ '${{ parameters.enablePoison }}' == 'True' ]]; then
|
|
|
|
customBuildArgs="$customBuildArgs --poison"
|
|
|
|
fi
|
|
|
|
|
2023-04-24 14:23:43 +00:00
|
|
|
if [[ '${{ parameters.buildFromArchive }}' == 'True' ]]; then
|
|
|
|
customBuildArgs="$customBuildArgs --source-repository https://github.com/dotnet/dotnet"
|
|
|
|
customBuildArgs="$customBuildArgs --source-version $(git -C "${{ parameters.vmrPath }}" rev-parse HEAD)"
|
|
|
|
fi
|
|
|
|
|
2023-05-18 19:07:54 +00:00
|
|
|
if [[ '${{ parameters.useMonoRuntime }}' == 'True' ]]; then
|
2023-05-19 14:44:38 +00:00
|
|
|
customBuildArgs="$customBuildArgs --use-mono-runtime"
|
2023-05-18 19:07:54 +00:00
|
|
|
fi
|
|
|
|
|
2023-12-04 21:07:43 +00:00
|
|
|
if [[ ! -z '${{ parameters.crossRootFs }}' || ! -z '${{ parameters.targetRid }}' ]]; then
|
|
|
|
extraBuildProperties="--"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -z '${{ parameters.crossRootFs }}' ]]; then
|
|
|
|
customRunArgs="$customRunArgs -e CROSSCOMPILE=1 -e ROOTFS_DIR=${{ parameters.crossRootFs}}"
|
|
|
|
extraBuildProperties="$extraBuildProperties /p:PortableBuild=true /p:DotNetBuildVertical=true"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -z '${{ parameters.targetRid }}' ]]; then
|
|
|
|
extraBuildProperties="$extraBuildProperties /p:OverrideTargetRid=${{ parameters.targetRid }}"
|
|
|
|
fi
|
|
|
|
|
2023-12-08 16:51:37 +00:00
|
|
|
# Only use Docker stuff on Linux
|
|
|
|
if [[ "`uname -s`" == "Linux" ]]; then
|
2023-12-08 18:02:00 +00:00
|
|
|
docker run --rm -v "$(sourcesPath):/vmr" -w /vmr $customRunArgs ${{ parameters.container }} ./build.sh --clean-while-building $(additionalBuildArgs) $customBuildArgs $extraBuildProperties
|
2023-12-08 16:51:37 +00:00
|
|
|
else
|
2023-12-08 20:58:57 +00:00
|
|
|
cd $(sourcesPath)
|
2023-12-08 17:12:49 +00:00
|
|
|
./build.sh --clean-while-building $(additionalBuildArgs) $customBuildArgs $extraBuildProperties
|
2023-12-08 16:51:37 +00:00
|
|
|
fi
|
2022-12-01 09:51:39 +00:00
|
|
|
displayName: Build
|
|
|
|
|
2023-12-04 21:07:43 +00:00
|
|
|
# Don't run tests if overriding RID, we don't support that for now
|
|
|
|
- ${{ if eq(parameters.targetRid, '') }}:
|
|
|
|
- script: |
|
|
|
|
set -x
|
2022-12-01 09:51:39 +00:00
|
|
|
|
2023-12-04 21:07:43 +00:00
|
|
|
dockerVolumeArgs="-v $(sourcesPath):/vmr"
|
|
|
|
dockerEnvArgs="-e SMOKE_TESTS_EXCLUDE_OMNISHARP=${{ parameters.excludeOmniSharpTests }} -e SMOKE_TESTS_WARN_SDK_CONTENT_DIFFS=true -e SMOKE_TESTS_RUNNING_IN_CI=true"
|
|
|
|
poisonArg=''
|
2022-12-01 09:51:39 +00:00
|
|
|
|
2023-12-04 21:07:43 +00:00
|
|
|
if [[ '${{ parameters.enablePoison }}' == 'True' ]]; then
|
|
|
|
poisonArg='--poison'
|
|
|
|
fi
|
2023-07-18 18:32:26 +00:00
|
|
|
|
2023-12-04 21:07:43 +00:00
|
|
|
docker run --rm $dockerVolumeArgs -w /vmr $dockerEnvArgs ${{ parameters.container }} ./build.sh $poisonArg --run-smoke-test $(additionalBuildArgs) -- -p:SmokeTestConsoleVerbosity=detailed
|
|
|
|
displayName: Run Tests
|
2022-12-01 09:51:39 +00:00
|
|
|
|
|
|
|
# Don't use CopyFiles@2 as it encounters permissions issues because it indexes all files in the source directory graph.
|
|
|
|
- script: |
|
|
|
|
set -x
|
|
|
|
|
|
|
|
targetFolder=$(Build.StagingDirectory)/BuildLogs/
|
|
|
|
mkdir -p ${targetFolder}
|
|
|
|
|
2023-01-13 18:14:44 +00:00
|
|
|
cd "$(sourcesPath)"
|
2022-12-01 09:51:39 +00:00
|
|
|
find artifacts/ -type f -name "*.binlog" -exec cp {} --parents -t ${targetFolder} \;
|
|
|
|
find artifacts/ -type f -name "*.log" -exec cp {} --parents -t ${targetFolder} \;
|
|
|
|
find artifacts/prebuilt-report/ -exec cp {} --parents -t ${targetFolder} \;
|
|
|
|
find src/ -type f -name "*.binlog" -exec cp {} --parents -t ${targetFolder} \;
|
|
|
|
find src/ -type f -name "*.log" -exec cp {} --parents -t ${targetFolder} \;
|
|
|
|
find test/ -type f -name "*.binlog" -exec cp {} --parents -t ${targetFolder} \;
|
|
|
|
find test/ -type f -name "Updated*.diff" -exec cp {} --parents -t ${targetFolder} \;
|
|
|
|
find test/ -type f -name "Updated*.txt" -exec cp {} --parents -t ${targetFolder} \;
|
|
|
|
displayName: Prepare BuildLogs staging directory
|
|
|
|
continueOnError: true
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
|
|
|
|
- publish: '$(Build.StagingDirectory)/BuildLogs'
|
|
|
|
artifact: $(Agent.JobName)_BuildLogs_Attempt$(System.JobAttempt)
|
|
|
|
displayName: Publish BuildLogs
|
|
|
|
continueOnError: true
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
|
|
|
|
- task: PublishTestResults@2
|
|
|
|
displayName: Publish Test Results
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
continueOnError: true
|
|
|
|
inputs:
|
|
|
|
testRunner: vSTest
|
|
|
|
testResultsFiles: 'test/**/*.trx'
|
2023-01-13 18:14:44 +00:00
|
|
|
searchFolder: ${{ variables.sourcesPath }}
|
2022-12-01 09:51:39 +00:00
|
|
|
mergeTestResults: true
|
|
|
|
publishRunAttachments: true
|
|
|
|
testRunTitle: SourceBuild_SmokeTests_$(Agent.JobName)
|
|
|
|
|
2023-01-13 18:14:44 +00:00
|
|
|
- publish: '${{ variables.sourcesPath }}/artifacts/${{ parameters.architecture }}/Release/'
|
2022-12-01 09:51:39 +00:00
|
|
|
artifact: $(Agent.JobName)_Artifacts
|
|
|
|
displayName: Publish Artifacts
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
continueOnError: true
|