Skip to content

Commit

Permalink
packit: add actions for RPM tests
Browse files Browse the repository at this point in the history
- build rpm
- install rpm
- execute setup

Signed-off-by: Douglas Schilling Landgraf <[email protected]>
  • Loading branch information
dougsland committed Oct 29, 2024
1 parent 5b6b21d commit 68b6f8b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 9 deletions.
Empty file modified .packit.sh
100644 → 100755
Empty file.
14 changes: 12 additions & 2 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ 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-{version}
- make dist DIST_DIR=/tmp/qm-{version}
- make rpm DIST_DIR=/tmp/qm-{version}
- sudo dnf install -y ./rpmbuild/RPMS/noarch/qm*.rpm
- bash tests/setup-test/test_setup.sh


jobs:
- job: copr_build
Expand Down Expand Up @@ -60,7 +72,6 @@ jobs:
disk:
- size: ">= 20 GB"


- job: tests
trigger: pull_request
identifier: e2e-ffi
Expand All @@ -77,7 +88,6 @@ jobs:
hardware:
disk:
- size: ">= 20 GB"
- size: ">= 20 GB"

- job: tests
trigger: pull_request
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,31 @@ 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 ${RPM_TOPDIR}

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
mkdir -p ${RPM_TOPDIR}/{RPMS,SRPMS,BUILD,SOURCES}
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
-f ${RPM_TOPDIR}/SOURCES/qm-${VERSION}.tar.gz $(DIST_DIR)
ln -sf ${RPM_TOPDIR}/SOURCES/qm-${VERSION}.tar.gz ${RPM_TOPDIR}/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}
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}" \
Expand All @@ -136,7 +138,7 @@ 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="u_enable_qm_mount_bind_video ${EN_QM_MNT_BIND_VIDEO}" \
--define="_topdir ${RPM_TOPDIR}" \
--define="version ${VERSION}" \
${SPECFILE}
Expand Down
2 changes: 1 addition & 1 deletion rpm/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v*.tar.gz
*.tar.gz
1 change: 1 addition & 0 deletions tests/setup-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qm/
37 changes: 37 additions & 0 deletions tests/setup-test/test_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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..."
make rpm
if [ $? -ne 0 ]; then
echo "RPM build failed."
exit 1
fi

# Optional: Install the RPM package to test it fully
echo "Installing the RPM package..."
sudo dnf install -y rpmbuild/RPMS/noarch/qm*.rpm
if [ $? -ne 0 ]; 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

0 comments on commit 68b6f8b

Please sign in to comment.