CBL-Mariner/.pipelines/templates/PackageBuild.yml

314 строки
10 KiB
YAML

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
parameters:
- name: buildRepoRoot
type: string
default: "$(Build.SourcesDirectory)"
- name: checkBuildRetries
type: string
default: ""
- name: concurrentPackageBuilds
type: number
default: 12
- name: customToolchainArtifactName
type: string
default: ""
- name: customToolchainTarballName
type: string
default: "toolchain_built_rpms_all.tar.gz"
- name: extraPackageRepos
type: string
default: ""
- name: failOnTestFailures
type: boolean
default: true
- name: inputCacheArtifacts
type: object
default: []
# Sample:
# - name: build-artifacts
# rpmsTarball: cache.tar.gz
- name: isAllowToolchainRebuilds
type: string
default: "default"
values:
- "default"
- "false"
- "true"
- name: isCheckBuild
type: string
default: "default"
values:
- "default"
- "false"
- "true"
- name: isDeltaBuild
type: string
default: "default"
values:
- "default"
- "false"
- "true"
- name: isQuickRebuildPackages
type: string
default: "default"
values:
- "default"
- "false"
- "true"
- name: isUseCCache
type: string
default: "default"
values:
- "default"
- "false"
- "true"
- name: maxCascadingRebuilds
type: string
default: ""
- name: outputArtifactsFolder
type: string
default: "$(Build.ArtifactStagingDirectory)"
- name: outputArtifactsLogsSubfolder
type: string
default: "LOGS"
- name: outputArtifactsPackagesSubfolder
type: string
default: "ARTIFACTS"
- name: outputArtifactsTestsSubfolder
type: string
default: "TESTS"
- name: maxCPU
type: string
default: ""
- name: outputRPMsCacheTarballName
type: string
default: ""
- name: outputRPMsTarballName
type: string
default: "rpms.tar.gz"
- name: outputSRPMsTarballName
type: string
default: "srpms.tar.gz"
- name: packageBuildList
type: string
default: ""
- name: packageRebuildList
type: string
default: ""
- name: pipArtifactFeeds
type: string
default: ""
- name: publishLogs
type: boolean
default: true
- name: selfRepoName
type: string
default: "CBL-Mariner"
- name: specsFolderPath
type: string
default: "SPECS"
- name: srpmPackList
type: string
default: ""
- name: testRerunList
type: string
default: ""
- name: testSuiteName
type: string
default: "Package test"
steps:
- template: ToolkitCheck.yml@${{ parameters.selfRepoName }}
parameters:
buildRepoRoot: ${{ parameters.buildRepoRoot }}
- ${{ if parameters.pipArtifactFeeds }}:
- task: PipAuthenticate@1
inputs:
artifactFeeds: "${{ parameters.pipArtifactFeeds }}"
displayName: "Authenticate to custom pip artifact feeds"
- ${{ if parameters.customToolchainArtifactName }}:
- task: DownloadPipelineArtifact@2
displayName: "Download toolchain"
inputs:
artifact: "${{ parameters.customToolchainArtifactName }}"
patterns: "**/${{ parameters.customToolchainTarballName }}"
- script: |
toolchain_archive="$(find "$(Pipeline.Workspace)" -name "${{ parameters.customToolchainTarballName }}" -print -quit)"
if [[ ! -f "$toolchain_archive" ]]; then
echo "ERROR: toolchain archive not found!" >&2
exit 1
fi
echo "##vso[task.setvariable variable=toolchainArchive]$toolchain_archive"
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" toolchain TOOLCHAIN_ARCHIVE="$toolchain_archive"
displayName: "Populate toolchain"
- ${{ each inputCacheArtifact in parameters.inputCacheArtifacts }}:
- task: DownloadPipelineArtifact@2
displayName: "Download input cache RPM from ${{ inputCacheArtifact.name }}"
inputs:
artifact: "${{ inputCacheArtifact.name }}"
patterns: "**/${{ inputCacheArtifact.rpmsTarball }}"
- script: |
rpms_archive="$(find "$(Pipeline.Workspace)" -name "${{ inputCacheArtifact.rpmsTarball }}" -print -quit)"
if [[ ! -f "$rpms_archive" ]]; then
echo "ERROR: cache RPMs archive '${{ inputCacheArtifact.rpmsTarball }}' not found!" >&2
exit 1
fi
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" hydrate-cached-rpms CACHED_PACKAGES_ARCHIVE="$rpms_archive"
displayName: "Populate cache RPMs"
- script: |
if [[ -n "${{ parameters.checkBuildRetries }}" ]]; then
check_build_retries_arg="CHECK_BUILD_RETRIES=${{ parameters.checkBuildRetries }}"
fi
if [[ -n "${{ parameters.customToolchainArtifactName }}" ]]; then
toolchain_archive_arg="TOOLCHAIN_ARCHIVE=$(toolchainArchive)"
fi
if [[ ${{ parameters.isAllowToolchainRebuilds }} == "true" ]]; then
allow_toolchain_rebuilds_arg="ALLOW_TOOLCHAIN_REBUILDS=y"
elif [[ ${{ parameters.isAllowToolchainRebuilds }} == "false" ]]; then
allow_toolchain_rebuilds_arg="ALLOW_TOOLCHAIN_REBUILDS=n"
fi
if [[ ${{ parameters.isCheckBuild }} == "true" ]]; then
run_check_arg="RUN_CHECK=y"
elif [[ ${{ parameters.isCheckBuild }} == "false" ]]; then
run_check_arg="RUN_CHECK=n"
fi
if [[ ${{ parameters.isDeltaBuild }} == "true" ]]; then
delta_fetch_arg="DELTA_FETCH=y"
elif [[ ${{ parameters.isDeltaBuild }} == "false" ]]; then
delta_fetch_arg="DELTA_FETCH=n"
fi
if [[ ${{ parameters.isQuickRebuildPackages }} == "true" ]]; then
quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=y"
elif [[ ${{ parameters.isQuickRebuildPackages }} == "false" ]]; then
quick_rebuild_packages_arg="QUICK_REBUILD_PACKAGES=n"
fi
if [[ ${{ parameters.isUseCCache }} == "true" ]]; then
use_ccache_arg="USE_CCACHE=y"
elif [[ ${{ parameters.isUseCCache }} == "false" ]]; then
use_ccache_arg="USE_CCACHE=n"
fi
if [[ -n "${{ parameters.maxCascadingRebuilds }}" ]]; then
max_cascading_rebuilds_arg="MAX_CASCADING_REBUILDS=${{ parameters.maxCascadingRebuilds }}"
fi
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" build-packages -j$(nproc) \
CONCURRENT_PACKAGE_BUILDS=${{ parameters.concurrentPackageBuilds }} \
CONFIG_FILE="" \
MAX_CPU="${{ parameters.maxCPU }}" \
PACKAGE_BUILD_LIST="${{ parameters.packageBuildList }}" \
PACKAGE_REBUILD_LIST="${{ parameters.packageRebuildList }}" \
REBUILD_TOOLS=y \
REPO_LIST="${{ parameters.extraPackageRepos }}" \
SPECS_DIR="${{ parameters.buildRepoRoot }}/${{ parameters.specsFolderPath }}" \
SRPM_PACK_LIST="${{ parameters.srpmPackList }}" \
TEST_RERUN_LIST="${{ parameters.testRerunList }}" \
$allow_toolchain_rebuilds_arg \
$check_build_retries_arg \
$delta_fetch_arg \
$max_cascading_rebuilds_arg \
$quick_rebuild_packages_arg \
$run_check_arg \
$toolchain_archive_arg \
$use_ccache_arg
displayName: "Build packages"
- ${{ if parameters.outputArtifactsFolder }}:
- ${{ if parameters.outputRPMsCacheTarballName }}:
- script: |
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" compress-cached-rpms
displayName: "Compress cached RPMs"
- bash: |
published_artifacts_dir="${{ parameters.outputArtifactsFolder }}/${{ parameters.outputArtifactsPackagesSubfolder }}"
mkdir -p "$published_artifacts_dir"
cp "${{ parameters.buildRepoRoot }}"/out/cache.tar.gz "$published_artifacts_dir/${{ parameters.outputRPMsCacheTarballName }}"
displayName: "Copy cached RPMs for publishing"
- ${{ if parameters.outputRPMsTarballName }}:
- script: |
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" compress-rpms
displayName: "Compress RPMs"
- bash: |
published_artifacts_dir="${{ parameters.outputArtifactsFolder }}/${{ parameters.outputArtifactsPackagesSubfolder }}"
mkdir -p "$published_artifacts_dir"
cp "${{ parameters.buildRepoRoot }}"/out/rpms.tar.gz "$published_artifacts_dir/${{ parameters.outputRPMsTarballName }}"
displayName: "Copy RPMs for publishing"
- ${{ if parameters.outputSRPMsTarballName }}:
- script: |
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" compress-srpms
displayName: "Compress SRPMs"
- bash: |
published_artifacts_dir="${{ parameters.outputArtifactsFolder }}/${{ parameters.outputArtifactsPackagesSubfolder }}"
mkdir -p "$published_artifacts_dir"
cp "${{ parameters.buildRepoRoot }}"/out/srpms.tar.gz "$published_artifacts_dir/${{ parameters.outputSRPMsTarballName }}"
displayName: "Copy SRPMs for publishing"
- ${{ if parameters.publishLogs }}:
- bash: |
published_logs_dir="${{ parameters.outputArtifactsFolder }}/${{ parameters.outputArtifactsLogsSubfolder }}"
mkdir -p "$published_logs_dir"
tar -C "${{ parameters.buildRepoRoot }}/build/logs/pkggen" -czf "$published_logs_dir/pkggen.logs.tar.gz" .
tar -C "${{ parameters.buildRepoRoot }}/build/pkg_artifacts" -czf "$published_logs_dir/pkg_artifacts.tar.gz" .
tar -C "${{ parameters.buildRepoRoot }}/build/timestamp" -czf "$published_logs_dir/timestamp.tar.gz" .
condition: always()
displayName: "Copy logs for publishing"
- ${{ if parameters.isCheckBuild }}:
- template: PackageTestResultsAnalysis.yml@${{ parameters.selfRepoName }}
parameters:
buildRepoRoot: ${{ parameters.buildRepoRoot }}
failOnTestFailures: ${{ parameters.failOnTestFailures }}
outputArtifactsFolder: ${{ parameters.outputArtifactsFolder }}
outputArtifactsTestsSubfolder: ${{ parameters.outputArtifactsTestsSubfolder }}
testSuiteName: ${{ parameters.testSuiteName }}