From 21dd500c05c91c4927b2a4166690da65b1c98f97 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Wed, 11 Nov 2020 14:44:44 +0100 Subject: [PATCH 1/5] Make pycodestyle pipeline happy --- cdist/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cdist/__init__.py b/cdist/__init__.py index 1c60ae0f..44366cd0 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -33,14 +33,15 @@ try: import cdist.version VERSION = cdist.version.VERSION except ModuleNotFoundError: - cdist_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) + cdist_dir = os.path.abspath( + os.path.join(os.path.dirname(__file__), os.pardir)) if os.path.isdir(os.path.join(cdist_dir, '.git')): try: VERSION = subprocess.check_output( ['git', 'describe', '--always'], cwd=cdist_dir, universal_newlines=True) - except: + except Exception: pass BANNER = """ From e2d4f8037ab7d30187e4d153aa25ef36e8afc91c Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Wed, 11 Nov 2020 14:45:05 +0100 Subject: [PATCH 2/5] [bin/cdist-build-helper] Fix paths to ex scripts/ scripts --- bin/cdist-build-helper | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/cdist-build-helper b/bin/cdist-build-helper index bdef0dbb..fb8a67a4 100755 --- a/bin/cdist-build-helper +++ b/bin/cdist-build-helper @@ -45,7 +45,7 @@ usage() { shellcheck-manifests shellcheck-local-gencodes shellcheck-remote-gencodes - shellcheck-scripts + shellcheck-bin shellcheck-gencodes shellcheck-types shellcheck @@ -100,7 +100,7 @@ case "$option" in if (\$0 ~ /^$end/) { exit } else { - print \$0 + print \$0 } } }" "$basedir/docs/changelog" @@ -135,7 +135,7 @@ case "$option" in version=$1; shift - ( + ( cat << eof Subject: cdist $version has been released @@ -336,7 +336,7 @@ eof make docs-clean make docs - ############################################################# + ############################################################# # Everything green, let's do the release # Tag the current commit @@ -405,7 +405,7 @@ eof ;; pycodestyle|pep8) - pycodestyle "${basedir}" "${basedir}/scripts/cdist" + pycodestyle "${basedir}" "${basedir}/bin/cdist" ;; check-pycodestyle) @@ -460,9 +460,10 @@ eof test ! -s "${SHELLCHECKTMP}" || { cat "${SHELLCHECKTMP}"; exit 1; } ;; - shellcheck-scripts) + # NOTE: shellcheck-scripts is kept for compatibility + shellcheck-bin|shellcheck-scripts) # shellcheck disable=SC2086 - ${SHELLCHECKCMD} scripts/cdist-dump scripts/cdist-new-type > "${SHELLCHECKTMP}" + ${SHELLCHECKCMD} bin/cdist-dump bin/cdist-new-type > "${SHELLCHECKTMP}" test ! -s "${SHELLCHECKTMP}" || { cat "${SHELLCHECKTMP}"; exit 1; } ;; @@ -480,7 +481,7 @@ eof shellcheck) "$0" shellcheck-global-explorers || exit 1 "$0" shellcheck-types || exit 1 - "$0" shellcheck-scripts || exit 1 + "$0" shellcheck-bin || exit 1 ;; shellcheck-type-files) From f82e0167aaf295b8451a07fa931506a1290efcdc Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Wed, 11 Nov 2020 14:49:04 +0100 Subject: [PATCH 3/5] [.gitlab-ci.yml] Make version before other targets --- .gitlab-ci.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e48355ea..a4bc67aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,20 +1,23 @@ +--- +image: code.ungleich.ch:5050/ungleich-public/cdist/cdist-ci:latest + stages: - test -image: code.ungleich.ch:5050/ungleich-public/cdist/cdist-ci:latest +before_script: + - ./bin/cdist-build-helper version -unit_tests: +shellcheck: stage: test script: - - ./bin/cdist-build-helper version - - ./bin/cdist-build-helper test + - ./bin/cdist-build-helper shellcheck pycodestyle: stage: test script: - ./bin/cdist-build-helper pycodestyle -shellcheck: +unit_tests: stage: test script: - - ./bin/cdist-build-helper shellcheck + - ./bin/cdist-build-helper test From 0ee3fda94deff1461ac488d218a2af98057675c5 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Wed, 11 Nov 2020 15:04:51 +0100 Subject: [PATCH 4/5] Fix paths to cdist executable --- cdist/integration.py | 5 ++--- cdist/test/__init__.py | 2 +- cdist/test/config/__init__.py | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cdist/integration.py b/cdist/integration.py index 03e4167d..17b65f09 100644 --- a/cdist/integration.py +++ b/cdist/integration.py @@ -54,13 +54,12 @@ _mydir = os.path.dirname(__file__) def find_cdist_exec(): """Search cdist executable starting from local lib directory. - Detect if ../scripts/cdist (from local lib direcotry) exists and + Detect if ../bin/cdist (from local lib directory) exists and if it is executable. If not then try to find cdist exec path in os.get_exec_path() entries. If no cdist path is found rasie cdist.Error. """ - cdist_path = os.path.abspath(os.path.join(_mydir, '..', 'scripts', - 'cdist')) + cdist_path = os.path.abspath(os.path.join(_mydir, '..', 'bin', 'cdist')) if os.access(cdist_path, os.X_OK): return cdist_path cdist_path = find_cdist_exec_in_path() diff --git a/cdist/test/__init__.py b/cdist/test/__init__.py index faa3686a..16a311e4 100644 --- a/cdist/test/__init__.py +++ b/cdist/test/__init__.py @@ -26,7 +26,7 @@ import tempfile cdist_base_path = os.path.abspath( os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../")) -cdist_exec_path = os.path.join(cdist_base_path, "scripts/cdist") +cdist_exec_path = os.path.join(cdist_base_path, "bin/cdist") global_fixtures_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "fixtures")) diff --git a/cdist/test/config/__init__.py b/cdist/test/config/__init__.py index 0ed614b1..c405207c 100644 --- a/cdist/test/config/__init__.py +++ b/cdist/test/config/__init__.py @@ -202,7 +202,7 @@ class ConfigRunTestCase(test.CdistTestCase): host_dir_name=self.hostdir, # exec_path can not derivated from sys.argv in case of unittest exec_path=os.path.abspath(os.path.join( - my_dir, '../../../scripts/cdist')), + my_dir, '../../../bin/cdist')), initial_manifest=os.path.join(fixtures, 'manifest/dryrun_manifest'), add_conf_dirs=[fixtures]) @@ -219,7 +219,7 @@ class ConfigRunTestCase(test.CdistTestCase): base_root_path=self.host_base_path, host_dir_name=self.hostdir, exec_path=os.path.abspath(os.path.join( - my_dir, '../../../scripts/cdist')), + my_dir, '../../../bin/cdist')), initial_manifest=os.path.join( fixtures, 'manifest/init-deps-resolver'), add_conf_dirs=[fixtures]) From c39eb1dbce281ed6f64f804a16fb28e5c8dceccd Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Wed, 11 Nov 2020 15:16:33 +0100 Subject: [PATCH 5/5] [cdist.emulator] Fix setting of log level (tests OK) --- cdist/emulator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index 60b94880..a2bdc3d4 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -120,17 +120,18 @@ class Emulator: level = logging.WARNING else: level = logging.WARNING + self.log = logging.getLogger(self.target_host[0]) try: logging.root.setLevel(level) + self.log.setLevel(level) except (ValueError, TypeError): # if invalid __cdist_log_level value logging.root.setLevel(logging.WARNING) + self.log.setLevel(logging.WARNING) colored_log = self.env.get('__cdist_colored_log', 'false') cdist.log.CdistFormatter.USE_COLORS = colored_log == 'true' - self.log = logging.getLogger(self.target_host[0]) - def commandline(self): """Parse command line"""