diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7170408..747d70c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ stages: before_script: - apt-get update - - apt-get install -y bash shellcheck + - apt-get install -y bash pylint3 shellcheck test: stage: test diff --git a/src/maintainers b/src/maintainers index ddf87c2..f041c7d 100755 --- a/src/maintainers +++ b/src/maintainers @@ -1,5 +1,17 @@ #!/usr/bin/env python +""" +Original author: XGQT +Licensed under the ISC License +Copyright (c) 2020, src_prepare group + +How to use: + - cd into the repository root: + $ pwd + => /home/user/git/src_prepare-overlay/app-admin/ + cd .. + - run this script +""" import os import os.path diff --git a/test.sh b/test.sh index 2e33377..3933582 100755 --- a/test.sh +++ b/test.sh @@ -1,23 +1,41 @@ #!/bin/sh +# Original author: XGQT +# Licensed under the ISC License +# Copyright (c) 2020, src_prepare group + + +# $1 - code check tool +# $2 - files to check (quoed list) +# Examples: +# - run_test shellcheck "src/check-commit src/repomanci" +# - run_test pylint "${py_files}" + exit_result=0 -files="$(grep -R --exclude-dir='.git' '^#!/.*sh$' 2>/dev/null | cut -d ':' -f 1)" + +run_test() { + for file in ${2} + do + echo "File ${file}... checking" + if command "${1}" "${file}" + then + echo " file is correct" + else + echo " there were errors found in the file" + exit_result=1 + fi + echo "Done: ${file}" + echo + done +} -for file in ${files} -do - echo "File ${file}... checking" - if shellcheck "${file}" - then - echo " file is correct" - else - echo " there were errors found in the file" - exit_result=1 - fi - echo "Done: ${file}" - echo -done +sh_files="$(grep -R --exclude-dir='.git' '^#!/.*sh$' 2>/dev/null | cut -d ':' -f 1)" +py_files="$(grep -R --exclude-dir='.git' '^#!/.*python$' 2>/dev/null | cut -d ':' -f 1)" + +run_test shellcheck "${sh_files}" +run_test pylint "${py_files}" if [ ${exit_result} = 0 ] then