]> Frank Brehm's Git Trees - pixelpark/python-packaging.git/commitdiff
Adding gitlab/linter.yaml
authorFrank Brehm <frank@brehm-online.com>
Thu, 29 Dec 2022 10:22:31 +0000 (11:22 +0100)
committerFrank Brehm <frank@brehm-online.com>
Thu, 29 Dec 2022 10:22:31 +0000 (11:22 +0100)
gitlab/linter.yaml [new file with mode: 0644]
gitlab/python-setup-template.yaml

diff --git a/gitlab/linter.yaml b/gitlab/linter.yaml
new file mode 100644 (file)
index 0000000..6b39957
--- /dev/null
@@ -0,0 +1,75 @@
+---
+
+variables:
+  UPDATE_ALL_PIP_MODULES: 'n'
+
+Linter:
+  stage: linter
+  extends: .setup-python-environment
+  image: python:3.11
+  rules:
+    - if: '$CI_COMMIT_TAG'
+    - if: $CI_COMMIT_BRANCH == "master"
+    - if: $CI_COMMIT_BRANCH == "main"
+    - if: $CI_COMMIT_BRANCH == "test"
+    - if: $CI_COMMIT_BRANCH =~ /test-.*/
+    - if: $CI_COMMIT_BRANCH =~ /build.*/
+    - if: $CI_COMMIT_BRANCH == "develop"
+  tags:
+    - docker
+  before_script:
+    - locale -a
+    - apt update
+    - apt dist-upgrade --yes
+    - apt install --yes --no-install-recommends sudo locales gettext
+    - >
+      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
+    - locale-gen
+    - locale -a
+    - pip install --upgrade pip
+    - >
+      if [[ -n "${UPDATE_ALL_PIP_MODULES}" && "${UPDATE_ALL_PIP_MODULES}" == "y" ]] ; then
+          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
+  script:
+    - apt install --yes shellcheck yamllint
+    - python --version
+    - pip install --upgrade --upgrade-strategy eager flake8 pylint
+    - >
+      YAML_FILE_PATHS=""
+      if [[ -f .gitlab-ci.yml ]]; then
+          YAML_FILE_PATHS=".gitlab-ci.yml"
+      fi
+      if [[ -d ".github" ]] ; then
+          if [[ -z "${YAML_FILE_PATHS}" ]] ; then
+              YAML_FILE_PATHS=".github"
+          else
+              YAML_FILE_PATHS+=" .github"
+          fi
+      fi
+    - >
+      if [[ -n "${YAML_FILE_PATHS}" ]] ; then
+          echo " "
+          echo "Linting YAML file paths ${YAML_FILE_PATHS} ..."
+          yamllint --config-file .yamllint.yaml --strict --format colored ${YAML_FILE_PATHS} || exit $?
+          echo "All YAML files ok."
+      fi
+
+# vim: et tabstop=2 expandtab shiftwidth=2 softtabstop=2 list
index 575d972ade7595f617130eb0c577c045f5cb6be3..cafad674877c48d068b92a5e788f1fcacb2ac5a3 100644 (file)
@@ -3,7 +3,8 @@
 .setup-python-environment:
   before_script:
     - locale -a
-    - apt update && apt install --yes sudo locales gettext
+    - apt update
+    - apt install --yes sudo locales gettext
     - >
       if test -f /etc/locale.gen; then
         echo "/etc/locale.gen:"