From 6cf678a4fc6b71bffabadca2e20bb761e11d3ce6 Mon Sep 17 00:00:00 2001 From: proletarius101 Date: Mon, 12 Feb 2024 15:36:51 +0800 Subject: [PATCH] ci: use codeclimate for linting tests Codeclimate is [integrated](https://docs.gitlab.com/ee/ci/testing/code_quality.html#customizing-scan-settings) into GitLab. Thus the UI is more intuitive from the web gui. --- .codeclimate.yml | 11 +++++++++++ .gitlab-ci.yml | 30 ++++++++++++------------------ 2 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 .codeclimate.yml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 00000000..bb651e21 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,11 @@ +--- +version: "2" +plugins: + pylint: + enabled: true + + shellcheck: + enabled: true + + bandit: + enabled: true diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 866a2ec8..e2c1049e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,6 @@ --- +include: + - template: Code-Quality.gitlab-ci.yml variables: pip: pip3 --timeout 100 --retries 10 @@ -222,36 +224,28 @@ lint_format_safety_bandit_checks: make pycodestyle pyflakes3 - pylint python3-dev python3-git python3-nose python3-pip python3-yaml - shellcheck - - $pip install --break-system-packages bandit safety + - $pip install --break-system-packages safety - export EXITVALUE=0 - function set_error() { export EXITVALUE=1; printf "\x1b[31mERROR `history|tail -2|head -1|cut -b 6-500`\x1b[0m\n"; } - ./hooks/pre-commit || set_error - - bandit - -r - -ii - --ini .bandit - || set_error - safety check --full-report || set_error - - pylint --output-format=colorized --reports=n - fdroid - makebuildserver - setup.py - fdroidserver/*.py - tests/*.py - tests/*.TestCase - || set_error - - shellcheck --exclude SC2046,SC2090 --severity=warning --color tests/run-tests - || set_error - exit $EXITVALUE +code_quality: + rules: + - if: $CODE_QUALITY_DISABLED + when: never + - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Run code quality job in merge request pipelines + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run code quality job in pipelines on the default branch (but not in other branch pipelines) + - if: $CI_COMMIT_TAG # Run code quality job in pipelines for tags + + # Run all the various linters and static analysis tools. locales: image: debian:bookworm-slim