tests: Enable use of custom osbuild-composer repo

This enables the user to specify custom REPO_URL for use during
internal RHEL build testing as ENV in scheduled pipelines.
It also gives the option to use osbuild build specified in
Schutzfile or from the nightly build repository.
This commit is contained in:
Jakub Rusz 2021-06-16 10:24:03 +02:00 committed by Alexander Todorov
parent 905c297bc7
commit b6c579cbe3
2 changed files with 44 additions and 37 deletions

View file

@ -100,8 +100,13 @@ fi
if [ -f "rhel8internal.repo" ]; then if [ -f "rhel8internal.repo" ]; then
greenprint "Preparing repos for internal build testing" greenprint "Preparing repos for internal build testing"
sudo mv rhel8internal.repo /etc/yum.repos.d/ sudo mv rhel8internal.repo /etc/yum.repos.d/
# Change back to removing osbuild*.repo when we have rpms in 8.5 # Use osbuild from schutzfile if desired for testing custom osbuild-composer packages
sudo rm -f /etc/yum.repos.d/osbuild-composer.repo # specified by $REPO_URL in ENV and used in prepare-rhel-internal.sh
if [ "$SCHUTZ_OSBUILD" == 1 ]; then
sudo rm -f /etc/yum.repos.d/osbuild-composer.repo
else
sudo rm -f /etc/yum.repos.d/osbuild*.repo
fi
fi fi
greenprint "Installing test packages for ${PROJECT}" greenprint "Installing test packages for ${PROJECT}"

View file

@ -62,50 +62,52 @@ EOF
cp rhel-8.json rhel-8-beta.json cp rhel-8.json rhel-8-beta.json
greenprint "📦 Installing requirements"
sudo dnf -y install createrepo_c wget python3-pip
# Install s3cmd if it is not present.
if ! s3cmd --version > /dev/null 2>&1; then
greenprint "📦 Installing s3cmd"
sudo pip3 -q install s3cmd
fi
JOB_NAME="${JOB_NAME:-${CI_JOB_ID}}" JOB_NAME="${JOB_NAME:-${CI_JOB_ID}}"
REPO_DIR_LATEST="repo/${JOB_NAME}/latest/internal" # Do not create tests repo if it's provided from ENV
mkdir -p "$REPO_DIR_LATEST" if [ -z "$REPO_URL" ]; then
greenprint "📦 Installing requirements"
sudo dnf -y install createrepo_c wget python3-pip
greenprint "Discover latest osbuild-composer NVR" # Install s3cmd if it is not present.
# Download only osbuild-composer-worker-*.rpm and use it in rpm --qf below if ! s3cmd --version > /dev/null 2>&1; then
wget --quiet --recursive --no-parent --no-directories --accept "osbuild-composer-worker-*.rpm" \ greenprint "📦 Installing s3cmd"
"${COMPOSE_URL}/compose/AppStream/${ARCH}/os/Packages/" sudo pip3 -q install s3cmd
fi
# Download osbuild-composer-tests from Brew b/c it is not available in the distro REPO_DIR_LATEST="repo/${JOB_NAME}/latest/internal"
# version matches osbuild-composer from the internal tree mkdir -p "$REPO_DIR_LATEST"
greenprint "Downloading osbuild-composer-tests from Brew"
TESTS_RPM_URL=$(rpm -qp ./osbuild-composer-worker-*.rpm --qf "http://download.devel.redhat.com/brewroot/vol/rhel-8/packages/osbuild-composer/%{version}/%{release}/%{arch}/osbuild-composer-tests-%{version}-%{release}.%{arch}.rpm")
wget --directory-prefix "$REPO_DIR_LATEST" "$TESTS_RPM_URL"
greenprint "⛓ Creating dnf repository" greenprint "Discover latest osbuild-composer NVR"
createrepo_c "${REPO_DIR_LATEST}" # Download only osbuild-composer-worker-*.rpm and use it in rpm --qf below
wget --quiet --recursive --no-parent --no-directories --accept "osbuild-composer-worker-*.rpm" \
"${COMPOSE_URL}/compose/AppStream/${ARCH}/os/Packages/"
# Bucket in S3 where our artifacts are uploaded # Download osbuild-composer-tests from Brew b/c it is not available in the distro
REPO_BUCKET=osbuild-composer-repos # version matches osbuild-composer from the internal tree
greenprint "Downloading osbuild-composer-tests from Brew"
TESTS_RPM_URL=$(rpm -qp ./osbuild-composer-worker-*.rpm --qf "http://download.devel.redhat.com/brewroot/vol/rhel-8/packages/osbuild-composer/%{version}/%{release}/%{arch}/osbuild-composer-tests-%{version}-%{release}.%{arch}.rpm")
wget --directory-prefix "$REPO_DIR_LATEST" "$TESTS_RPM_URL"
# Remove the previous latest repo for this job. greenprint "⛓ Creating dnf repository"
# Don't fail if the path is missing. createrepo_c "${REPO_DIR_LATEST}"
s3cmd --recursive rm "s3://${REPO_BUCKET}/${REPO_DIR_LATEST}" || true
# Upload repository to S3. # Bucket in S3 where our artifacts are uploaded
greenprint "☁ Uploading RPMs to S3" REPO_BUCKET=osbuild-composer-repos
s3cmd --acl-public sync . s3://${REPO_BUCKET}/
# Public URL for the S3 bucket with our artifacts. # Remove the previous latest repo for this job.
MOCK_REPO_BASE_URL="http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com" # Don't fail if the path is missing.
s3cmd --recursive rm "s3://${REPO_BUCKET}/${REPO_DIR_LATEST}" || true
# Full URL to the RPM repository after they are uploaded. # Upload repository to S3.
REPO_URL=${MOCK_REPO_BASE_URL}/${REPO_DIR_LATEST} greenprint "☁ Uploading RPMs to S3"
s3cmd --acl-public sync . s3://${REPO_BUCKET}/
# Public URL for the S3 bucket with our artifacts.
MOCK_REPO_BASE_URL="http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com"
# Full URL to the RPM repository after they are uploaded.
REPO_URL=${MOCK_REPO_BASE_URL}/${REPO_DIR_LATEST}
fi
# amend repository file. # amend repository file.
greenprint "📜 Amend dnf repository file" greenprint "📜 Amend dnf repository file"