From 3fc198062244eeb98fd70e5c4cb40fb6d7facc9c Mon Sep 17 00:00:00 2001 From: Derek Straka Date: Wed, 13 Mar 2024 14:22:53 -0500 Subject: [PATCH 1/4] github-actions: add python lint, build, and test Signed-off-by: Derek Straka --- .github/workflows/python-ci.yml | 92 +++++++++++++++++++++++++++++++++ ci-requirements.txt | 4 ++ 2 files changed, 96 insertions(+) create mode 100644 .github/workflows/python-ci.yml create mode 100644 ci-requirements.txt diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml new file mode 100644 index 0000000..38da26d --- /dev/null +++ b/.github/workflows/python-ci.yml @@ -0,0 +1,92 @@ +--- +name: Python Workflow + +on: # yamllint disable-line rule:truthy + push: + branches: + - "*" + pull_request: + branches: + - "main" + +jobs: + python_lint: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.12] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Python Lint + run: | + python -m pip install --upgrade pip + pip install virtualenv + virtualenv venv + source venv/bin/activate + pip install -r ci-requirements.txt + isort . --check-only || true + black --check . || true + find ruck -type f -name "*.py" | xargs pylint || true + + python_build: + runs-on: ubuntu-latest + needs: python_lint + strategy: + matrix: + python-version: [3.12] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Python Build + run: | + python -m pip install --upgrade pip + pip install virtualenv + virtualenv venv + source venv/bin/activate + pip install -r ci-requirements.txt + pip install -r requirements.txt + pip install build + python -m build + + python_test: + runs-on: ubuntu-latest + needs: python_lint + strategy: + matrix: + python-version: [3.12] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Python Test + run: | + python -m pip install --upgrade pip + pip install virtualenv + virtualenv venv + source venv/bin/activate + pip install -r ci-requirements.txt + tox -e py3 || true diff --git a/ci-requirements.txt b/ci-requirements.txt new file mode 100644 index 0000000..87f710a --- /dev/null +++ b/ci-requirements.txt @@ -0,0 +1,4 @@ +tox>=4.14.0 # MIT +pylint>=3.1.0 # GPLv2 +isort>=5.13.2 # MIT +black>=24.2.0 # MIT \ No newline at end of file From 8f3791ad5fea5188fd777f5d1f8f72234519ff9d Mon Sep 17 00:00:00 2001 From: Derek Straka Date: Thu, 21 Mar 2024 12:21:29 -0500 Subject: [PATCH 2/4] Fix isort lint errors Resolved issues automatically with `isort --recursive .` Signed-off-by: Derek Straka --- ruck/__init__.py | 1 - ruck/build.py | 2 +- ruck/cmd/build.py | 3 ++- ruck/cmd/shell.py | 2 +- ruck/stages/base.py | 3 +-- ruck/stages/bootctl.py | 6 ++---- ruck/stages/bootstrap.py | 3 +-- ruck/stages/deploy.py | 5 ++--- ruck/stages/ostree.py | 3 +-- 9 files changed, 11 insertions(+), 17 deletions(-) diff --git a/ruck/__init__.py b/ruck/__init__.py index 9f3f888..bb6dbd7 100644 --- a/ruck/__init__.py +++ b/ruck/__init__.py @@ -14,6 +14,5 @@ import pbr.version - __version__ = pbr.version.VersionInfo( 'ruck').version_string() diff --git a/ruck/build.py b/ruck/build.py index d577d6e..c700de5 100644 --- a/ruck/build.py +++ b/ruck/build.py @@ -8,8 +8,8 @@ from stevedore import driver -from ruck.config import Config from ruck import exceptions +from ruck.config import Config class Build(object): diff --git a/ruck/cmd/build.py b/ruck/cmd/build.py index f384c37..7dbae1c 100644 --- a/ruck/cmd/build.py +++ b/ruck/cmd/build.py @@ -7,8 +7,9 @@ import click from ruck.build import Build -from ruck.cmd.options import config_option from ruck.cmd import pass_state_context +from ruck.cmd.options import config_option + @click.command( help="Build Debian artifact from manifest.") diff --git a/ruck/cmd/shell.py b/ruck/cmd/shell.py index 7b8d078..2611594 100644 --- a/ruck/cmd/shell.py +++ b/ruck/cmd/shell.py @@ -6,9 +6,9 @@ """ import click +from ruck.cmd import pass_state_context from ruck.cmd.build import build from ruck.cmd.options import workspace_option -from ruck.cmd import pass_state_context from ruck.log import setup_log diff --git a/ruck/stages/base.py b/ruck/stages/base.py index 6dc2f2c..fecd1bb 100644 --- a/ruck/stages/base.py +++ b/ruck/stages/base.py @@ -5,8 +5,7 @@ """ -from abc import ABC -from abc import abstractmethod +from abc import ABC, abstractmethod class Base(ABC): diff --git a/ruck/stages/bootctl.py b/ruck/stages/bootctl.py index 83153df..89bd22f 100644 --- a/ruck/stages/bootctl.py +++ b/ruck/stages/bootctl.py @@ -7,12 +7,10 @@ import logging -from ruck import exceptions -from ruck.mount import mount -from ruck.mount import umount +from ruck import exceptions, utils +from ruck.mount import mount, umount from ruck.schema import validate from ruck.stages.base import Base -from ruck import utils SCHEMA = { "step": {"type": "string"}, diff --git a/ruck/stages/bootstrap.py b/ruck/stages/bootstrap.py index 6e553f5..7140024 100644 --- a/ruck/stages/bootstrap.py +++ b/ruck/stages/bootstrap.py @@ -8,10 +8,9 @@ import logging import shutil -from ruck import exceptions +from ruck import exceptions, utils from ruck.schema import validate from ruck.stages.base import Base -from ruck import utils SCHEMA = { "step": {"type": "string", "required": True}, diff --git a/ruck/stages/deploy.py b/ruck/stages/deploy.py index ae763a5..d55f0ad 100644 --- a/ruck/stages/deploy.py +++ b/ruck/stages/deploy.py @@ -7,10 +7,9 @@ import logging -from ruck.archive import unpack from ruck import exceptions -from ruck.mount import mount -from ruck.mount import umount +from ruck.archive import unpack +from ruck.mount import mount, umount from ruck.schema import validate from ruck.stages.base import Base diff --git a/ruck/stages/ostree.py b/ruck/stages/ostree.py index 762bb66..d4c9fc0 100644 --- a/ruck/stages/ostree.py +++ b/ruck/stages/ostree.py @@ -7,9 +7,8 @@ import logging import pathlib -from ruck import exceptions +from ruck import exceptions, utils from ruck.stages.base import Base -from ruck import utils class OstreeBase(Base): From 97adacddde85667c420b258f7722387d63996329 Mon Sep 17 00:00:00 2001 From: Derek Straka Date: Thu, 21 Mar 2024 12:21:59 -0500 Subject: [PATCH 3/4] Fix linting errors with black Resolved automatically with `black .` Signed-off-by: Derek Straka --- doc/source/conf.py | 41 ++++++++++++++++++++++------------------ ruck/__init__.py | 3 +-- ruck/archive.py | 4 +--- ruck/build.py | 15 +++++---------- ruck/cmd/build.py | 3 +-- ruck/cmd/options.py | 10 +++++----- ruck/cmd/shell.py | 5 ++--- ruck/config.py | 6 +++--- ruck/exceptions.py | 3 +++ ruck/log.py | 13 +++++-------- ruck/mount.py | 6 ++---- ruck/stages/bootctl.py | 17 ++++++++--------- ruck/stages/bootstrap.py | 39 ++++++++++++++++++-------------------- ruck/stages/deploy.py | 2 +- ruck/stages/disk.py | 35 +++++++++++++++++++--------------- ruck/stages/noop.py | 1 + ruck/stages/ostree.py | 4 ++-- ruck/stages/unpack.py | 7 +++---- ruck/tests/base.py | 1 - ruck/utils.py | 12 +++--------- setup.py | 4 +--- 21 files changed, 108 insertions(+), 123 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index d10fdbe..bbaf242 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -15,14 +15,14 @@ import os import sys -sys.path.insert(0, os.path.abspath('../..')) +sys.path.insert(0, os.path.abspath("../..")) # -- General configuration ---------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ - 'sphinx.ext.autodoc', - 'openstackdocstheme', + "sphinx.ext.autodoc", + "openstackdocstheme", #'sphinx.ext.intersphinx', ] @@ -31,19 +31,21 @@ # execute "export SPHINX_DEBUG=1" in your terminal to disable # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'ruck' -copyright = '2022, OpenStack Developers' +project = "ruck" +copyright = "2022, OpenStack Developers" # openstackdocstheme options -openstackdocs_repo_name = 'openstack/ruck' -openstackdocs_bug_project = 'replace with the name of the project on Launchpad or the ID from Storyboard' -openstackdocs_bug_tag = '' +openstackdocs_repo_name = "openstack/ruck" +openstackdocs_bug_project = ( + "replace with the name of the project on Launchpad or the ID from Storyboard" +) +openstackdocs_bug_tag = "" # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True @@ -53,7 +55,7 @@ add_module_names = True # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'native' +pygments_style = "native" # -- Options for HTML output -------------------------------------------------- @@ -62,20 +64,23 @@ # html_theme_path = ["."] # html_theme = '_theme' # html_static_path = ['static'] -html_theme = 'openstackdocs' +html_theme = "openstackdocs" # Output file base name for HTML help builder. -htmlhelp_basename = '%sdoc' % project +htmlhelp_basename = "%sdoc" % project # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ - ('index', - '%s.tex' % project, - '%s Documentation' % project, - 'OpenStack Developers', 'manual'), + ( + "index", + "%s.tex" % project, + "%s Documentation" % project, + "OpenStack Developers", + "manual", + ), ] # Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None} +# intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/ruck/__init__.py b/ruck/__init__.py index bb6dbd7..4f1a974 100644 --- a/ruck/__init__.py +++ b/ruck/__init__.py @@ -14,5 +14,4 @@ import pbr.version -__version__ = pbr.version.VersionInfo( - 'ruck').version_string() +__version__ = pbr.version.VersionInfo("ruck").version_string() diff --git a/ruck/archive.py b/ruck/archive.py index 1330dca..01f4e9f 100644 --- a/ruck/archive.py +++ b/ruck/archive.py @@ -14,6 +14,4 @@ def unpack(archive, rootfs): log.info(f"Unpaking {archive}.") - utils.run_command( - ["tar", "-C", rootfs, "-zxf", archive, "--numeric-owner"] - ) + utils.run_command(["tar", "-C", rootfs, "-zxf", archive, "--numeric-owner"]) diff --git a/ruck/build.py b/ruck/build.py index c700de5..4884d67 100644 --- a/ruck/build.py +++ b/ruck/build.py @@ -3,6 +3,7 @@ SPDX-License-Identifier: Apache-2.0 """ + import logging import shutil @@ -24,8 +25,7 @@ def build(self): self.logging.info("Loading configuration file.") if not self.state.config.exists(): - exceptions.ConfigError( - f"Failed to load configuration: {self.state.config}") + exceptions.ConfigError(f"Failed to load configuration: {self.state.config}") config = self.config.load_config() self.logging.info("Setting up workspace.") @@ -35,10 +35,7 @@ def build(self): self.workspace = self.state.workspace.joinpath(name) self.logging.info("Copying configuration to workspace.") - shutil.copytree( - self.state.config.parent, - self.workspace, - dirs_exist_ok=True) + shutil.copytree(self.state.config.parent, self.workspace, dirs_exist_ok=True) steps = config.get("steps") for step in steps: @@ -46,8 +43,6 @@ def build(self): namespace="ruck.stages", name=step.get("step"), invoke_on_load=True, - invoke_args=(self.state, - step, - self.workspace), - ) + invoke_args=(self.state, step, self.workspace), + ) mgr.driver.run() diff --git a/ruck/cmd/build.py b/ruck/cmd/build.py index 7dbae1c..8a742bc 100644 --- a/ruck/cmd/build.py +++ b/ruck/cmd/build.py @@ -11,8 +11,7 @@ from ruck.cmd.options import config_option -@click.command( - help="Build Debian artifact from manifest.") +@click.command(help="Build Debian artifact from manifest.") @pass_state_context @config_option def build(state, config): diff --git a/ruck/cmd/options.py b/ruck/cmd/options.py index 16577a0..356e107 100644 --- a/ruck/cmd/options.py +++ b/ruck/cmd/options.py @@ -3,6 +3,7 @@ SPDX-License-Identifier: Apache-2.0 """ + import pathlib import click @@ -16,11 +17,9 @@ def callback(ctxt, param, value): state.config = pathlib.Path(value) return value + return click.option( - "-C", "--config", - help="Path to configuration file.", - nargs=1, - callback=callback + "-C", "--config", help="Path to configuration file.", nargs=1, callback=callback )(f) @@ -29,11 +28,12 @@ def callback(ctxt, param, value): state = ctxt.ensure_object(State) state.workspace = pathlib.Path(value) return value + return click.option( "--workspace", help="Path to the ruck workspace.", nargs=1, default="/var/tmp/ruck", required=True, - callback=callback + callback=callback, )(f) diff --git a/ruck/cmd/shell.py b/ruck/cmd/shell.py index 2611594..4df4478 100644 --- a/ruck/cmd/shell.py +++ b/ruck/cmd/shell.py @@ -4,6 +4,7 @@ SPDX-License-Identifier: Apache-2.0 """ + import click from ruck.cmd import pass_state_context @@ -12,9 +13,7 @@ from ruck.log import setup_log -@click.group( - help="Debian build system." -) +@click.group(help="Debian build system.") @pass_state_context @workspace_option def cli(state, workspace): diff --git a/ruck/config.py b/ruck/config.py index 9d55d84..731b571 100644 --- a/ruck/config.py +++ b/ruck/config.py @@ -3,6 +3,7 @@ SPDX-License-Identifier: Apache-2.0 """ + import os import yaml @@ -32,7 +33,6 @@ def load_config(self): """Load the manifest.yaml""" with open(self.state.config, "r") as f: try: - return yaml.safe_load(f) + return yaml.safe_load(f) except yaml.YAMLError: - raise exceptions.ConfigError( - "Unable to parse configuration file.") + raise exceptions.ConfigError("Unable to parse configuration file.") diff --git a/ruck/exceptions.py b/ruck/exceptions.py index 604fb23..2177312 100644 --- a/ruck/exceptions.py +++ b/ruck/exceptions.py @@ -19,14 +19,17 @@ def __str__(self): class ConfigError(RuckError): """Ruck cofiguration error.""" + pass class CommandNotFoundError(RuckError): """Program not found in path error.""" + pass class SchemaError(RuckError): """Schema configuration error.""" + pass diff --git a/ruck/log.py b/ruck/log.py index 7d447f9..ef9334b 100644 --- a/ruck/log.py +++ b/ruck/log.py @@ -18,19 +18,16 @@ def setup_log(debug=False): rootLogger = logging.getLogger() rootLogger.setLevel(logging.NOTSET) - journald_handler = JournalHandler( - SYSLOG_IDENTIFIER="apt-ostree") + journald_handler = JournalHandler(SYSLOG_IDENTIFIER="apt-ostree") journald_handler.setLevel(level) - journald_handler.setFormatter(logging.Formatter( - '[%(levelname)s] %(message)s')) + journald_handler.setFormatter(logging.Formatter("[%(levelname)s] %(message)s")) rootLogger.addHandler(journald_handler) console = Console(color_system=None) - rich_handler = RichHandler(show_path=False, - show_time=False, - show_level=False, - console=console) + rich_handler = RichHandler( + show_path=False, show_time=False, show_level=False, console=console + ) rich_handler.setLevel(level) rich_handler.setFormatter(logging.Formatter(fmt)) rootLogger.addHandler(rich_handler) diff --git a/ruck/mount.py b/ruck/mount.py index cd9fb16..9f73b4f 100644 --- a/ruck/mount.py +++ b/ruck/mount.py @@ -9,10 +9,8 @@ def mount(image, rootfs): - utils.run_command( - ["systemd-dissect", "-M", image, rootfs]) + utils.run_command(["systemd-dissect", "-M", image, rootfs]) def umount(rootfs): - utils.run_command( - ["systemd-dissect", "-U", rootfs]) + utils.run_command(["systemd-dissect", "-U", rootfs]) diff --git a/ruck/stages/bootctl.py b/ruck/stages/bootctl.py index 89bd22f..4583d1c 100644 --- a/ruck/stages/bootctl.py +++ b/ruck/stages/bootctl.py @@ -17,10 +17,10 @@ "options": { "type": "dict", "schema": { - "image": {"type": "string"}, - "kernel_cmdline": {"type": "string"}, - }, + "image": {"type": "string"}, + "kernel_cmdline": {"type": "string"}, }, + }, } @@ -52,10 +52,9 @@ def run(self): self.logging.info("Installing bootloader") utils.run_chroot( - ["bootctl", "install", - "--no-variables", - "--entry-token", "os-id"], - self.image) + ["bootctl", "install", "--no-variables", "--entry-token", "os-id"], + self.image, + ) mount(self.image, self.rootfs) @@ -65,8 +64,8 @@ def run(self): self.logging.info(f"Installing kernel {kver}.") utils.run_chroot( - ["kernel-install", "add", kver, f"/boot/vmlinuz-{kver}"], - self.image) + ["kernel-install", "add", kver, f"/boot/vmlinuz-{kver}"], self.image + ) def install_kernel(self): """Configure kernel cmdine.""" diff --git a/ruck/stages/bootstrap.py b/ruck/stages/bootstrap.py index 7140024..e7762c9 100644 --- a/ruck/stages/bootstrap.py +++ b/ruck/stages/bootstrap.py @@ -17,18 +17,18 @@ "options": { "type": "dict", "schema": { - "target": {"type": "string", "required": True}, - "suite": {"type": "string", "required": True}, - "packages": {"type": "list"}, - "variant": {"type": "string"}, - "components": {"type": "list"}, - "hooks": {"type": "list"}, - "setup-hooks": {"type": "list"}, - "extract-hooks": {"type": "list"}, - "customize-hooks": {"type": "list"}, - "essential-hooks": {"type": "list"}, - }, - } + "target": {"type": "string", "required": True}, + "suite": {"type": "string", "required": True}, + "packages": {"type": "list"}, + "variant": {"type": "string"}, + "components": {"type": "list"}, + "hooks": {"type": "list"}, + "setup-hooks": {"type": "list"}, + "extract-hooks": {"type": "list"}, + "customize-hooks": {"type": "list"}, + "essential-hooks": {"type": "list"}, + }, + }, } @@ -58,7 +58,8 @@ def run(self): cmd = [ self.mmdebstrap, - "--architecture", "amd64", + "--architecture", + "amd64", "--verbose", ] @@ -69,8 +70,7 @@ def run(self): customize_hooks = self.options.get("customize-hooks", None) if customize_hooks: - cmd.extend([f"--customize-hook={hook}" - for hook in customize_hooks]) + cmd.extend([f"--customize-hook={hook}" for hook in customize_hooks]) # Enable extra components (main, non-free, etc). components = self.options.get("components", None) @@ -95,19 +95,16 @@ def run(self): # Enable extract hooks. extract_hooks = self.options.get("extract-hook", None) if extract_hooks: - cmd.extend( - [f"--extract-hook={hook}" for hook in extract_hooks]) + cmd.extend([f"--extract-hook={hook}" for hook in extract_hooks]) # Enable customization hooks. customize_hooks = self.options.get("customize-hooks", None) if customize_hooks: - cmd.extend([f"--customize-hook={hook}" - for hook in customize_hooks]) + cmd.extend([f"--customize-hook={hook}" for hook in customize_hooks]) # Enable essential hooks. essential_hooks = self.options.get("essential-hooks", None) if essential_hooks: - cmd.extend([f"--essential-hook={hook}" - for hook in essential_hooks]) + cmd.extend([f"--essential-hook={hook}" for hook in essential_hooks]) cmd.extend([suite, target]) utils.run_command(cmd, cwd=self.workspace) diff --git a/ruck/stages/deploy.py b/ruck/stages/deploy.py index d55f0ad..670c96d 100644 --- a/ruck/stages/deploy.py +++ b/ruck/stages/deploy.py @@ -21,7 +21,7 @@ "source": {"type": "string", "required": True}, "target": {"type": "string", "required": True}, }, - } + }, } diff --git a/ruck/stages/disk.py b/ruck/stages/disk.py index 6c2fdd3..71e8d70 100644 --- a/ruck/stages/disk.py +++ b/ruck/stages/disk.py @@ -4,6 +4,7 @@ SPDX-License-Identifier: Apache-2.0 """ + import logging import os import shutil @@ -21,9 +22,9 @@ "definition": {"type": "string", "required": True}, "size": {"type": "string", "required": True}, "image": {"type": "string", "required": True}, - } }, - } + }, +} class DiskPlugin(Base): @@ -41,8 +42,7 @@ def run(self): """Create a DDI based disk image using systemd-repart.""" self.logging.info("Creating DDI disk.") if self.repart is None: - raise exceptions.CommandNotFoundError( - "systemd-repart is not found.") + raise exceptions.CommandNotFoundError("systemd-repart is not found.") state = validate(self.config, SCHEMA) if not state: @@ -58,14 +58,19 @@ def run(self): raise exceptions.ConfigError(f"Unable to find {definitions}.") size = self.options.get("size") - run_command([ - self.repart, - "--definitions", str(definitions), - "--empty=create", - "--size", size, - "--dry-run=no", - "--discard=no", - "--offline=true", - "--no-pager", - str(image)], - cwd=self.workspace) + run_command( + [ + self.repart, + "--definitions", + str(definitions), + "--empty=create", + "--size", + size, + "--dry-run=no", + "--discard=no", + "--offline=true", + "--no-pager", + str(image), + ], + cwd=self.workspace, + ) diff --git a/ruck/stages/noop.py b/ruck/stages/noop.py index bb97854..73567eb 100644 --- a/ruck/stages/noop.py +++ b/ruck/stages/noop.py @@ -4,6 +4,7 @@ SPDX-License-Identifier: Apache-2.0 """ + from ruck.stages.base import Base diff --git a/ruck/stages/ostree.py b/ruck/stages/ostree.py index d4c9fc0..a3e74f2 100644 --- a/ruck/stages/ostree.py +++ b/ruck/stages/ostree.py @@ -4,6 +4,7 @@ SPDX-License-Identifier: Apache-2.0 """ + import logging import pathlib @@ -32,5 +33,4 @@ def run(self): if repo.exists(): raise exceptions.ConfigError(f"{repo} already exists.") - utils.run_command( - ["ostree", "init", "--repo", repo, "--mode", mode]) + utils.run_command(["ostree", "init", "--repo", repo, "--mode", mode]) diff --git a/ruck/stages/unpack.py b/ruck/stages/unpack.py index 653053d..f8df581 100644 --- a/ruck/stages/unpack.py +++ b/ruck/stages/unpack.py @@ -4,6 +4,7 @@ SPDX-License-Identifier: Apache-2.0 """ + import logging from ruck.archive import unpack @@ -13,10 +14,8 @@ "target": {"type": "string"}, "options": { "type": "dict", - "schema": { - "target": {"type": "string", "required": True} - }, - } + "schema": {"target": {"type": "string", "required": True}}, + }, } diff --git a/ruck/tests/base.py b/ruck/tests/base.py index 1c30cdb..3054386 100644 --- a/ruck/tests/base.py +++ b/ruck/tests/base.py @@ -19,5 +19,4 @@ class TestCase(base.BaseTestCase): - """Test case base class for all unit tests.""" diff --git a/ruck/utils.py b/ruck/utils.py index e1944a2..e31ffe5 100644 --- a/ruck/utils.py +++ b/ruck/utils.py @@ -4,27 +4,21 @@ SPDX-License-Identifier: Apache-2.0 """ + import subprocess def run_command(argv, **kwargs): """Run a command in a shell.""" try: - return subprocess.run( - argv, **kwargs) + return subprocess.run(argv, **kwargs) except subprocess.CalledProcessError as e: raise e def run_chroot(args, image, **kwargs): """Run a command in a seperate namespace.""" - cmd = [ - "systemd-nspawn", - "--quiet", - "--as-pid2", - "-i", - image - ] + cmd = ["systemd-nspawn", "--quiet", "--as-pid2", "-i", image] cmd += args print(cmd) diff --git a/setup.py b/setup.py index 1f988cd..0346ed3 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,4 @@ # THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT import setuptools -setuptools.setup( - setup_requires=['pbr'], - pbr=True) +setuptools.setup(setup_requires=["pbr"], pbr=True) From f601b13f3193ec4310aebbb111f13bcb3092b0d4 Mon Sep 17 00:00:00 2001 From: Derek Straka Date: Wed, 13 Mar 2024 17:20:36 -0500 Subject: [PATCH 4/4] github-actions: enable isort and black Signed-off-by: Derek Straka --- .github/workflows/python-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 38da26d..058d7b0 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -33,8 +33,9 @@ jobs: virtualenv venv source venv/bin/activate pip install -r ci-requirements.txt - isort . --check-only || true - black --check . || true + pip install -r requirements.txt + isort . --check-only + black --check . find ruck -type f -name "*.py" | xargs pylint || true python_build: