Skip to content

Commit a60e5f6

Browse files
mcattamoredhatkgiusti
authored andcommitted
ci: support testing from brew builds
Add support for installing go-fdo-client/go-fdo-server RPMs from an internal brew build in test/rpm and test/bootc, in addition to the existing COPR/Packit/local-build paths. Set BREW_CLIENT_RPMS_URL / BREW_SERVER_RPMS_URL to a build's version/release directory in brew to install the client/server RPMs straight from an internal brew server. Self-signed certs and unsigned builds are expected on internal brew servers, so --nogpgcheck --setopt=sslverify=false is used intentionally. rpms_from_brew_url() (test/ci/utils.sh) lists the RPM URLs actually published under a brew build's ${arch}/ and noarch/ directories, rather than hardcoding each sub-package's name, so it doesn't need to be kept in sync whenever brew's package layout changes. test/bootc also recognizes rhel-10* as a base image (overridable via BOOTC_BASE_IMAGE) and generates a RHEL nightly-compose repo file at runtime when DOWNLOAD_NODE is set, so the container build can reach RHEL packages while installing go-fdo-client. Assisted-by: Claude (claude-sonnet-5) Signed-off-by: Mario Cattamo <mcattamo@redhat.com>
1 parent 434b1ba commit a60e5f6

3 files changed

Lines changed: 126 additions & 22 deletions

File tree

test/bootc/utils.sh

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,78 @@ case "${ID}-${VERSION_ID}" in
3131
base_image_url="quay.io/centos-bootc/centos-bootc:stream${VERSION_ID}"
3232
boot_args="uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no"
3333
;;
34+
rhel-10*)
35+
os_variant="rhel10-unknown"
36+
base_image_url="${BOOTC_BASE_IMAGE:-registry.redhat.io/rhel10/rhel-bootc:${VERSION_ID}}"
37+
boot_args="uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no"
38+
;;
3439
*)
3540
log_error "Unsupported distro: ${ID}-${VERSION_ID}"
3641
exit 1
3742
;;
3843
esac
3944

4045
build_bootc_container() {
41-
tee Containerfile >/dev/null <<EOF
46+
# For any RHEL host, generate a repo file pointing at the nightly compose so
47+
# that the built container image has enabled repos. This is unrelated to
48+
# installing go-fdo-client (which never needs repos, whichever path below is
49+
# taken) -- it's needed downstream by generate_iso_from_bootc(), since
50+
# bootc-image-builder depsolves additional packages (kernel, anaconda, etc.)
51+
# from repos baked into the image itself, and unregistered/unentitled RHEL
52+
# bootc base images otherwise ship with no enabled repos. The file is
53+
# generated at runtime (rather than kept as a static template) so it works
54+
# for any RHEL minor version (10.2, 10.3, ...) without code changes.
55+
local rhel_repo_file=""
56+
if [[ "${ID}" == "rhel" ]] && [ -n "${DOWNLOAD_NODE:-}" ]; then
57+
local major_ver="${VERSION_ID%%.*}" # e.g. "10" from "10.2"
58+
rhel_repo_file="files/rhel-${VERSION_ID}.repo"
59+
mkdir -p files
60+
cat > "${rhel_repo_file}" << EOF
61+
[RHEL-${VERSION_ID}-NIGHTLY-BaseOS]
62+
name=baseos
63+
baseurl=http://${DOWNLOAD_NODE}/rhel-${major_ver}/nightly/RHEL-${major_ver}/latest-RHEL-${VERSION_ID}/compose/BaseOS/\$basearch/os
64+
enabled=1
65+
# Nightly compose builds are not GPG-signed; gpgcheck=0 is intentional.
66+
gpgcheck=0
67+
sslverify=0
68+
[RHEL-${VERSION_ID}-NIGHTLY-AppStream]
69+
name=appstream
70+
baseurl=http://${DOWNLOAD_NODE}/rhel-${major_ver}/nightly/RHEL-${major_ver}/latest-RHEL-${VERSION_ID}/compose/AppStream/\$basearch/os
71+
enabled=1
72+
# Nightly compose builds are not GPG-signed; gpgcheck=0 is intentional.
73+
gpgcheck=0
74+
sslverify=0
75+
EOF
76+
fi
77+
78+
if [ -n "${BREW_CLIENT_RPMS_URL:-}" ]; then
79+
# Install go-fdo-client from a specific brew build base path.
80+
# BREW_CLIENT_RPMS_URL should point to the version/release directory of the package in brew.
81+
# e.g.: https://${BREW_HOST}/${BREW_PACKAGES_DIR}/go-fdo-client/1.0.0/4.el10_2.5
82+
tee Containerfile >/dev/null <<EOF
83+
FROM ${base_image_url}
84+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
85+
# use self-signed certificates and builds may not be GPG-signed.
86+
RUN dnf install -y --nogpgcheck --setopt=sslverify=false $(rpms_from_brew_url "${BREW_CLIENT_RPMS_URL}" | tr '\n' ' ')
87+
EOF
88+
else
89+
tee Containerfile >/dev/null <<EOF
4290
FROM ${base_image_url}
4391
RUN dnf=\$(readlink \$(command -v dnf)); [ "\${dnf}" = "dnf5" ] || dnf=dnf ; \
4492
rpm -q --whatprovides \${dnf}'-command(copr)' &> /dev/null || \${dnf} install -y \${dnf}'-command(copr)'; \
4593
\${dnf} copr enable -y '@fedora-iot/fedora-iot'; \
4694
\${dnf} install -y go-fdo-client; \
4795
\${dnf} copr disable -y @fedora-iot/fedora-iot
4896
EOF
97+
fi
98+
99+
# Append the RHEL repo file into the container image when it was generated.
100+
if [ -n "${rhel_repo_file}" ]; then
101+
tee -a Containerfile >/dev/null << EOF
102+
COPY ${rhel_repo_file} /etc/yum.repos.d/rhel-${VERSION_ID}.repo
103+
EOF
104+
fi
105+
49106
podman build --retry=5 --retry-delay=10s -t "fdo-bootc:latest" -f Containerfile .
50107
}
51108

