diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.github/workflows/anaconda_tests.yml b/.github/workflows/anaconda_tests.yml index 2a94c3c60..0bcc92afd 100644 --- a/.github/workflows/anaconda_tests.yml +++ b/.github/workflows/anaconda_tests.yml @@ -1,5 +1,8 @@ name: Run validation tests from Anaconda -on: pull_request +on: + pull_request: + branches: + - main permissions: contents: read diff --git a/.github/workflows/check-rhel.yml b/.github/workflows/check-rhel.yml new file mode 100644 index 000000000..ce410fd9f --- /dev/null +++ b/.github/workflows/check-rhel.yml @@ -0,0 +1,38 @@ +name: Static Analysis (RHEL) + +on: + pull_request: + branches: + - rhel10-branch + +jobs: + build: + name: static-analysis-rhel + runs-on: ubuntu-24.04 + env: + CI_IMAGE: quay.io/centos/centos:stream10-development + CI_CONTAINER: blivet-tests + steps: + - name: Checkout libblockdev repository + uses: actions/checkout@v4 + + - name: Install podman + run: | + sudo apt -qq update + sudo apt -y -qq install podman + + - name: Start the container + run: | + podman run -d -t --name ${{ env.CI_CONTAINER }} --privileged --volume "$(pwd):/app" --workdir "/app" ${{ env.CI_IMAGE }} + + - name: Install ansible in the container + run: | + podman exec -it ${{ env.CI_CONTAINER }} bash -c "dnf -y install ansible-core make which" + + - name: Install test 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: Run static analysis tests in the container + run: | + podman exec -it ${{ env.CI_CONTAINER }} bash -c "make check" diff --git a/.packit.yaml b/.packit.yaml index d9d43a6f4..4b4c09c9f 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -1,10 +1,5 @@ actions: post-upstream-clone: - # we need to set email and username for the merge commit - - 'git config user.email "blivet-ci@example.com"' - - 'git config user.name "Blivet CI"' - # merge the release branch to get correct version in spec - - 'git merge --ff origin/3.10-release' # bump release to 99 to always be ahead of Fedora builds - 'bash -c "sed -i -r \"s/Release:(\s*)\S+/Release: 99%{?dist}/\" python-blivet.spec"' get-current-version: @@ -20,19 +15,78 @@ actions: - bash -c "sed -i python-blivet.spec -e \"s/Release:.*/Release:\ ${PACKIT_RPMSPEC_RELEASE}%{?dist}/\"" jobs: +# Fedora builds for the 'main' branch - job: copr_build - metadata: - targets: + targets: - fedora-all trigger: pull_request + branch: main +# CentOS 10 Stream builds for the 'rhel10-branch' +- job: copr_build + targets: + - centos-stream-10-x86_64 + trigger: pull_request + branch: rhel10-branch + +# Daily builds for Fedora from the 'main' branch - job: copr_build trigger: commit owner: "@storage" project: blivet-daily - branch: 3.10-devel + branch: main preserve_project: true +# Fedora tests for the 'main' branch +- job: tests + trigger: pull_request + targets: + - fedora-latest-stable + branch: main + +# CentOS 10 Stream tests for the 'rhel10-branch' +- job: tests + trigger: pull_request + targets: + - centos-stream-10-x86_64 + branch: rhel10-branch + +# Downstream builds +- job: propose_downstream + trigger: release + dist_git_branches: + - fedora-all + +- job: koji_build + trigger: commit + dist_git_branches: + - fedora-all + +- job: bodhi_update + trigger: commit + dist_git_branches: + - fedora-branched + +# Reverse dependency tests +## run tests for udisks consumers, see plans/ with `revdeps == yes` +- job: tests + identifier: revdeps + trigger: pull_request + branch: main + notifications: + failure_comment: + message: "Blivet-GUI tests failed for commit {commit_sha}. @vojtechtrefny please check." + targets: + - fedora-latest-stable + tf_extra_params: + environments: + - artifacts: + - type: repository-file + id: https://copr.fedorainfracloud.org/coprs/g/storage/blivet-daily/repo/fedora-$releasever/group_storage-blivet-daily-fedora-$releasever.repo + tmt: + context: + revdeps: "yes" + srpm_build_deps: - git - make diff --git a/blivet/devicelibs/stratis.py b/blivet/devicelibs/stratis.py index fd5c5b268..14b8cb2df 100644 --- a/blivet/devicelibs/stratis.py +++ b/blivet/devicelibs/stratis.py @@ -155,6 +155,8 @@ def set_key(key_desc, passphrase, key_file): fd = read elif key_file: fd = os.open(key_file, os.O_RDONLY) + else: + raise RuntimeError("Passphrase or key file must be provided") fd_list = Gio.UnixFDList() fd_list.append(fd) diff --git a/blivet/devicetree.py b/blivet/devicetree.py index d85f4f9ee..6a27b1e71 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -752,6 +752,7 @@ def resolve_device(self, devspec, blkid_tab=None, crypt_tab=None, options=None, break elif options: attr = None + val = None if "subvol=" in options: attr = "name" val = util.get_option_value("subvol", options) diff --git a/blivet/formats/luks.py b/blivet/formats/luks.py index c6d879411..92c2f0bd7 100644 --- a/blivet/formats/luks.py +++ b/blivet/formats/luks.py @@ -400,6 +400,8 @@ def add_passphrase(self, passphrase): context = blockdev.CryptoKeyslotContext(passphrase=self.__passphrase) elif self._key_file: context = blockdev.CryptoKeyslotContext(keyfile=self._key_file) + else: + raise LUKSError("luks device not configured") ncontext = blockdev.CryptoKeyslotContext(passphrase=passphrase) diff --git a/blivet/tasks/availability.py b/blivet/tasks/availability.py index 32d48d94d..0ee6ff0d1 100644 --- a/blivet/tasks/availability.py +++ b/blivet/tasks/availability.py @@ -283,6 +283,8 @@ def availability_errors(self, resource): avail, _mode, utility = self.check_fn(self.fstype) elif self.operation == FSOperation.MKFS: avail, _options, utility = self.check_fn(self.fstype) + else: + raise RuntimeError("Unknown operation") except blockdev.FSError as e: return [str(e)] if not avail: diff --git a/blivet/udev.py b/blivet/udev.py index d24f8fe1c..70fc722f5 100644 --- a/blivet/udev.py +++ b/blivet/udev.py @@ -86,6 +86,8 @@ def get_device(sysfs_path=None, device_node=None): device = pyudev.Devices.from_sys_path(global_udev, sysfs_path) elif device_node is not None: device = pyudev.Devices.from_device_file(global_udev, device_node) + else: + raise RuntimeError("At least one of 'sysfs_path' and 'device_node' must be specified") except pyudev.DeviceNotFoundError as e: log.error(e) result = None diff --git a/misc/install-test-dependencies.yml b/misc/install-test-dependencies.yml index 4641194ef..273780646 100644 --- a/misc/install-test-dependencies.yml +++ b/misc/install-test-dependencies.yml @@ -59,27 +59,23 @@ - stratis-cli when: ansible_distribution == 'Fedora' and test_dependencies|bool -####### CentOS 8/9 +####### CentOS 9/10 - name: Install basic build tools (CentOS) package: name=make state=present when: ansible_distribution == 'CentOS' - name: Enable EPEL repository (CentOS) package: name=epel-release state=present - when: ansible_distribution == 'CentOS' - - - name: Enable powertools repository (CentOS 8) - command: yum config-manager --set-enabled powertools - when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' - - - name: Enable CRB repository (CentOS 9) - command: yum config-manager --set-enabled crb - when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '9' + when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '9' - - name: Install dnf-plugins-core for dnf builddep (CentOS) + - name: Install dnf-plugins-core for dnf config-manager and builddep (CentOS) package: name=dnf-plugins-core state=present when: ansible_distribution == 'CentOS' + - name: Enable CRB repository (CentOS) + command: dnf config-manager --set-enabled crb + when: ansible_distribution == 'CentOS' + - name: Install build dependencies (CentOS) command: "dnf -y builddep python3-blivet --nogpgcheck" when: ansible_distribution == 'CentOS' @@ -95,8 +91,6 @@ - dosfstools - e2fsprogs - xfsprogs - - python3-coverage - - python3-pycodestyle - python3-pyudev - python3-pyparted - libselinux-python3 @@ -109,12 +103,25 @@ - iscsi-initiator-utils - stratisd - stratis-cli - when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' and test_dependencies|bool + when: ansible_distribution == 'CentOS' and test_dependencies|bool - - name: Install paramiko using pip (not available in EPEL yet) (CentOS 9) - pip: name=paramiko executable=pip3 + - name: Install additional test dependencies (CentOS 9) + package: + state: present + name: + - python3-coverage + - python3-pycodestyle when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '9' and test_dependencies|bool + - name: Install coverage and pycodestyle using pip (CentOS 10) + pip: + name: ['coverage', 'pycodestyle'] + when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '10' and test_dependencies|bool + + - name: Install paramiko using pip + pip: name=paramiko executable=pip3 + when: ansible_distribution == 'CentOS' and test_dependencies|bool + - name: Install pocketlint using pip (CentOS) pip: name=pocketlint executable=pip3 when: ansible_distribution == 'CentOS' and test_dependencies|bool diff --git a/plans/blivet-gui.fmf b/plans/blivet-gui.fmf new file mode 100644 index 000000000..27bad1623 --- /dev/null +++ b/plans/blivet-gui.fmf @@ -0,0 +1,32 @@ +# reverse dependency test for blivet-gui +enabled: false + +adjust+: + when: revdeps == yes + enabled: true + +prepare: + - name: copr + how: shell + script: + - sudo dnf install -y 'dnf-command(copr)' + - sudo dnf copr enable -y @storage/blivet-daily + # TF prioritizes Fedora tag repo over all others, in particular our daily COPR + - for f in $(grep -l -r 'testing-farm-tag-repository' /etc/yum.repos.d); do sed -i '/priority/d' "$f" ;done + - sudo dnf -y update + + - name: ansible + how: ansible + playbook: + - https://raw.githubusercontent.com/storaged-project/blivet-gui/main/misc/install-test-dependencies.yml + +discover: + how: shell + url: https://github.com/storaged-project/blivet-gui + ref: main + tests: + - name: all + test: make test + +execute: + how: tmt diff --git a/plans/tests-rhel.fmf b/plans/tests-rhel.fmf new file mode 100644 index 000000000..01662b86d --- /dev/null +++ b/plans/tests-rhel.fmf @@ -0,0 +1,16 @@ +summary: Run tests + +adjust+: + - when: revdeps == yes + enabled: false + - when: distro == fedora + enabled: false + +prepare: + - name: ansible + how: ansible + playbook: misc/install-test-dependencies.yml + +execute: + how: tmt + script: sudo make test diff --git a/plans/tests.fmf b/plans/tests.fmf new file mode 100644 index 000000000..9967efa8e --- /dev/null +++ b/plans/tests.fmf @@ -0,0 +1,25 @@ +summary: Run tests + +adjust+: + - when: revdeps == yes + enabled: false + - when: distro == centos + enabled: false + +prepare: + - name: copr + how: shell + script: + - sudo dnf install -y 'dnf-command(copr)' + - sudo dnf copr enable -y @storage/blivet-daily + # TF prioritizes Fedora tag repo over all others, in particular our daily COPR + - for f in $(grep -l -r 'testing-farm-tag-repository' /etc/yum.repos.d); do sed -i '/priority/d' "$f" ;done + - sudo dnf -y update + + - name: ansible + how: ansible + playbook: misc/install-test-dependencies.yml + +execute: + how: tmt + script: sudo make test diff --git a/tests/pylint/runpylint.py b/tests/pylint/runpylint.py index eef4047fa..62d6f6e48 100755 --- a/tests/pylint/runpylint.py +++ b/tests/pylint/runpylint.py @@ -23,10 +23,11 @@ def __init__(self): FalsePositive(r"Method 'do_task' is abstract in class 'UnimplementedTask' but is not overridden"), FalsePositive(r"No value for argument 'member_count' in unbound method call$"), FalsePositive(r"No value for argument 'smallest_member_size' in unbound method call$"), - FalsePositive(r"Bad option value '(subprocess-popen-preexec-fn|try-except-raise|environment-modify|arguments-renamed|redundant-u-string-prefix)'"), + FalsePositive(r"Bad option value '(subprocess-popen-preexec-fn|try-except-raise|environment-modify|arguments-renamed|redundant-u-string-prefix|possibly-used-before-assignment)'"), FalsePositive(r"Instance of '(Action.*Device|Action.*Format|Action.*Member|Device|DeviceAction|DeviceFormat|Event|ObjectID|PartitionDevice|StorageDevice|BTRFS.*Device|LoopDevice)' has no 'id' member$"), FalsePositive(r"Instance of 'GError' has no 'message' member"), # overriding currently broken local pylint disable - FalsePositive(r"No name '.*' in module 'libmount'") + FalsePositive(r"No name '.*' in module 'libmount'"), + FalsePositive(r"Unknown option value for 'disable', expected a valid pylint message and got 'possibly-used-before-assignment'") ] def _files(self): diff --git a/tests/run_tests.py b/tests/run_tests.py index a2ca47cd2..22d785c64 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -134,8 +134,8 @@ def _should_skip(distro=None, version=None, arch=None, reason=None): # pylint: # DISTRO, VERSION and ARCH variables are set in main, we don't need to # call hostnamectl etc. for every test run - if ((distro is None or DISTRO in distro) and (version is None or VERSION in version) and # pylint: disable=used-before-assignment - (arch is None or ARCH in arch)): # pylint: disable=used-before-assignment + if ((distro is None or DISTRO in distro) and (version is None or VERSION in version) and # pylint: disable=used-before-assignment,possibly-used-before-assignment + (arch is None or ARCH in arch)): # pylint: disable=used-before-assignment,possibly-used-before-assignment return True return False