From 8fcd2e995d54a806ed6ec81b6be63e9354aa4a3d Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 4 Sep 2024 15:04:35 +0200 Subject: [PATCH 1/9] misc: Add support for installing dependencies on CentOS 1O Stream --- misc/install-test-dependencies.yml | 39 ++++++++++++++++++------------ 1 file changed, 23 insertions(+), 16 deletions(-) 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 From e900553ed57a03dc831555a487cd2c55b7ad2940 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 5 Sep 2024 09:59:03 +0200 Subject: [PATCH 2/9] ci: Add a GH action to run static analysis on CentOS 10 Stream This runs 'make check' in the latest CentOS 10 Stream container. --- .github/workflows/check-rhel.yml | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/check-rhel.yml 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" From c892392efeb6782020dc370e2a6950e14efb0880 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Mon, 20 May 2024 10:55:22 +0200 Subject: [PATCH 3/9] Fix pylint 'possibly-used-before-assignment' warnings The latest pylint introduced a new warning for values possibly used before assignment. --- blivet/devicelibs/stratis.py | 2 ++ blivet/devicetree.py | 1 + blivet/formats/luks.py | 2 ++ blivet/tasks/availability.py | 2 ++ blivet/udev.py | 2 ++ tests/pylint/runpylint.py | 5 +++-- tests/run_tests.py | 4 ++-- 7 files changed, 14 insertions(+), 4 deletions(-) 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/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 From 3368690ff6e4029c0bdd684dc195448298adf3a9 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 5 Sep 2024 10:07:07 +0200 Subject: [PATCH 4/9] ci: Sync .packit.yml with the main branch --- .packit.yaml | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/.packit.yaml b/.packit.yaml index d9d43a6f4..b8f5f7783 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: @@ -30,9 +25,47 @@ jobs: trigger: commit owner: "@storage" project: blivet-daily - branch: 3.10-devel + branch: main preserve_project: true +- job: tests + trigger: pull_request + targets: + - fedora-latest-stable + +- 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 + +# run tests for udisks consumers, see plans/ with `revdeps == yes` +- job: tests + identifier: revdeps + trigger: pull_request + 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 From 35d6649b74754e0da84d10f3614154022167b67d Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 5 Sep 2024 10:08:09 +0200 Subject: [PATCH 5/9] packit: Limit Fedora builds and tests to the 'main' branch --- .packit.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.packit.yaml b/.packit.yaml index b8f5f7783..c690e157b 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -16,10 +16,10 @@ actions: jobs: - job: copr_build - metadata: - targets: + targets: - fedora-all trigger: pull_request + branch: main - job: copr_build trigger: commit @@ -32,6 +32,7 @@ jobs: trigger: pull_request targets: - fedora-latest-stable + branch: main - job: propose_downstream trigger: release @@ -52,6 +53,7 @@ jobs: - job: tests identifier: revdeps trigger: pull_request + branch: main notifications: failure_comment: message: "Blivet-GUI tests failed for commit {commit_sha}. @vojtechtrefny please check." From 111b07d54e971312db9f6e3c403466338e2ebd9a Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 5 Sep 2024 10:19:23 +0200 Subject: [PATCH 6/9] ci: Limit running Anaconda tests to 'main' branch only --- .github/workflows/anaconda_tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From e2c8715cc80d0f183213450950a9881c1db38582 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 5 Sep 2024 10:33:08 +0200 Subject: [PATCH 7/9] packit: Add RPM build for pull requests against the rhel10-branch For 'rhel10-branch' we want to run builds just for the CentOS 10 Stream target. --- .packit.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.packit.yaml b/.packit.yaml index c690e157b..b29db5313 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -15,12 +15,21 @@ 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 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" @@ -28,12 +37,14 @@ jobs: branch: main preserve_project: true +# Fedora tests for the 'main' branch - job: tests trigger: pull_request targets: - fedora-latest-stable branch: main +# Downstream builds - job: propose_downstream trigger: release dist_git_branches: @@ -49,7 +60,8 @@ jobs: dist_git_branches: - fedora-branched -# run tests for udisks consumers, see plans/ with `revdeps == yes` +# Reverse dependency tests +## run tests for udisks consumers, see plans/ with `revdeps == yes` - job: tests identifier: revdeps trigger: pull_request From fcf16108a3c110c99e1ec0cd5565ae3a138cb3b8 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 5 Sep 2024 13:50:24 +0200 Subject: [PATCH 8/9] ci: Copy tmt tests from the main branch --- .fmf/version | 1 + plans/blivet-gui.fmf | 32 ++++++++++++++++++++++++++++++++ plans/tests.fmf | 23 +++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .fmf/version create mode 100644 plans/blivet-gui.fmf create mode 100644 plans/tests.fmf 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/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.fmf b/plans/tests.fmf new file mode 100644 index 000000000..ba2b6baa3 --- /dev/null +++ b/plans/tests.fmf @@ -0,0 +1,23 @@ +summary: Run tests + +adjust+: + when: revdeps == yes + 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 From ec4b84f8c57a693961b78a4bee663d27018ea1e9 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 5 Sep 2024 13:52:42 +0200 Subject: [PATCH 9/9] packit: Add tmt tests for rhel10-branch running on C10S --- .packit.yaml | 7 +++++++ plans/tests-rhel.fmf | 16 ++++++++++++++++ plans/tests.fmf | 6 ++++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 plans/tests-rhel.fmf diff --git a/.packit.yaml b/.packit.yaml index b29db5313..4b4c09c9f 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -44,6 +44,13 @@ jobs: - 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 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 index ba2b6baa3..9967efa8e 100644 --- a/plans/tests.fmf +++ b/plans/tests.fmf @@ -1,8 +1,10 @@ summary: Run tests adjust+: - when: revdeps == yes - enabled: false + - when: revdeps == yes + enabled: false + - when: distro == centos + enabled: false prepare: - name: copr