Merge branch 'fix/ci' into 'master'

Make the pipeline green again

See merge request ungleich-public/cdist!954
This commit is contained in:
poljakowski 2020-11-13 06:30:37 +01:00
commit ac31e95ec0
7 changed files with 29 additions and 24 deletions

View file

@ -1,20 +1,23 @@
---
image: code.ungleich.ch:5050/ungleich-public/cdist/cdist-ci:latest
stages: stages:
- test - test
image: code.ungleich.ch:5050/ungleich-public/cdist/cdist-ci:latest before_script:
- ./bin/cdist-build-helper version
unit_tests: shellcheck:
stage: test stage: test
script: script:
- ./bin/cdist-build-helper version - ./bin/cdist-build-helper shellcheck
- ./bin/cdist-build-helper test
pycodestyle: pycodestyle:
stage: test stage: test
script: script:
- ./bin/cdist-build-helper pycodestyle - ./bin/cdist-build-helper pycodestyle
shellcheck: unit_tests:
stage: test stage: test
script: script:
- ./bin/cdist-build-helper shellcheck - ./bin/cdist-build-helper test

View file

@ -45,7 +45,7 @@ usage() {
shellcheck-manifests shellcheck-manifests
shellcheck-local-gencodes shellcheck-local-gencodes
shellcheck-remote-gencodes shellcheck-remote-gencodes
shellcheck-scripts shellcheck-bin
shellcheck-gencodes shellcheck-gencodes
shellcheck-types shellcheck-types
shellcheck shellcheck
@ -405,7 +405,7 @@ eof
;; ;;
pycodestyle|pep8) pycodestyle|pep8)
pycodestyle "${basedir}" "${basedir}/scripts/cdist" pycodestyle "${basedir}" "${basedir}/bin/cdist"
;; ;;
check-pycodestyle) check-pycodestyle)
@ -460,9 +460,10 @@ eof
test ! -s "${SHELLCHECKTMP}" || { cat "${SHELLCHECKTMP}"; exit 1; } test ! -s "${SHELLCHECKTMP}" || { cat "${SHELLCHECKTMP}"; exit 1; }
;; ;;
shellcheck-scripts) # NOTE: shellcheck-scripts is kept for compatibility
shellcheck-bin|shellcheck-scripts)
# shellcheck disable=SC2086 # 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; } test ! -s "${SHELLCHECKTMP}" || { cat "${SHELLCHECKTMP}"; exit 1; }
;; ;;
@ -480,7 +481,7 @@ eof
shellcheck) shellcheck)
"$0" shellcheck-global-explorers || exit 1 "$0" shellcheck-global-explorers || exit 1
"$0" shellcheck-types || exit 1 "$0" shellcheck-types || exit 1
"$0" shellcheck-scripts || exit 1 "$0" shellcheck-bin || exit 1
;; ;;
shellcheck-type-files) shellcheck-type-files)

View file

@ -33,14 +33,15 @@ try:
import cdist.version import cdist.version
VERSION = cdist.version.VERSION VERSION = cdist.version.VERSION
except ModuleNotFoundError: 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')): if os.path.isdir(os.path.join(cdist_dir, '.git')):
try: try:
VERSION = subprocess.check_output( VERSION = subprocess.check_output(
['git', 'describe', '--always'], ['git', 'describe', '--always'],
cwd=cdist_dir, cwd=cdist_dir,
universal_newlines=True) universal_newlines=True)
except: except Exception:
pass pass
BANNER = """ BANNER = """

View file

@ -120,17 +120,18 @@ class Emulator:
level = logging.WARNING level = logging.WARNING
else: else:
level = logging.WARNING level = logging.WARNING
self.log = logging.getLogger(self.target_host[0])
try: try:
logging.root.setLevel(level) logging.root.setLevel(level)
self.log.setLevel(level)
except (ValueError, TypeError): except (ValueError, TypeError):
# if invalid __cdist_log_level value # if invalid __cdist_log_level value
logging.root.setLevel(logging.WARNING) logging.root.setLevel(logging.WARNING)
self.log.setLevel(logging.WARNING)
colored_log = self.env.get('__cdist_colored_log', 'false') colored_log = self.env.get('__cdist_colored_log', 'false')
cdist.log.CdistFormatter.USE_COLORS = colored_log == 'true' cdist.log.CdistFormatter.USE_COLORS = colored_log == 'true'
self.log = logging.getLogger(self.target_host[0])
def commandline(self): def commandline(self):
"""Parse command line""" """Parse command line"""

View file

@ -54,13 +54,12 @@ _mydir = os.path.dirname(__file__)
def find_cdist_exec(): def find_cdist_exec():
"""Search cdist executable starting from local lib directory. """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 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 os.get_exec_path() entries. If no cdist path is found rasie
cdist.Error. cdist.Error.
""" """
cdist_path = os.path.abspath(os.path.join(_mydir, '..', 'scripts', cdist_path = os.path.abspath(os.path.join(_mydir, '..', 'bin', 'cdist'))
'cdist'))
if os.access(cdist_path, os.X_OK): if os.access(cdist_path, os.X_OK):
return cdist_path return cdist_path
cdist_path = find_cdist_exec_in_path() cdist_path = find_cdist_exec_in_path()

View file

@ -26,7 +26,7 @@ import tempfile
cdist_base_path = os.path.abspath( cdist_base_path = os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../")) 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__), global_fixtures_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
"fixtures")) "fixtures"))

View file

@ -202,7 +202,7 @@ class ConfigRunTestCase(test.CdistTestCase):
host_dir_name=self.hostdir, host_dir_name=self.hostdir,
# exec_path can not derivated from sys.argv in case of unittest # exec_path can not derivated from sys.argv in case of unittest
exec_path=os.path.abspath(os.path.join( exec_path=os.path.abspath(os.path.join(
my_dir, '../../../scripts/cdist')), my_dir, '../../../bin/cdist')),
initial_manifest=os.path.join(fixtures, initial_manifest=os.path.join(fixtures,
'manifest/dryrun_manifest'), 'manifest/dryrun_manifest'),
add_conf_dirs=[fixtures]) add_conf_dirs=[fixtures])
@ -219,7 +219,7 @@ class ConfigRunTestCase(test.CdistTestCase):
base_root_path=self.host_base_path, base_root_path=self.host_base_path,
host_dir_name=self.hostdir, host_dir_name=self.hostdir,
exec_path=os.path.abspath(os.path.join( exec_path=os.path.abspath(os.path.join(
my_dir, '../../../scripts/cdist')), my_dir, '../../../bin/cdist')),
initial_manifest=os.path.join( initial_manifest=os.path.join(
fixtures, 'manifest/init-deps-resolver'), fixtures, 'manifest/init-deps-resolver'),
add_conf_dirs=[fixtures]) add_conf_dirs=[fixtures])