diff --git a/.github/workflows/blivetgui_tests.yml b/.github/workflows/blivetgui_tests.yml new file mode 100644 index 000000000..3a8b3bedb --- /dev/null +++ b/.github/workflows/blivetgui_tests.yml @@ -0,0 +1,53 @@ +name: Blivet-GUI tests + +on: + pull_request: + branches: + - 3.*-devel + +jobs: + build: + name: blivetgui-tests + runs-on: ubuntu-22.04 + env: + CI_CONTAINER: blivet-ci-blivetgui-tests + steps: + - name: Checkout blivet repository + uses: actions/checkout@v4 + + - name: Install podman + run: | + sudo apt -qq update + sudo apt -y -qq install podman + + - name: Build the container + run: | + podman build --no-cache -t ${{ env.CI_CONTAINER }} -f misc/ci.Dockerfile . + + - name: Start the container + run: | + podman run -d -t --name ${{ env.CI_CONTAINER }} --privileged --volume "$(pwd):/app" --workdir "/app" ${{ env.CI_CONTAINER }} + + - name: Install Blivet-GUI test dependencies in the container + run: | + podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local /blivet-gui/misc/install-test-dependencies.yml" + + - name: Remove Blivet from the container (we want to install from source) + run: | + podman exec -it ${{ env.CI_CONTAINER }} bash -c "dnf -y remove python3-blivet --noautoremove" + + - name: Install Blivet build dependencies in the container + run: | + podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local misc/install-test-dependencies.yml" + + - name: Build and install Blivet in the container + run: | + podman exec -it ${{ env.CI_CONTAINER }} bash -c "python3 setup.py install --prefix=/usr" + + - name: Run Blivet-GUI static analysis in the container + run: | + podman exec -it ${{ env.CI_CONTAINER }} bash -c "cd /blivet-gui && make check" + + - name: Run Blivet-GUI unit tests in the container + run: | + podman exec -it ${{ env.CI_CONTAINER }} bash -c "cd /blivet-gui && make gui-test" diff --git a/blivet/flags.py b/blivet/flags.py index e1f2279b2..66edf01ca 100644 --- a/blivet/flags.py +++ b/blivet/flags.py @@ -71,6 +71,9 @@ def __init__(self): # backup metadata in /etc/lvm/{archive,backup} self.lvm_metadata_backup = True + # set to False to not write new LVM PVs to /etc/lvm/devices/system.devices + self.lvm_devices_file = True + # whether to include nodev filesystems in the devicetree self.include_nodev = False diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py index b72ea519e..142e37b82 100644 --- a/blivet/formats/lvmpv.py +++ b/blivet/formats/lvmpv.py @@ -37,6 +37,7 @@ from . import DeviceFormat, register_device_format from .. import udev from ..static_data.lvm_info import pvs_info, vgs_info +from ..flags import flags import logging log = logging.getLogger("blivet") @@ -136,6 +137,10 @@ def lvmdevices_add(self, force=True): self.device, lvm.LVM_DEVICES_FILE) return + if not flags.lvm_devices_file: + log.debug("Not adding %s to devices file: 'lvm_devices_file' flag is set to False", self.device) + return + try: blockdev.lvm.devices_add(self.device) except blockdev.LVMError as e: diff --git a/blivet/tasks/fsmkfs.py b/blivet/tasks/fsmkfs.py index 062d54777..e9daa9ea3 100644 --- a/blivet/tasks/fsmkfs.py +++ b/blivet/tasks/fsmkfs.py @@ -272,11 +272,18 @@ def do_task(self, options=None, label=False, set_uuid=False, nodiscard=False): " is unacceptable for this filesystem." % (self.fs.label, self.fs.type)) + if self.fs.create_options: + create_options = shlex.split(self.fs.create_options) + else: + create_options = [] + if options: + create_options += options + try: bd_options = BlockDev.FSMkfsOptions(label=self.fs.label if label else None, uuid=self.fs.uuid if set_uuid else None, no_discard=self.fs._mkfs_nodiscard if nodiscard else False) - BlockDev.fs.mkfs(self.fs.device, self.fstype, bd_options, extra=options or []) + BlockDev.fs.mkfs(self.fs.device, self.fstype, bd_options, extra={k: '' for k in create_options}) except BlockDev.FSError as e: raise FSError(str(e)) diff --git a/misc/ci.Dockerfile b/misc/ci.Dockerfile new file mode 100644 index 000000000..eecf79e23 --- /dev/null +++ b/misc/ci.Dockerfile @@ -0,0 +1,10 @@ +# latest fedora image for running some of our tests in GH actions + +FROM registry.fedoraproject.org/fedora:latest + +RUN set -e; \ + dnf install -y ansible python3-pip git which dnf-plugins-core; \ + git clone --depth 1 https://github.com/storaged-project/ci.git; \ + git clone --depth 1 https://github.com/storaged-project/blivet-gui.git; + +WORKDIR / diff --git a/misc/install-test-dependencies.yml b/misc/install-test-dependencies.yml index 19c3b4f72..691a92292 100644 --- a/misc/install-test-dependencies.yml +++ b/misc/install-test-dependencies.yml @@ -7,6 +7,8 @@ --- - hosts: all become: true + vars: + test_dependencies: true # whether to install test dependencies or not tasks: ####### Fedora @@ -53,7 +55,7 @@ - python3-paramiko - targetcli - iscsi-initiator-utils - when: ansible_distribution == 'Fedora' + when: ansible_distribution == 'Fedora' and test_dependencies|bool ####### CentOS 8/9 - name: Install basic build tools (CentOS) @@ -104,15 +106,15 @@ - python3-pip - targetcli - iscsi-initiator-utils - when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' + when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' and test_dependencies|bool - name: Install paramiko using pip (not available in EPEL yet) (CentOS 9) pip: name=paramiko executable=pip3 - when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '9' + when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '9' and test_dependencies|bool - name: Install pocketlint using pip (CentOS) pip: name=pocketlint executable=pip3 - when: ansible_distribution == 'CentOS' + when: ansible_distribution == 'CentOS' and test_dependencies|bool ####### Debian/Ubuntu - name: Update apt cache (Debian/Ubuntu) @@ -159,7 +161,7 @@ - python3-pip - targetcli-fb - open-iscsi - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' and test_dependencies|bool - name: Install libmount (Debian/Ubuntu) block: @@ -175,4 +177,4 @@ - name: Install pocketlint using pip (Debian/Ubuntu) pip: name=pocketlint executable=pip3 - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' and test_dependencies|bool diff --git a/tests/storage_tests/formats_test/fs_test.py b/tests/storage_tests/formats_test/fs_test.py index 7c9ec58b3..e566670d5 100644 --- a/tests/storage_tests/formats_test/fs_test.py +++ b/tests/storage_tests/formats_test/fs_test.py @@ -10,6 +10,7 @@ from blivet.formats import get_format from blivet.devices import PartitionDevice, DiskDevice from blivet.flags import flags +from blivet.util import capture_output from .loopbackedtestcase import LoopBackedTestCase @@ -67,6 +68,25 @@ def test_online_resize(self): an_fs.unmount() + def test_create_options(self): + label = "root-test-label" + uuid = "c1b9d5a2-f162-11cf-9ece-0020afc76f16" + + an_fs = self._fs_class() + if not an_fs.formattable: + self.skipTest("can not create filesystem %s" % an_fs.name) + an_fs.device = self.loop_devices[0] + + # custom fs create options -- -L