[AUTO-CHERRYPICK] Adding support for multiple cache inputs - branch main (#7464)

Co-authored-by: Pawel Winogrodzki <pawelwi@microsoft.com>
This commit is contained in:
CBL-Mariner-Bot 2024-01-25 09:45:37 -08:00 коммит произвёл GitHub
Родитель 6e7be29036
Коммит 29b467577a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 50 добавлений и 28 удалений

Просмотреть файл

@ -30,6 +30,13 @@ parameters:
type: boolean type: boolean
default: true default: true
- name: inputCacheArtifacts
type: object
default: []
# Sample:
# - name: build-artifacts
# rpmsTarball: cache.tar.gz
- name: isCheckBuild - name: isCheckBuild
type: string type: string
default: "default" default: "default"
@ -86,6 +93,18 @@ parameters:
type: string type: string
default: "" default: ""
- name: outputRPMsCacheTarballName
type: string
default: ""
- name: outputRPMsTarballName
type: string
default: "rpms.tar.gz"
- name: outputSRPMsTarballName
type: string
default: "srpms.tar.gz"
- name: pipArtifactFeeds - name: pipArtifactFeeds
type: string type: string
default: "" default: ""
@ -94,18 +113,6 @@ parameters:
type: boolean type: boolean
default: true default: true
- name: rpmsCacheArtifactName
type: string
default: ""
- name: rpmsCacheTarballName
type: string
default: "rpms.tar.gz"
- name: rpmsTarballName
type: string
default: "rpms.tar.gz"
- name: selfRepoName - name: selfRepoName
type: string type: string
default: "CBL-Mariner" default: "CBL-Mariner"
@ -118,10 +125,6 @@ parameters:
type: string type: string
default: "" default: ""
- name: srpmsTarballName
type: string
default: "srpms.tar.gz"
- name: testSuiteName - name: testSuiteName
type: string type: string
default: "Package test" default: "Package test"
@ -155,22 +158,22 @@ steps:
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" toolchain TOOLCHAIN_ARCHIVE="$toolchain_archive" sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" toolchain TOOLCHAIN_ARCHIVE="$toolchain_archive"
displayName: "Populate toolchain" displayName: "Populate toolchain"
- ${{ if parameters.rpmsCacheArtifactName }}: - ${{ each inputCacheArtifact in parameters.inputCacheArtifacts }}:
- task: DownloadPipelineArtifact@2 - task: DownloadPipelineArtifact@2
displayName: "Download RPM cache" displayName: "Download input cache RPM from ${{ inputCacheArtifact.name }}"
inputs: inputs:
artifact: "${{ parameters.rpmsCacheArtifactName }}" artifact: "${{ inputCacheArtifact.name }}"
patterns: "**/${{ parameters.rpmsCacheTarballName }}" patterns: "**/${{ inputCacheArtifact.rpmsTarball }}"
- script: | - script: |
rpms_archive="$(find "$(Pipeline.Workspace)" -name "${{ parameters.rpmsCacheTarballName }}" -print -quit)" rpms_archive="$(find "$(Pipeline.Workspace)" -name "${{ inputCacheArtifact.rpmsTarball }}" -print -quit)"
if [[ ! -f "$rpms_archive" ]]; then if [[ ! -f "$rpms_archive" ]]; then
echo "ERROR: RPMs cache archive not found!" >&2 echo "ERROR: cache RPMs archive '${{ inputCacheArtifact.rpmsTarball }}' not found!" >&2
exit 1 exit 1
fi fi
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" hydrate-cached-rpms CACHED_PACKAGES_ARCHIVE="$rpms_archive" sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" hydrate-cached-rpms CACHED_PACKAGES_ARCHIVE="$rpms_archive"
displayName: "Populate RPMs cache" displayName: "Populate cache RPMs"
- script: | - script: |
if [[ ${{ parameters.isDeltaBuild }} == "true" ]]; then if [[ ${{ parameters.isDeltaBuild }} == "true" ]]; then
@ -219,7 +222,18 @@ steps:
displayName: "Build packages" displayName: "Build packages"
- ${{ if parameters.outputArtifactsFolder }}: - ${{ if parameters.outputArtifactsFolder }}:
- ${{ if parameters.rpmsTarballName }}: - ${{ 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: | - script: |
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" compress-rpms sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" compress-rpms
displayName: "Compress RPMs" displayName: "Compress RPMs"
@ -227,10 +241,10 @@ steps:
- bash: | - bash: |
published_artifacts_dir="${{ parameters.outputArtifactsFolder }}/${{ parameters.outputArtifactsPackagesSubfolder }}" published_artifacts_dir="${{ parameters.outputArtifactsFolder }}/${{ parameters.outputArtifactsPackagesSubfolder }}"
mkdir -p "$published_artifacts_dir" mkdir -p "$published_artifacts_dir"
cp "${{ parameters.buildRepoRoot }}"/out/rpms.tar.gz "$published_artifacts_dir/${{ parameters.rpmsTarballName }}" cp "${{ parameters.buildRepoRoot }}"/out/rpms.tar.gz "$published_artifacts_dir/${{ parameters.outputRPMsTarballName }}"
displayName: "Copy RPMs for publishing" displayName: "Copy RPMs for publishing"
- ${{ if parameters.srpmsTarballName }}: - ${{ if parameters.outputSRPMsTarballName }}:
- script: | - script: |
sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" compress-srpms sudo make -C "${{ parameters.buildRepoRoot }}/toolkit" compress-srpms
displayName: "Compress SRPMs" displayName: "Compress SRPMs"
@ -238,7 +252,7 @@ steps:
- bash: | - bash: |
published_artifacts_dir="${{ parameters.outputArtifactsFolder }}/${{ parameters.outputArtifactsPackagesSubfolder }}" published_artifacts_dir="${{ parameters.outputArtifactsFolder }}/${{ parameters.outputArtifactsPackagesSubfolder }}"
mkdir -p "$published_artifacts_dir" mkdir -p "$published_artifacts_dir"
cp "${{ parameters.buildRepoRoot }}"/out/srpms.tar.gz "$published_artifacts_dir/${{ parameters.srpmsTarballName }}" cp "${{ parameters.buildRepoRoot }}"/out/srpms.tar.gz "$published_artifacts_dir/${{ parameters.outputSRPMsTarballName }}"
displayName: "Copy SRPMs for publishing" displayName: "Copy SRPMs for publishing"
- ${{ if parameters.publishLogs }}: - ${{ if parameters.publishLogs }}:

Просмотреть файл

@ -233,6 +233,7 @@ $(preprocessed_file): $(cached_file) $(go-graphPreprocessor)
######## PACKAGE BUILD ######## ######## PACKAGE BUILD ########
cache_archive = $(OUT_DIR)/cache.tar.gz
pkggen_archive = $(OUT_DIR)/rpms.tar.gz pkggen_archive = $(OUT_DIR)/rpms.tar.gz
srpms_archive = $(OUT_DIR)/srpms.tar.gz srpms_archive = $(OUT_DIR)/srpms.tar.gz
@ -326,6 +327,10 @@ compress-rpms:
tar -cvp -f $(BUILD_DIR)/temp_rpms_tarball.tar.gz -C $(RPMS_DIR)/.. $(notdir $(RPMS_DIR)) tar -cvp -f $(BUILD_DIR)/temp_rpms_tarball.tar.gz -C $(RPMS_DIR)/.. $(notdir $(RPMS_DIR))
mv $(BUILD_DIR)/temp_rpms_tarball.tar.gz $(pkggen_archive) mv $(BUILD_DIR)/temp_rpms_tarball.tar.gz $(pkggen_archive)
##help:target:compress-cached-rpms=Compresses all cached RPMs in `build/rpm_cache/cache` into `out/cache.tar.gz`.
compress-cached-rpms:
tar -cvp -f $(cache_archive) -C $(remote_rpms_cache_dir)/.. $(notdir $(remote_rpms_cache_dir))
##help:target:compress-srpms=Compresses all SRPMs in `../out/SRPMS` into `../out/srpms.tar.gz`. ##help:target:compress-srpms=Compresses all SRPMs in `../out/SRPMS` into `../out/srpms.tar.gz`.
# use temp tarball to avoid tar warning "file changed as we read it" # use temp tarball to avoid tar warning "file changed as we read it"
# that can sporadically occur when tarball is the dir that is compressed # that can sporadically occur when tarball is the dir that is compressed
@ -333,7 +338,10 @@ compress-srpms:
tar -cvp -f $(BUILD_DIR)/temp_srpms_tarball.tar.gz -C $(SRPMS_DIR)/.. $(notdir $(SRPMS_DIR)) tar -cvp -f $(BUILD_DIR)/temp_srpms_tarball.tar.gz -C $(SRPMS_DIR)/.. $(notdir $(SRPMS_DIR))
mv $(BUILD_DIR)/temp_srpms_tarball.tar.gz $(srpms_archive) mv $(BUILD_DIR)/temp_srpms_tarball.tar.gz $(srpms_archive)
# Seed the cached RPMs folder files from the archive. ##help:target:hydrate-cached-rpms=Hydrates the external RPMs cache from the `CACHED_PACKAGES_ARCHIVE` file.
# All of the '*.rpm' files inside the archive will be extracted into the cache directory in flat manner.
# Any duplicates inside the archive's subdirectories will be overwritten by the last one.
# Also see the `compress-cached-rpms` target.
hydrate-cached-rpms: hydrate-cached-rpms:
$(if $(CACHED_PACKAGES_ARCHIVE),,$(error Must set CACHED_PACKAGES_ARCHIVE=<path>)) $(if $(CACHED_PACKAGES_ARCHIVE),,$(error Must set CACHED_PACKAGES_ARCHIVE=<path>))
@mkdir -p $(remote_rpms_cache_dir) @mkdir -p $(remote_rpms_cache_dir)