Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
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
pip install -r requirements.txt
isort . --check-only
black --check .
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
4 changes: 4 additions & 0 deletions ci-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tox>=4.14.0 # MIT
pylint>=3.1.0 # GPLv2
isort>=5.13.2 # MIT
black>=24.2.0 # MIT
41 changes: 23 additions & 18 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]

Expand All @@ -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
Expand All @@ -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 --------------------------------------------------

Expand All @@ -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}
4 changes: 1 addition & 3 deletions ruck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@

import pbr.version


__version__ = pbr.version.VersionInfo(
'ruck').version_string()
__version__ = pbr.version.VersionInfo("ruck").version_string()
4 changes: 1 addition & 3 deletions ruck/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
17 changes: 6 additions & 11 deletions ruck/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

SPDX-License-Identifier: Apache-2.0
"""

import logging
import shutil

from stevedore import driver

from ruck.config import Config
from ruck import exceptions
from ruck.config import Config


class Build(object):
Expand All @@ -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.")
Expand All @@ -35,19 +35,14 @@ 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:
mgr = driver.DriverManager(
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()
6 changes: 3 additions & 3 deletions ruck/cmd/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
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.")
@click.command(help="Build Debian artifact from manifest.")
@pass_state_context
@config_option
def build(state, config):
Expand Down
10 changes: 5 additions & 5 deletions ruck/cmd/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

SPDX-License-Identifier: Apache-2.0
"""

import pathlib

import click
Expand All @@ -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)


Expand All @@ -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)
7 changes: 3 additions & 4 deletions ruck/cmd/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
SPDX-License-Identifier: Apache-2.0

"""

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


@click.group(
help="Debian build system."
)
@click.group(help="Debian build system.")
@pass_state_context
@workspace_option
def cli(state, workspace):
Expand Down
6 changes: 3 additions & 3 deletions ruck/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

SPDX-License-Identifier: Apache-2.0
"""

import os

import yaml
Expand Down Expand Up @@ -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.")
3 changes: 3 additions & 0 deletions ruck/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 5 additions & 8 deletions ruck/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions ruck/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Loading