debian-mirror-gitlab/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml

62 lines
2 KiB
YAML
Raw Normal View History

2019-07-07 11:18:12 +05:30
code_quality:
stage: test
2022-05-07 20:08:51 +05:30
image: docker:20.10.12
2019-07-07 11:18:12 +05:30
allow_failure: true
services:
2022-05-07 20:08:51 +05:30
- name: 'docker:20.10.12-dind'
command: ['--tls=false', '--host=tcp://0.0.0.0:2375']
2019-09-30 21:07:59 +05:30
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
2023-03-17 16:20:25 +05:30
CODE_QUALITY_IMAGE_TAG: "0.89.0"
2023-03-04 22:38:38 +05:30
CODE_QUALITY_IMAGE: "$CI_TEMPLATE_REGISTRY_HOST/gitlab-org/ci-cd/codequality:$CODE_QUALITY_IMAGE_TAG"
2020-07-28 23:09:34 +05:30
needs: []
2019-07-07 11:18:12 +05:30
script:
2021-01-03 14:25:43 +05:30
- export SOURCE_CODE=$PWD
2019-07-07 11:18:12 +05:30
- |
if ! docker info &>/dev/null; then
2022-05-07 20:08:51 +05:30
if [ -z "$DOCKER_HOST" ] && [ -n "$KUBERNETES_PORT" ]; then
2019-07-07 11:18:12 +05:30
export DOCKER_HOST='tcp://localhost:2375'
fi
fi
2020-11-24 15:15:51 +05:30
- | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage
function propagate_env_vars() {
CURRENT_ENV=$(printenv)
for VAR_NAME; do
echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
done
}
2022-11-25 23:54:43 +05:30
- |
if [ -n "$CODECLIMATE_REGISTRY_USERNAME" ] && [ -n "$CODECLIMATE_REGISTRY_PASSWORD" ] && [ -n "$CODECLIMATE_PREFIX" ]; then
CODECLIMATE_REGISTRY=${CODECLIMATE_PREFIX%%/*}
docker login "$CODECLIMATE_REGISTRY" --username "$CODECLIMATE_REGISTRY_USERNAME" --password "$CODECLIMATE_REGISTRY_PASSWORD"
fi
2020-01-01 13:55:28 +05:30
- docker pull --quiet "$CODE_QUALITY_IMAGE"
2020-11-24 15:15:51 +05:30
- |
2021-10-27 15:23:28 +05:30
docker run --rm \
2020-11-24 15:15:51 +05:30
$(propagate_env_vars \
SOURCE_CODE \
TIMEOUT_SECONDS \
CODECLIMATE_DEBUG \
CODECLIMATE_DEV \
REPORT_STDOUT \
2021-01-29 00:20:46 +05:30
REPORT_FORMAT \
2020-11-24 15:15:51 +05:30
ENGINE_MEMORY_LIMIT_BYTES \
2021-04-29 21:17:54 +05:30
CODECLIMATE_PREFIX \
2022-11-25 23:54:43 +05:30
CODECLIMATE_REGISTRY_USERNAME \
CODECLIMATE_REGISTRY_PASSWORD \
2020-11-24 15:15:51 +05:30
) \
--volume "$PWD":/code \
--volume /var/run/docker.sock:/var/run/docker.sock \
2020-01-01 13:55:28 +05:30
"$CODE_QUALITY_IMAGE" /code
2019-07-07 11:18:12 +05:30
artifacts:
2019-09-30 21:07:59 +05:30
reports:
codequality: gl-code-quality-report.json
expire_in: 1 week
dependencies: []
2020-05-24 23:13:21 +05:30
rules:
- if: '$CODE_QUALITY_DISABLED'
when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'