1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-10 17:30:11 +01:00

Merge branch 'use-codeclimate-for-linting-tests' into 'master'

ci: use GitLab Code Quality for linting tests

See merge request fdroid/fdroidserver!1443
This commit is contained in:
proletarius101 2024-06-07 11:02:25 +00:00
commit 1c3eb6ec46
5 changed files with 88 additions and 22 deletions

View File

@ -1,3 +0,0 @@
[bandit]
skips: B110,B404,B408,B410,B603,B607
targets: .

2
.bandit.yaml Normal file
View File

@ -0,0 +1,2 @@
skips: [B110, B404, B408, B410, B603, B607, B322]
targets: .

47
.codeclimate.yml Normal file
View File

@ -0,0 +1,47 @@
---
version: "2"
plugins:
shellcheck:
enabled: true
channel:
# Only include tests/run-tests
exclude_patterns:
- "**/*"
- "!tests/run-tests"
checks:
SC2046:
enabled: false
SC2090:
enabled: false
# Disable as the followings are absent in the shellcheck version provided by debian
# https://gitlab.com/fdroid/fdroidserver/-/merge_requests/1443#note_1769237096
SC2086:
enabled: false
SC2129:
enabled: false
SC2006:
enabled: false
SC2126:
enabled: false
SC1007:
enabled: false
SC1001:
enabled: false
SC2016:
enabled: false
SC2181:
enabled: false
SC2103:
enabled: false
SC2089:
enabled: false
bandit:
enabled: true
# Disable as they are not among the array of linters we used previously
duplication:
enabled: false
structure:
enabled: false

View File

@ -1,4 +1,6 @@
---
include:
- template: Code-Quality.gitlab-ci.yml
variables:
pip: pip3 --timeout 100 --retries 10
@ -213,7 +215,7 @@ gradlew-fdroid:
# Run all the various linters and static analysis tools.
lint_format_safety_bandit_checks:
lint_format_safety_checks:
image: debian:bookworm-slim
variables:
LANG: C.UTF-8
@ -228,34 +230,52 @@ 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
- 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
tags:
- saas-linux-medium-amd64
pylint:
rules:
- 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
image: debian:bookworm-slim
script:
- apt-get update
- apt-get -y install --no-install-recommends
python3-pip
pylint
- $pip install --break-system-packages pylint-gitlab
- pylint --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter
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
tests/*.TestCase > pylint-report.json
artifacts:
reports:
codequality: pylint-report.json
# Run all the various linters and static analysis tools.

View File

@ -142,7 +142,7 @@ fi
# allow the location of aapt to be overridden
if [ -z "$aapt" ]; then
aapt=`ls -1 $ANDROID_HOME/build-tools/*/aapt 2> /dev/null | sort | tail -1`
aapt=$(find "$ANDROID_HOME/build-tools/*/aapt" 2> /dev/null | sort | tail -1)
fi
# try to use GNU sed on OSX/BSD cuz BSD sed sucks
@ -745,7 +745,7 @@ if [ -e .git/config ]; then
REPOROOT=`create_test_dir`
cd $REPOROOT
tar xzf `ls -1 $WORKSPACE/dist/fdroidserver-*.tar.gz | sort -n | tail -1`
tar xzf "$(find "$WORKSPACE"/dist/fdroidserver-*.tar.gz | sort -n | tail -1)"
cd $REPOROOT
# shellcheck disable=SC2211
./fdroidserver-*/fdroid init
@ -1303,7 +1303,7 @@ if which wget; then
mv $REPOROOT/index-v1.json repo/index-v1.json
port=321${RANDOM:3}
test $(printf $port | wc -m) -le 3 && port=52734 # when $RANDOM doesn't work
test "${#port}" -le 3 && port=52734 # when $RANDOM doesn't work
timeout 5m python3 -m http.server $port --bind 127.0.0.1 > $REPOROOT/http.server.log 2>&1 &
http_server_pid=$!