ci: add support for pylint

src: fix QA issues
This commit is contained in:
Maciej Barć 2020-09-16 17:52:34 +02:00
parent 7989b29d7a
commit 30e5013bfa
No known key found for this signature in database
GPG Key ID: 031C9FE65BED714A
3 changed files with 45 additions and 15 deletions

View File

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

View File

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

46
test.sh
View File

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