我已经修改了我的 Gitlab CI/CD 当前流程,以使用 codeclimate 添加一个关于代码质量的阶段。我尝试尽可能地遵循 Gitlab 文档,但是我收到了关于配置模板的错误。
.codeclimate.yml is not a valid location!
这是我的.gitlabci.yml
文件的内容
include:
- template: .codeclimate.yml
stages:
- slack-start-prod
- slack-start-staging
- docker
- test
- code-quality
- deploy-staging
- deploy-prod
- slack-end-prod
- slack-end-staging
- slack-failure
//////////////////////////////////////////////////////////
#------------------------------------------
# run tests on builded docker image
#------------------------------------------
test:
stage: test
image:
name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
services:
- name: mysql:5.7
alias: mysql
- name: redis:6
alias: redis
variables:
MYSQL_DATABASE: xx
MYSQL_ROOT_PASSWORD: xx
MYSQL_USERNAME: xx
MYSQL_HOST: xx
artifacts:
reports:
junit: phpunit-report.xml
expire_in: 10 minutes
when: always
before_script:
- until $(nc -z -v -w1 mysql 3306);do echo Waiting for mysql to be ready... && sleep 5s;done
script:
- cp .env.test.example /var/www/html/.env
- echo 'ok' | mysql --user="$MYSQL_USERNAME" --password="$MYSQL_ROOT_PASSWORD" --host="$MYSQL_HOST" --execute="CREATE DATABASE xx"
- cd /var/www/html
- php artisan migrate --force
- php -dxdebug.mode=coverage vendor/bin/phpunit --configuration phpunit.xml --log-junit phpunit-report.xml --coverage-text --colors=never
- cp phpunit-report.xml $CI_PROJECT_DIR/
tags:
- kubernetes
#------------------------------------------
# run code quality
#------------------------------------------
code-quality:
stage: test
services:
- name: codeclimate/codeclimate-phpcodesniffer
alias: codeclimate-phpcodesniffer
- name: codeclimate/codeclimate-duplication
alias: codeclimate-duplication
image:
name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
artifacts:
paths: [gl-code-quality-report.json]
reports:
codequality: gl-code-quality-report.json
script:
- codeclimate analyze
- cp gl-code-quality-report.json $CI_PROJECT_DIR/
variables:
REPORT_FORMAT: html
tags:
- kubernetes
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////