@@ -99,19 +156,28 @@ echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/admin' "${new_ks_file}"
99156
}
100157

101158
install_server() {
102-
if [ ! -v "PACKIT_COPR_RPMS" ]; then
159+
if [ -v "PACKIT_COPR_RPMS" ]; then
160+
echo " - Expected RPMs: ${PACKIT_COPR_RPMS}"
161+
elif [ -n "${BREW_SERVER_RPMS_URL:-}" ]; then
162+
# Install from a specific brew build base path.
163+
# BREW_SERVER_RPMS_URL should point to the version/release directory of the package in brew.
164+
# e.g.: https://${BREW_HOST}/${BREW_PACKAGES_DIR}/go-fdo-server/1.0.1/2.el10_2.3
165+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
166+
# use self-signed certificates and builds may not be GPG-signed.
167+
sudo dnf install -y --nogpgcheck --setopt=sslverify=false $(rpms_from_brew_url "${BREW_SERVER_RPMS_URL}")
168+
else
103169
sudo dnf install -y golang make
104170
commit="$(git rev-parse --short HEAD)"
105171
rpm -q go-fdo-server | grep -q "go-fdo-server.*git${commit}.*" || {
106172
make rpm
107173
sudo dnf install -y rpmbuild/rpms/{noarch,"$(uname -m)"}/*git"${commit}"*.rpm
108174
}
109-
else
110-
echo " - Expected RPMs: ${PACKIT_COPR_RPMS}"
111175
fi
112-
# Make sure the RPMS are installed
113-
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " go-fdo-server{,-{manufacturer,owner,rendezvous}})
114-
echo " - Installed RPMs: ${installed_rpms}"
176+
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " ${go_fdo_server_rpms})
177+
log_info "Installed Server RPMs:"
178+
for i in ${installed_rpms}; do
179+
echo "$i"
180+
done
115181
}
116182

117183
install_client() {

test/ci/utils.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,23 @@ stop_services() {
404404
done
405405
}
406406

407+
# List the RPM package URLs published under a brew build base URL.
408+
# The URL must point to the version/release directory of the package in
409+
# brew, which contains an '${arch}/' and a 'noarch/' sub-directory listing
410+
# the built RPMs. Prints one full RPM URL per line, e.g.:
411+
# SOME_RPM_URL=https://${BREW_HOST}/${BREW_PACKAGES_DIR}/${BREW_PACKAGE_NAME}/${BREW_PACKAGE_VERSION}/${BREW_PACKAGE_RELEASE}
412+
# rpms_from_brew_url "${SOME_RPM_URL}"
413+
rpms_from_brew_url() {
414+
local brew_base_url="${1%/}" # strip any trailing slash to avoid double slashes below
415+
local arch
416+
arch=$(uname -m | sed 's/arm64/aarch64/')
417+
# --insecure is intentional: internal brew servers use self-signed
418+
# certificates, same as the --setopt=sslverify=false used when installing
419+
# the RPMs these URLs point to.
420+
curl --fail --silent --insecure "${brew_base_url}/${arch}/" | grep rpm | sed "s|.*>\(.*\)\.rpm</.*|${brew_base_url}/${arch}/\1.rpm|"
421+
curl --fail --silent --insecure "${brew_base_url}/noarch/" | grep rpm | sed "s|.*>\(.*\)\.rpm</.*|${brew_base_url}/noarch/\1.rpm|"
422+
}
423+
407424
fetch_client_repo() {
408425
[ -d "${client_src_dir}" ] || git clone --single-branch https://github.com/fido-device-onboard/go-fdo-client "${client_src_dir}"
409426
if [ -v "CLIENT_REF" ]; then

test/rpm/utils.sh

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ configure_service_owner() {
202202
sudo chown -R ${rpm_owner_user}:${rpm_server_group} ${rpm_owner_home_dir}
203203
}
204204

205+
go_fdo_server_rpms="go-fdo-server go-fdo-server-manufacturer go-fdo-server-owner go-fdo-server-rendezvous"
206+
go_fdo_client_rpms="go-fdo-client"
207+
205208
install_from_copr() {
206209
rpm -q --whatprovides 'dnf-command(copr)' &>/dev/null || sudo dnf install -y 'dnf-command(copr)'
207210
dnf copr list | grep 'fedora-iot/fedora-iot' || sudo dnf copr enable -y @fedora-iot/fedora-iot
@@ -212,9 +215,19 @@ install_from_copr() {
212215
}
213216

214217
install_client() {
215-
# If PACKIT_COPR_RPMS is not defined it means we are running the test
216-
# locally so we will install the client from the copr repo
217-
[ -v "PACKIT_COPR_RPMS" ] || rpm -q go-fdo-client &>/dev/null || install_from_copr go-fdo-client
218+
if [ -v "PACKIT_COPR_RPMS" ]; then
219+
: # pre-installed by CI
220+
elif [ -n "${BREW_CLIENT_RPMS_URL:-}" ]; then
221+
# Install from a specific brew build base path.
222+
# BREW_CLIENT_RPMS_URL should point to the version/release directory of the package in brew.
223+
# e.g.: https://${BREW_HOST}/${BREW_PACKAGES_DIR}/go-fdo-client/1.0.0/4.el10_2.5
224+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
225+
# use self-signed certificates and builds may not be GPG-signed.
226+
sudo dnf install -y --nogpgcheck --setopt=sslverify=false $(rpms_from_brew_url "${BREW_CLIENT_RPMS_URL}")
227+
else
228+
# If running locally install the client from the COPR repo
229+
rpm -q go-fdo-client &>/dev/null || install_from_copr go-fdo-client
230+
fi
218231
log_info "Installed Client RPM:"
219232
echo "$(rpm -q go-fdo-client)"
220233
}
@@ -223,8 +236,9 @@ uninstall_client() {
223236
# When running a test locally we remove the client package
224237
# after a successful execution.
225238
[ -v "PACKIT_COPR_RPMS" ] || {
226-
sudo dnf remove -y go-fdo-client
227-
sudo dnf copr remove -y @fedora-iot/fedora-iot
239+
sudo dnf remove -y ${go_fdo_client_rpms}
240+
# Only remove the COPR repo when it was used for installation
241+
[ -n "${BREW_CLIENT_RPMS_URL:-}" ] || sudo dnf copr remove -y @fedora-iot/fedora-iot
228242
}
229243
}
230244

@@ -240,30 +254,37 @@ run_go_fdo_client() {
240254
}
241255

242256
install_server() {
243-
# If PACKIT_COPR_RPMS is not defined it means we are running the test
244-
# locally so we will build and install the RPMs from the *committed* code
245-
if [ ! -v "PACKIT_COPR_RPMS" ]; then
257+
if [ -v "PACKIT_COPR_RPMS" ]; then
258+
log_info "Expected Server RPMs:"
259+
for i in ${PACKIT_COPR_RPMS}; do
260+
echo "$i"
261+
done | sort
262+
elif [ -n "${BREW_SERVER_RPMS_URL:-}" ]; then
263+
# Install from a specific brew build base path.
264+
# BREW_SERVER_RPMS_URL should point to the version/release directory of the package in brew.
265+
# e.g.: https://${BREW_HOST}/${BREW_PACKAGES_DIR}/go-fdo-server/1.0.1/2.el10_2.3
266+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
267+
# use self-signed certificates and builds may not be GPG-signed.
268+
sudo dnf install -y --nogpgcheck --setopt=sslverify=false $(rpms_from_brew_url "${BREW_SERVER_RPMS_URL}")
269+
else
270+
# If PACKIT_COPR_RPMS is not defined it means we are running the test
271+
# locally so we will build and install the RPMs from the *committed* code
246272
commit="$(git rev-parse --short HEAD)"
247273
rpm -q go-fdo-server | grep -q "go-fdo-server.*git${commit}.*" || {
248274
make rpm
249275
sudo dnf install -y rpmbuild/rpms/{noarch,"$(uname -m)"}/*git"${commit}"*.rpm
250276
}
251-
else
252-
log_info "Expected Server RPMs:"
253-
for i in ${PACKIT_COPR_RPMS}; do
254-
echo "$i"
255-
done | sort
256277
fi
257278
# Make sure the RPMS are installed
258-
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " go-fdo-server{,-{manufacturer,owner,rendezvous}})
279+
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " ${go_fdo_server_rpms})
259280
log_info "Installed Server RPMs:"
260281
for i in ${installed_rpms}; do
261282
echo "$i"
262283
done | sort
263284
}
264285

265286
uninstall_server() {
266-
[ -v "PACKIT_COPR_RPMS" ] || sudo dnf remove -y go-fdo-server{,-manufacturer,-owner,-rendezvous}
287+
[ -v "PACKIT_COPR_RPMS" ] || sudo dnf remove -y ${go_fdo_server_rpms}
267288
}
268289

269290
start_service_manufacturer() {

0 commit comments

Comments
 (0)