variables:
UPDATE_ALL_PIP_MODULES: 'n'
+ PYTHON_INIT_FILE: ''
Linter:
stage: linter
- docker
before_script:
- locale -a
- - >
- echo -e "\e[0Ksection_start:$( date +%s ):apt_update[collapsed=true]\r\e[0KAPT update ...";
- apt update;
+ - |
+ echo -e "\e[0Ksection_start:$( date +%s ):apt_update[collapsed=true]\r\e[0KAPT update ..."
+ apt update
echo -e "\e[0Ksection_end:$( date +%s ):apt_update\r\e[0K"
- - >
- echo -e "\e[0Ksection_start:$( date +%s ):dist_upgrade[collapsed=true]\r\e[0KAPT dist-upgrade ...";
- apt dist-upgrade --yes;
+ - |
+ echo -e "\e[0Ksection_start:$( date +%s ):dist_upgrade[collapsed=true]\r\e[0KAPT dist-upgrade ..."
+ apt dist-upgrade --yes
echo -e "\e[0Ksection_end:$( date +%s ):dist_upgrade\r\e[0K"
- - >
- echo -e "\e[0Ksection_start:$( date +%s ):install_additional[collapsed=true]\r\e[0KInstalling additional packages ...";
- apt install --yes --no-install-recommends sudo locales gettext;
+ - |
+ echo -e "\e[0Ksection_start:$( date +%s ):install_additional[collapsed=true]\r\e[0KInstalling additional packages ..."
+ apt install --yes --no-install-recommends sudo locales gettext
echo -e "\e[0Ksection_end:$( date +%s ):install_additional\r\e[0K"
- - >
+ - |
if test -f /etc/locale.gen; then
echo "/etc/locale.gen:"
grep -P -v '^\s*(#.*)?$' /etc/locale.gen || true
echo "<-- EOF"
fi
- - >
+ - |
if grep 'en_US.UTF-8' /etc/locale.gen; then
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
else
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
fi
- - >
- echo -e "\e[0Ksection_start:$( date +%s ):locale_gen[collapsed=true]\r\e[0KGenerate locales ...";
- locale-gen;
+ - |
+ echo -e "\e[0Ksection_start:$( date +%s ):locale_gen[collapsed=true]\r\e[0KGenerate locales ..."
+ locale-gen
echo -e "\e[0Ksection_end:$( date +%s ):locale_gen\r\e[0K"
- locale -a
- - >
- echo -e "\e[0Ksection_start:$( date +%s ):update_pip[collapsed=true]\r\e[0KUpdating pip via pip ...";
- pip install --upgrade pip;
+ - |
+ echo -e "\e[0Ksection_start:$( date +%s ):update_pip[collapsed=true]\r\e[0KUpdating pip via pip ..."
+ pip install --upgrade pip
echo -e "\e[0Ksection_end:$( date +%s ):update_pip\r\e[0K"
- - >
- echo -e "\e[0Ksection_start:$( date +%s ):update_outdated[collapsed=true]\r\e[0KUpdating Outdated pip modules ...";
+ - |
+ echo -e "\e[0Ksection_start:$( date +%s ):update_outdated[collapsed=true]\r\e[0KUpdating Outdated pip modules ..."
if [[ -n "${UPDATE_ALL_PIP_MODULES}" && "${UPDATE_ALL_PIP_MODULES}" == "y" ]] ; then
- echo ' ';
- echo "Updating all outdated PIP modules.";
+ echo
+ echo "Updating all outdated PIP modules."
for module in $( pip list --outdated | awk '{if(NR>=3) print $1}' ); do
- echo ' ';
- echo "Updating module '${module}' ...";
- pip install --upgrade "${module}";
- done;
- echo ' ';
- fi;
+ echo
+ echo "Updating module '${module}' ..."
+ pip install --upgrade "${module}"
+ done
+ echo
+ fi
echo -e "\e[0Ksection_end:$( date +%s ):update_outdated\r\e[0K"
script:
- - >
- echo -e "\e[0Ksection_start:$( date +%s ):install_yamllint[collapsed=true]\r\e[0KInstalling yamllint ...";
+ - |
+ echo -e "\e[0Ksection_start:$( date +%s ):install_yamllint[collapsed=true]\r\e[0KInstalling yamllint ..."
apt install --yes shellcheck yamllint
echo -e "\e[0Ksection_end:$( date +%s ):install_yamllint\r\e[0K"
- python --version
- - >
- echo -e "\e[0Ksection_start:$( date +%s ):install_flake[collapsed=true]\r\e[0KInstalling flake8 and pylint ...";
- pip install --upgrade --upgrade-strategy eager flake8 pylint;
+ - |
+ echo -e "\e[0Ksection_start:$( date +%s ):install_flake[collapsed=true]\r\e[0KInstalling flake8 and pylint ..."
+ pip install --upgrade --upgrade-strategy eager flake8 pylint
echo -e "\e[0Ksection_end:$( date +%s ):install_flake\r\e[0K"
- - >
- if [[ -f ".gitlab-ci.yml" ]] ; then YAML_FILE_PATHS=".gitlab-ci.yml"; else YAML_FILE_PATHS=""; fi;
+ - |
+ if [[ -f ".gitlab-ci.yml" ]] ; then
+ YAML_FILE_PATHS=".gitlab-ci.yml"
+ else YAML_FILE_PATHS=""
+ fi
if [[ -d ".github" ]] ; then
if [[ -z "${YAML_FILE_PATHS}" ]] ; then
- YAML_FILE_PATHS=".github";
+ YAML_FILE_PATHS=".github"
+ else
+ YAML_FILE_PATHS+=" .github"
+ fi
+ fi
+ - |
+ if [[ -n "${PYTHON_INIT_FILE}" && -f "${PYTHON_INIT_FILE}" && -n "${CI_COMMIT_TAG}" ]] ; then
+ echo
+ echo "Checking module version against tag ..."
+ MODULE_VERSION=$( grep -P '^__version__(\s|=)' "${PYTHON_INIT_FILE}" | sed -e "s/^[^'\"]*['\"]//" -e "s/['\"][ »]*\$//" )
+ echo "Module version: '${MODULE_VERSION}'"
+ echo "Commit tag: '${CI_COMMIT_TAG}'."
+ if [[ "${MODULE_VERSION}" == "${CI_COMMIT_TAG}" ]] ; then
+ echo "Tag and module version '${MODULE_VERSION}' are okay."
+ else
+ echo "Tag '${CI_COMMIT_TAG}' does not match module version '${MODULE_VERSION}'" >&2
+ exit 5
+ fi
+ fi
+ - |
+ if [[ -n "${PYTHON_INIT_FILE}" && -f "${PYTHON_INIT_FILE}" && -f debian/changlog ]] ; then
+ echo
+ echo "Checking module version against version in debian/changlog ..."
+ MODULE_VERSION=$( grep -P '^__version__(\s|=)' "${PYTHON_INIT_FILE}" | sed -e "s/^[^'\"]*['\"]//" -e "s/['\"][ »]*\$//" )
+ DEBIAN_PKG_VERSION=$( head -n 1 debian/changelog | sed -e 's/^[^(]*(//' -e 's/).*//' )
+ echo "Module version: '${MODULE_VERSION}'"
+ echo "Debian package version: '${DEBIAN_PKG_VERSION}'"
+ if [[ "${MODULE_VERSION}" == "${DEBIAN_PKG_VERSION}" ]] ; then
+ echo "Debian package version and module version '${DEBIAN_PKG_VERSION}' are matching."
else
- YAML_FILE_PATHS+=" .github";
+ echo "Debian package version '${DEBIAN_PKG_VERSION}' does not match module version '${MODULE_VERSION}'" >&2
+ exit 5
fi
fi
- - >
+ - |
if [[ -n "${YAML_FILE_PATHS}" ]] ; then
- echo " "
+ echo
echo "Linting YAML file paths ${YAML_FILE_PATHS} ..."
- yamllint --config-file .yamllint.yaml --strict --format colored ${YAML_FILE_PATHS} || exit $?
+ yamllint --config-file .yamllint.yaml --strict --format colored ${YAML_FILE_PATHS}
echo "All YAML files ok."
fi