From: Frank Brehm Date: Thu, 29 Dec 2022 13:43:24 +0000 (+0100) Subject: Adding possibility of different languages in gitlab/python-test-template.yaml and... X-Git-Tag: v1.0~12 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=f19b12492385a308eb011def9973cfffb50352d2;p=pixelpark%2Fpython-packaging.git Adding possibility of different languages in gitlab/python-test-template.yaml and gitlab/python-setup-template.yaml --- diff --git a/gitlab/python-setup-template.yaml b/gitlab/python-setup-template.yaml index 927f163..e37f1e3 100644 --- a/gitlab/python-setup-template.yaml +++ b/gitlab/python-setup-template.yaml @@ -1,5 +1,10 @@ --- +#--------------------------- +variables: + TEST_LOCALES: 'en_US.UTF-8 de_DE.UTF-8' + +#--------------------------- .setup-python-environment: before_script: - locale -a @@ -17,22 +22,37 @@ 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 + echo "/etc/locale.gen:" + grep -P -v '^\s*(#.*)?$' /etc/locale.gen || true + echo "<-- EOF" else - echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen + echo "Creating /etc/locale.gen ..." + echo "en_US.UTF-8 UTF-8" > /etc/locale.gen fi - | - if grep 'de_DE.UTF-8' /etc/locale.gen; then - sed -i -e 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/' /etc/locale.gen + echo + echo "Configuring locales:" + if [[ -n "${TEST_LOCALES}" ]] ; then + if echo "${TEST_LOCALES}" | grep -w 'en_US.UTF-8' >/dev/null ; then + USED_LOCALES="${TEST_LOCALES}" + else + USED_LOCALES="en_US.UTF-8 ${TEST_LOCALES}" + fi else - echo 'de_DE.UTF-8 UTF-8' >> /etc/locale.gen + USED_LOCALES="en_US.UTF-8" fi + for locale in ${USED_LOCALES} ; do + echo " * ${locale}" + if grep -w "${locale}" /etc/locale.gen >/dev/null ; then + sed -i -e "s/# *${locale} *UTF-8/${locale} UTF-8/" /etc/locale.gen + else + echo "${locale} UTF-8" >> /etc/locale.gen + fi + done + echo + echo "/etc/locale.gen:" + grep -P -v '^\s*(#.*)?$' /etc/locale.gen || true + echo "<-- EOF" - | echo -e "\e[0Ksection_start:$( date +%s ):locale_gen[collapsed=true]\r\e[0KGenerate locales ..." locale-gen diff --git a/gitlab/python-test-template.yaml b/gitlab/python-test-template.yaml index 58d445e..10baabb 100644 --- a/gitlab/python-test-template.yaml +++ b/gitlab/python-test-template.yaml @@ -1,5 +1,10 @@ --- +#--------------------------- +variables: + TEST_LOCALES: 'en_US.UTF-8 de_DE.UTF-8' + +#--------------------------- .exec-python-tests: stage: test rules: @@ -18,6 +23,25 @@ pip install --upgrade --upgrade-strategy eager pytest echo -e "\e[0Ksection_end:$( date +%s ):install_pytest\r\e[0K" - pip list --format columns - - pytest --verbose + - | + if [[ -n "${TEST_LOCALES}" ]] ; then + if echo "${TEST_LOCALES}" | grep -w 'en_US.UTF-8' >/dev/null ; then + USED_LOCALES="${TEST_LOCALES}" + else + USED_LOCALES="en_US.UTF-8 ${TEST_LOCALES}" + fi + else + USED_LOCALES="en_US.UTF-8" + fi + for locale in ${USED_LOCALES} ; do + echo + echo "Executing pytest for locale '${locale}' ..." + export LC_ALL="${locale}" + export LANG="${locale}" + export LANGUAGE=$( echo "${locale}" | cut -d. -f1 ) + locale + echo + pytest --verbose + done # vim: et tabstop=2 expandtab shiftwidth=2 softtabstop=2 list