Skip to content

Commit

Permalink
Merge pull request #75 from KKoukiou/run-anaconda-master-fixup
Browse files Browse the repository at this point in the history
tests: clean up logic for repositories in various test scenarios
  • Loading branch information
KKoukiou authored Dec 5, 2023
2 parents 418391c + 22bee6e commit 727f3c3
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 87 deletions.
84 changes: 0 additions & 84 deletions test/build-rpms

This file was deleted.

5 changes: 2 additions & 3 deletions test/prepare-updates-img
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ set -eu

TEST_RPMS="${TEST_RPMS:-""}"

# build the anaconda-webui rpm && download anaconda-webui missing dependencies
make srpm
test/build-rpms -v anaconda-webui*.src.rpm
# Prepare tmp/rpms folder with anaconda-webui missing dependencies
test/vm.install -v

# Copy the extra RPMs to the /tmp/rpms directory
for i in ${TEST_RPMS//,/ }; do
Expand Down
99 changes: 99 additions & 0 deletions test/vm.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env python3

# derived from test/image-prepare in cockpit-project/cockpit

import argparse
import glob
import os
import shutil
import subprocess
import sys

BOTS_DIR = os.path.realpath(f'{__file__}/../../bots')
sys.path.append(BOTS_DIR)

missing_packages = "cockpit-ws cockpit-bridge cockpit-storaged fedora-logos"
# Install missing firefox dependencies.
# Resolving all dependencies with dnf download is possible,
# but it packs to many packages to updates.img
missing_packages_incl_deps = "firefox"

from machine.machine_core import machine_virtual # NOQA: imported through parent.py


def vm_install(image, verbose, quick):
subprocess.check_call([os.path.join(BOTS_DIR, "image-download"), image])
machine = machine_virtual.VirtMachine(image=image)
packages_to_download = missing_packages + " anaconda-core";
try:
machine.start()
machine.wait_boot()

scenario = os.environ.get("TEST_SCENARIO")
# Pull cockpit dependencies from the image default compose
# unless we are testing a PR on cockpit-project/cockpit, then pull it from the PR COPR repo
if scenario and scenario.startswith("cockpit-pr-"):
cockpit_pr = scenario.split("-")[-1]
machine.execute(f"dnf copr enable -y packit/cockpit-project-cockpit-{cockpit_pr}", stdout=sys.stdout)

# Build anaconda-webui from SRPM unless we are testing a anaconda-webui PR scenario
# from a different repo, then pull it from the anaconda-webui PR COPR repo
if not scenario or not scenario.startswith("anaconda-webui-pr-"):
subprocess.run(["rm", "anaconda-webui-*.rpm anaconda-webui-*.tar.xz"])
subprocess.run(["make", "srpm"])
srpm = glob.glob("anaconda-webui*.src.rpm")[0]
machine.execute("su builder -c 'mkdir -p /var/tmp/build/SRPMS'")
vm_srpm = os.path.join("/var/tmp/build/SRPMS", os.path.basename(srpm))
machine.upload([os.path.realpath(srpm)], vm_srpm)

# build rpms
mock_opts = ("--verbose" if verbose else "") + (" --nocheck" if quick else "")
machine.execute("su builder -c 'mock --no-clean --disablerepo=* --offline --resultdir /var/tmp/build "
f"{mock_opts} --rebuild /var/tmp/build/SRPMS/*.src.rpm'", timeout=1800)
else:
anaconda_webui_pr = scenario.split("-")[-1]
machine.execute(f"dnf copr enable -y packit/rhinstaller-anaconda-webui-{anaconda_webui_pr}", stdout=sys.stdout)
packages_to_download += f" anaconda-webui"

# Pull anaconda-core from the COPR repo packit builds from master branch
# unless we are testing a PR on rhinstaller/anaconda, then pull it from the PR COPR repo
if not scenario or not scenario.startswith("anaconda-pr-"):
machine.execute(f"dnf copr enable -y @rhinstaller/Anaconda ", stdout=sys.stdout)
else:
anaconda_pr = scenario.split("-")[-1]
machine.execute(f"dnf copr enable -y packit/rhinstaller-anaconda-{anaconda_pr}", stdout=sys.stdout)

# Download missing dependencies rpms
# FIXME boot.iso on rawhide does not currently contain the new anaconda-webui dependencies
# This will change once we include this changes upstream and start building boot.iso with the new dependencies
# Then we can enable this only for the various scenarios above
machine.execute(f"dnf download --destdir /var/tmp/build/ {packages_to_download}", stdout=sys.stdout, timeout=300)
machine.execute(f"dnf download --resolve --destdir /var/tmp/build/ {missing_packages_incl_deps}", stdout=sys.stdout, timeout=300)

# download rpms
vm_rpms = machine.execute("find /var/tmp/build -name '*.rpm' -not -name '*.src.rpm'").strip().split()

destdir = os.path.abspath("tmp/rpms")
if os.path.exists(destdir):
shutil.rmtree(destdir)
os.makedirs(destdir)

rpms = []
for rpm in vm_rpms:
machine.download(rpm, destdir)
rpms.append(os.path.join(destdir, os.path.basename(rpm)))
return rpms
finally:
machine.stop()


def main():
parser = argparse.ArgumentParser()
parser.add_argument('--quick', '-q', action='store_true')
parser.add_argument('--verbose', '-v', action='store_true')
parser.add_argument('--image', default='fedora-rawhide')
args = parser.parse_args()

vm_install(args.image, args.verbose, args.quick)

main()

0 comments on commit 727f3c3

Please sign in to comment.