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 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) 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 = """ 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""" 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])