代码拉取完成,页面将自动刷新
#注意:定制项目请在GitlabCI 设置里面添加变量 REPOSITORY 为 "custom" ;设置非法值或者未设置都会报警
stages:
- automation
- test
variables:
MYSQL_DATABASE: edusoho_test
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
before_script:
- cp app/config/parameters.yml.dist app/config/parameters.yml
- cp app/config/parameters.yml.dist app/config/parameters_test.yml
- "sed -i 's/\\s*database_host.*/ database_host: mysql/g' app/config/parameters_test.yml"
- "sed -i 's/\\s*database_name.*/ database_name: edusoho_test/g' app/config/parameters_test.yml"
- "echo ' redis_host: redis:6379' >> app/config/parameters_test.yml"
- "echo ' redis_timeout: 1' >> app/config/parameters_test.yml"
- "echo ' redis_reserved: null' >> app/config/parameters_test.yml"
- "echo ' redis_retry_interval: 100' >> app/config/parameters_test.yml"
- mkdir web/files
- mkdir -p app/data/private_files
- touch app/config/routing_plugins.yml
check env:
stage: test
image: codeages/ci-php:5.3-2
script:
- if [[ "${REPOSITORY}" != "main" ]]&&[[ "${REPOSITORY}" != "custom" ]];then
- echo "必须在Gitlab中设置正确的REPOSITORY,当前的设置为:${REPOSITORY}, 请打开此文档链接地址去修改为正确的配置:http://kb.codeages.net/edusoho/projects/continuous-integration.html "
- exit 1
- fi
except:
variables:
- $REPOSITORY == "main"
- $REPOSITORY == "custom"
#5.3 with nothing:
# stage: test
# image: codeages/ci-php:5.3-2
# services:
# - mysql:5.5
# script:
# - bin/phpunit-diff
# only:
# refs:
# - develop
# - master
# - trigger
# variables:
# - $REPOSITORY == "main"
#
#5.3 with Redis:
# stage: test
# image: codeages/ci-php:5.3-2
# services:
# - mysql:5.5
# - redis:latest
# script:
# - bin/phpunit-diff
# only:
# refs:
# - develop
# - master
# - trigger
# variables:
# - $REPOSITORY == "main"
7.1 with php-cs-fixer only for custom:
stage: test
image: codeages/ci-php71:6
services:
- mysql:5.5
- redis:latest
script:
- git config diff.nodiff.command /usr/bin/true
- php-cs-fixer fix --config=.php_cs.dist -v --dry-run --using-cache=no --path-mode=intersection `git diff --name-only --diff-filter=ACMRTUXB HEAD~..HEAD`
- git config --unset diff.nodiff.command
- bin/phpunit-diff
only:
variables:
- $REPOSITORY == "custom"
5.6 with php-cs-fixer only for main:
stage: test
image: zhongyunchang/php56-ci
services:
- mysql:5.5
- redis:latest
script:
- git config diff.nodiff.command /usr/bin/true
- bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --using-cache=no --path-mode=intersection `git diff --name-only --diff-filter=ACMRTUXB HEAD~..HEAD`
- git config --unset diff.nodiff.command
- bin/phpunit-diff
only:
refs:
- merge_requests
variables:
- $REPOSITORY == "main"
7.1 For main:
stage: test
image: codeages/ci-php71
services:
- mysql:5.5
- redis:latest
script:
- bin/phpunit-diff
only:
refs:
- master
- release
- trigger
variables:
- $REPOSITORY == "main"
- $REPOSITORY == "custom"
7.1 For main with MySQL80:
stage: test
image: codeages/ci-php71
services:
- name: mysql:8.0
command: ["--default-authentication-plugin=mysql_native_password"]
- redis:latest
script:
- bin/phpunit-diff
only:
refs:
- /^release/.*$/
- develop
- master
- project/b2c
variables:
- $REPOSITORY == "main"
7.4 For main with MySQL80:
stage: test
image: codeages/ci-php74
services:
- name: mysql:8.0
command: ["--default-authentication-plugin=mysql_native_password"]
- redis:latest
script:
- bin/phpunit-diff
only:
refs:
- /^release/.*$/
- develop
- master
- project/data-visualization
variables:
- $REPOSITORY == "main"
7.1 For Develop:
stage: test
image: codeages/ci-php71
services:
- mysql:5.5
- redis:latest
script:
- sed -i 's/memory_limit.*/memory_limit = 3000M/g' /etc/php/7.1/phpdbg/php.ini
- sed -i "s/sonar.projectKey=.*/sonar.projectKey=$SONAR_PROJECT_KEY/g" sonar-project.properties
- phpdbg -qrr bin/phpunit -c app/ --debug --coverage-text --colors=never --testsuite UnitA2B --coverage-clover reports_tmp/phpunit.coverage.xml_1 --log-junit reports_tmp/phpunit.xml_1
- phpdbg -qrr bin/phpunit -c app/ --debug --coverage-text --colors=never --testsuite UnitC2C --coverage-clover reports_tmp/phpunit.coverage.xml_2 --log-junit reports_tmp/phpunit.xml_2
- phpdbg -qrr bin/phpunit -c app/ --debug --coverage-text --colors=never --testsuite UnitD2D --coverage-clover reports_tmp/phpunit.coverage.xml_3 --log-junit reports_tmp/phpunit.xml_3
- phpdbg -qrr bin/phpunit -c app/ --debug --coverage-text --colors=never --testsuite UnitE2P --coverage-clover reports_tmp/phpunit.coverage.xml_4 --log-junit reports_tmp/phpunit.xml_4
- phpdbg -qrr bin/phpunit -c app/ --debug --coverage-text --colors=never --testsuite UnitQ2T --coverage-clover reports_tmp/phpunit.coverage.xml_5 --log-junit reports_tmp/phpunit.xml_5
- phpdbg -qrr bin/phpunit -c app/ --debug --coverage-text --colors=never --testsuite UnitU2Z --coverage-clover reports_tmp/phpunit.coverage.xml_6 --log-junit reports_tmp/phpunit.xml_6
- phpdbg -qrr bin/phpunit -c app/ --debug --coverage-text --colors=never --testsuite SpecialTest --coverage-clover reports_tmp/phpunit.coverage.xml_7 --log-junit reports_tmp/phpunit.xml_7
- mkdir reports
- bin/caculate
- echo "sonar.links.ci=$SONAR_LINKS_CI" >> sonar-project.properties
- echo "sonar.links.issue=$SONAR_LINKS_ISSUE" >> sonar-project.properties
- echo "sonar.host.url=$SONAR_HOST" >> /opt/sonar-scanner/conf/sonar-scanner.properties
- echo "sonar.login=$SONAR_TOKEN" >> /opt/sonar-scanner/conf/sonar-scanner.properties
- /opt/sonar-scanner/bin/sonar-scanner
only:
refs:
- develop
variables:
- $REPOSITORY == "main"
- $REPOSITORY == "custom"
AT With Java And Selenium:
stage: automation
image: ruanwenqin/ci:php5.5-jdk8
services:
- mysql:5.7
- selenium/standalone-chrome:latest
script:
# 修改配置文件
- "sed -i 's/\\s*database_host.*/ database_host: mysql/g' app/config/parameters.yml"
- "sed -i 's/\\s*database_name.*/ database_name: edusoho_test/g' app/config/parameters.yml"
# 启动web服务
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/vip.git plugins/VipPlugin
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/chargecoin.git plugins/ChargeCoinPlugin
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/coupon.git plugins/CouponPlugin
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/discount.git plugins/DiscountPlugin
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/moneycard.git plugins/MoneyCardPlugin
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/userimporter.git plugins/UserImporterPlugin
# 安装插件
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusoho/GUIAutomation2.git
- mysql -uroot --password="" -h mysql edusoho_test < GUIAutomation2/src/main/resources/fixtures/try3.sql
- tar xzf GUIAutomation2/src/main/resources/fixtures/file.tar.gz
- export SERVICE_IP=$(getent hosts $HOSTNAME | awk '{ print $1 }')
- bin/phpmig migrate
- app/console server:start $SERVICE_IP:8000
- cd GUIAutomation2
- sed -i "s/homePage\.url.*/homePage\.url=http\:\/\/$SERVICE_IP\:8000/g" src/main/resources/testdata_common.properties
- /opt/apache-maven-3.5.2/bin/mvn -B -Dmaven.repo.local=/cache/.m2 clean test -DseleniumBrowserType=chrome -DseleniumHubUrl="http://selenium__standalone-chrome:4444/wd/hub" -DisLocal=false
only:
refs:
- schedules
- triggers
- web
- api
variables:
- $REPOSITORY == "main"
Api Test With 7.1:
stage: test
image: codeages/ci-php71
services:
- mysql:5.5
- redis:latest
script:
# 修改配置文件
- "sed -i 's/\\s*database_host.*/ database_host: mysql/g' app/config/parameters.yml"
- "sed -i 's/\\s*database_name.*/ database_name: edusoho_test/g' app/config/parameters.yml"
- touch app/data/specialEnv # 防止 新建uuid 索引报错的问题
- bin/phpmig migrate
# 安装codeception(因为版本问题,放到gitlab ci上运行时安装)
# - composer config repo.packagist composer https://mirrors.aliyun.com/composer/
# - composer require "codeception/codeception:*" --ignore-platform-reqs
# install plugin
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/vip.git plugins/VipPlugin && app/console plugin:register Vip
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/chargecoin.git plugins/ChargeCoinPlugin && app/console plugin:register ChargeCoin
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/coupon.git plugins/CouponPlugin && app/console plugin:register Coupon
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/discount.git plugins/DiscountPlugin && app/console plugin:register Discount
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/moneycard.git plugins/MoneyCardPlugin && app/console plugin:register MoneyCard
- git clone -b develop --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusohoplugin/userimporter.git plugins/UserImporterPlugin && app/console plugin:register UserImporter
# 启动web服务
- app/console server:start
# 执行codeception的A PI 单元测试
- bin/codecept run api --bootstrap=bootstrap/bootstrap_codecept.php -vvv
# 执行newman的 API 单元测试
- npm install -g n
- n stable
- npm config set registry https://registry.npm.taobao.org
- npm install -g newman
- cd tests/api/Newman && newman run collection.json --iteration-data param.json --environment environment.json --verbose
only:
refs:
- /^release/.*$/
- develop
- feature/fix-api-test
- project/data-visualization
variables:
- $REPOSITORY == "main"
# 5.5 with js-test-unit:
# stage: test
# image: tianshengjie/codeage-node
# script:
# - npm install yarn
# - node_modules/yarn/bin/yarn config set registry https://registry.npm.taobao.org
# - node_modules/yarn/bin/yarn
# - npm run test:simple tests/Js/test/*
# only:
# - develop
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。