From 0450e061d0c489b0d03c62a37c9912a088c83354 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sun, 27 Oct 2024 14:29:26 -0400 Subject: [PATCH] packit: add actions for RPM tests - build rpm - install rpm - execute setup Signed-off-by: Douglas Schilling Landgraf --- .packit.sh | 0 .packit.yaml | 13 +++++++++++-- Makefile | 24 +++++++++++++---------- rpm/.gitignore | 2 +- rpm/qm.spec | 3 ++- tests/setup-test/.gitignore | 1 + tests/setup-test/test_setup.sh | 35 ++++++++++++++++++++++++++++++++++ 7 files changed, 64 insertions(+), 14 deletions(-) mode change 100644 => 100755 .packit.sh create mode 100644 tests/setup-test/.gitignore create mode 100755 tests/setup-test/test_setup.sh diff --git a/.packit.sh b/.packit.sh old mode 100644 new mode 100755 diff --git a/.packit.yaml b/.packit.yaml index 942b3b08..5cf02148 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -7,10 +7,21 @@ upstream_tag_template: v{version} srpm_build_deps: - make + - container-selinux + - golang-github-cpuguy83-md2man + - selinux-policy + - selinux-policy-devel + - selinux-policy-base + - selinux-policy-targeted actions: fix-spec-file: - bash .packit.sh + - git clone https://github.com/containers/qm /tmp/qm-0.6.7 + - make dist DIST_DIR=/tmp/qm-0.6.7 + - make rpm DIST_DIR=/tmp/qm-0.6.7 + - sudo dnf install -y ./rpmbuild/RPMS/noarch/qm*.rpm + - bash tests/setup-test/test_setup.sh jobs: - job: copr_build @@ -60,7 +71,6 @@ jobs: disk: - size: ">= 20 GB" - - job: tests trigger: pull_request identifier: e2e-ffi @@ -77,7 +87,6 @@ jobs: hardware: disk: - size: ">= 20 GB" - - size: ">= 20 GB" - job: tests trigger: pull_request diff --git a/Makefile b/Makefile index 7abe711d..bc083d8d 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LIBDIR ?= $(PREFIX)/lib SYSCONFDIR?=/etc QMDIR=/usr/lib/qm SPECFILE=rpm/qm.spec -RPM_TOPDIR ?= $(PWD)/rpmbuild +RPM_TOPDIR ?= ${HOME}/rpmbuild VERSION ?= $(shell cat VERSION) ########################################### @@ -105,29 +105,33 @@ codespell: ## - Runs codespell to check for spelling errors @codespell -S tmp,.git -L te -w clean: ## - Removes generated files and dirs - rm -f *~ *.tc *.pp *.pp.bz2 - rm -rf tmp *.tar.gz ${RPM_TOPDIR} + @rm -f *~ *.tc *.pp *.pp.bz2 + @rm -rf tmp *.tar.gz ${HOME}/rpmbuild man: qm.8.md ## - Generates the QM man page go-md2man --in qm.8.md --out qm.8 .PHONY: dist +DIST_DIR ?= ../qm # Set default path to ../qm, but allow overriding + dist: ## - Creates the QM distribution package + # Get the base directory + mkdir -p "${HOME}/"rpmbuild/{RPMS,SRPMS,BUILD,SOURCES} + cd $(dir $(DIST_DIR)) && \ tar cvz \ --exclude='.git' \ --dereference \ --exclude='.gitignore' \ --exclude='demos' \ - --exclude='.github' \ --transform s/qm/qm-${VERSION}/ \ - -f /tmp/v${VERSION}.tar.gz ../qm - mv /tmp/v${VERSION}.tar.gz ./rpm + --exclude='.github' \ + -f "${HOME}/rpmbuild/SOURCES/qm-${VERSION}.tar.gz" $(notdir $(DIST_DIR)) && \ + ln -sf "${HOME}/rpmbuild/SOURCES/qm-${VERSION}.tar.gz" "${HOME}/rpmbuild/SOURCES/v${VERSION}.tar.gz" .PHONY: rpm rpm: clean dist ## - Creates a local RPM package, useful for development - mkdir -p ${RPM_TOPDIR}/{RPMS,SRPMS,BUILD,SOURCES} + mkdir -p ${HOME}/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES} tools/version-update -v ${VERSION} - cp ./rpm/v${VERSION}.tar.gz ${RPM_TOPDIR}/SOURCES rpmbuild -ba \ --define="u_enable_qm_dropin_img_tempdir ${EN_QM_DROP_IMG_TMPDIR}" \ --define="u_enable_qm_window_manager ${EN_QM_WINDOW_MGR}" \ @@ -136,8 +140,8 @@ rpm: clean dist ## - Creates a local RPM package, useful for develop --define="u_enable_qm_mount_bind_sound ${EN_QM_MNT_BIND_SOUND}" \ --define="u_enable_qm_mount_bind_kvm ${EN_QM_MNT_BIND_KVM}" \ --define="u_enable_qm_mount_bind_input ${EN_QM_MNT_BIND_INPUT}" \ - --define="u_enable_qm_mount_bind_video ${EN_QM_MNT_BIND_VIDEO}" \ - --define="_topdir ${RPM_TOPDIR}" \ + --define="u_enable_qm_mount_bind_video ${EN_QM_MNT_BIND_VIDEO}" \ + --define="_topdir ${HOME}/rpmbuild" \ --define="version ${VERSION}" \ ${SPECFILE} diff --git a/rpm/.gitignore b/rpm/.gitignore index 8999a8b0..335ec957 100644 --- a/rpm/.gitignore +++ b/rpm/.gitignore @@ -1 +1 @@ -v*.tar.gz +*.tar.gz diff --git a/rpm/qm.spec b/rpm/qm.spec index cd770c9d..425d327d 100644 --- a/rpm/qm.spec +++ b/rpm/qm.spec @@ -144,7 +144,8 @@ isolate there applications from other processes in the QM they should use container tools like Podman. %prep -%autosetup -Sgit -n %{name}-%{version} +%setup -q +#%autosetup -Sgit -n %{name}-%{version} sed -i 's/^install: man all/install:/' Makefile %build diff --git a/tests/setup-test/.gitignore b/tests/setup-test/.gitignore new file mode 100644 index 00000000..5bccdecd --- /dev/null +++ b/tests/setup-test/.gitignore @@ -0,0 +1 @@ +qm/ diff --git a/tests/setup-test/test_setup.sh b/tests/setup-test/test_setup.sh new file mode 100755 index 00000000..f4f840c9 --- /dev/null +++ b/tests/setup-test/test_setup.sh @@ -0,0 +1,35 @@ +#!/bin/bash -ex + +# Define variables for repository URL and directory +REPO_URL="https://github.com/containers/qm.git" +REPO_DIR="qm" + +# Step 1: Clone the repository +rm -rf "$REPO_DIR" +echo "Cloning the repository..." +git clone "$REPO_URL" "$REPO_DIR" +cd "$REPO_DIR" || exit 1 + +# Step 2: Build the RPM package +echo "Building the RPM package..." +if ! make rpm; then + echo "RPM build failed." + exit 1 +fi + +# Optional: Install the RPM package to test it fully +echo "Installing the RPM package..." +if ! sudo dnf install -y rpmbuild/RPMS/noarch/qm*.rpm; then + echo "RPM installation failed." + exit 1 +fi + +# Step 3: Run the setup script and check its exit status +echo "Running /usr/share/qm/setup..." +if /usr/share/qm/setup; then + echo "Setup script ran successfully." + rm -rf qm && exit 0 +else + echo "Setup script failed." + rm -rf qm && exit 1 +fi