53 lines
2.1 KiB
YAML
53 lines
2.1 KiB
YAML
|
|
.pylint_badge: &pylint_badge |
|
|
echo "{
|
|
\"PyLintScore\": \"$PyPIScore\"
|
|
}" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/badge_pylint.json"
|
|
|
|
.PyLint:
|
|
variables:
|
|
PYLINT_PATH: "/*/python-module/*/*.py"
|
|
PYLINT_RC_PATH: "/python/.pylintrc"
|
|
stage: validation
|
|
before_script:
|
|
- if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi
|
|
- echo "[DEBUG] ROOT_DIR[$ROOT_DIR]"
|
|
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME"
|
|
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests"
|
|
- export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'`
|
|
- apt update
|
|
- apt install --no-install-recommends -y git
|
|
- python3 -m venv env
|
|
- . env/bin/activate
|
|
- pip install --upgrade pip
|
|
- pip install -r $ROOT_DIR/python/requirements.txt
|
|
- mkdir $PYTHON_VERSION
|
|
script:
|
|
- PYLINT_PATH=$ROOT_DIR$PYLINT_PATH
|
|
- echo "[DEBUG] PYLINT_PATH[$PYLINT_PATH]"
|
|
- PYLINT_RC_PATH=$ROOT_DIR$PYLINT_RC_PATH
|
|
- echo "[DEBUG] PYLINT_RC_PATH[$PYLINT_RC_PATH]"
|
|
- python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter $PYLINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json"
|
|
|
|
- python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter $PYLINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.html"
|
|
|
|
- PyPIScore=$(python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero $PYLINT_PATH | sed -n 's/^Your code has been rated at \([-0-9./]*\).*/\1/p')
|
|
|
|
- *pylint_badge
|
|
|
|
|
|
after_script:
|
|
- echo deactivate
|
|
artifacts:
|
|
expire_in: 1 days
|
|
when: always
|
|
paths:
|
|
- "artifacts/*"
|
|
reports:
|
|
codequality: "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json"
|
|
rules:
|
|
- if: '$CI_COMMIT_BRANCH'
|
|
when: always
|
|
- when: never
|
|
|