115 Star 368 Fork 165

EduSoho / EduSoho

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
.gitlab-ci.yml 14.98 KB
一键复制 编辑 原始数据 按行查看 历史
zhangyao 提交于 2022-01-24 10:15 . feat: #10000 22.1.4
#注意:定制项目请在GitlabCI 设置里面添加变量 REPOSITORY 为 "custom" ;设置非法值或者未设置都会报警
stages:
- automation
- test
- build
variables:
MYSQL_DATABASE: edusoho_test
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
FROM_VERSION: 22.1.3
VERSION: 22.1.4
H5VERSION: release/22.1.4
before_script:
- cp app/config/parameters.yml.dist app/config/parameters.yml
- cp app/config/parameters.yml.dist app/config/parameters_test.yml
- cp app/config/session_redis.yml.dist app/config/session_redis.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: dockerhub.codeages.work/codeages-proxy/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"
7.1 with php-cs-fixer only for custom:
stage: test
image: dockerhub.codeages.work/codeages-proxy/codeages/ci-php71:6
services:
- name: dockerhub.codeages.work/library-proxy/library/mysql:5.5
alias: mysql
- name: dockerhub.codeages.work/library-proxy/library/redis:latest
alias: redis
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
interruptible: true
only:
variables:
- $REPOSITORY == "custom"
7.1 For main:
stage: test
image: dockerhub.codeages.work/codeages-proxy/codeages/ci-php71
services:
- name: dockerhub.codeages.work/library-proxy/library/mysql:5.5
alias: mysql
- name: dockerhub.codeages.work/library-proxy/library/redis:latest
alias: redis
script:
- 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`
- bin/phpunit-diff
interruptible: true
only:
refs:
- master
- develop
- /^release/.*$/
- trigger
- merge_requests
variables:
- $REPOSITORY == "main"
- $REPOSITORY == "custom"
7.1 For main with MySQL80:
stage: test
image: dockerhub.codeages.work/codeages-proxy/codeages/ci-php71
services:
- name: dockerhub.codeages.work/library-proxy/library/mysql:8.0
alias: mysql
command: ["--default-authentication-plugin=mysql_native_password"]
- name: dockerhub.codeages.work/library-proxy/library/redis:latest
alias: redis
script:
- bin/phpunit-diff
interruptible: true
only:
refs:
- /^release/.*$/
- /^project/.*$/
- develop
- master
variables:
- $REPOSITORY == "main"
#7.4 For main with MySQL80:
# stage: test
# image: dockerhub.codeages.work/codeages-proxy/codeages/ci-php74
# services:
# - name: dockerhub.codeages.work/library-proxy/library/mysql:8.0
# alias: mysql
# command: ["--default-authentication-plugin=mysql_native_password"]
# - name: dockerhub.codeages.work/library-proxy/library/redis:latest
# alias: redis
# script:
# - bin/phpunit-diff
# interruptible: true
# only:
# refs:
# - /^release/.*$/
# - /^project/.*$/
# - develop
# - master
# variables:
# - $REPOSITORY == "main"
7.1 Coverage For Main:
stage: test
image: dockerhub.codeages.work/codeages-proxy/codeages/ci-php71
services:
- name: dockerhub.codeages.work/library-proxy/library/mysql:5.5
alias: mysql
- name: dockerhub.codeages.work/library-proxy/library/redis:latest
alias: redis
script:
- sed -i 's/memory_limit.*/memory_limit = 4000M/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
interruptible: true
only:
refs:
- develop
- master
variables:
- $REPOSITORY == "main"
- $REPOSITORY == "custom"
7.1 Coverage For project:
stage: test
image: dockerhub.codeages.work/codeages-proxy/codeages/ci-php71
services:
- name: dockerhub.codeages.work/library-proxy/library/mysql:5.5
alias: mysql
- name: dockerhub.codeages.work/library-proxy/library/redis:latest
alias: redis
script:
- sed -i 's/memory_limit.*/memory_limit = 4000M/g' /etc/php/7.1/phpdbg/php.ini
- sed -i "s/sonar.projectKey=.*/sonar.projectKey=$SONAR_PROJECT_KEY-$CI_COMMIT_REF_SLUG/g" sonar-project.properties
- cat 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
interruptible: true
only:
refs:
- /^project/.*$/
variables:
- $REPOSITORY == "main"
- $REPOSITORY == "custom"
#AT With Java And Selenium:
# stage: automation
# image: ruanwenqin/ci:php5.5-jdk8
#
# services:
# - name: dockerhub.codeages.work/library-proxy/library/mysql:5.7
# alias: mysql
# - 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
# interruptible: true
# only:
# refs:
# - schedules
# - triggers
# - web
# - api
# variables:
# - $REPOSITORY == "main"
Api Test With 7.1:
stage: test
image: dockerhub.codeages.work/codeages-proxy/codeages/ci-php71
services:
- name: dockerhub.codeages.work/library-proxy/library/mysql:5.5
alias: mysql
- name: dockerhub.codeages.work/library-proxy/library/redis:latest
alias: redis
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
interruptible: true
only:
refs:
- test
variables:
- $REPOSITORY == "main"
Build upgrade package:
stage: build
image: dockerhub.codeages.work/codeages-proxy/codeages/ci-php71
script:
- git checkout v${FROM_VERSION}
- git checkout release/${VERSION}
- git clone -b master --single-branch http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusoho/upgradescripts.git scripts
- git clone http://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HOST}/edusoho/edusoho-h5.git
- npm install -g n
- n 12.18.1
- node -v
- yarn config set registry https://registry.npm.taobao.org
- rm -rf app/caches
- cd edusoho-h5
- git checkout ${H5VERSION}
- git pull
- cp build/env.js.example build/env.js
- rm -rf node_modules
- rm -rf dist
- rm -rf ./../web/h5/*
- yarn install
- npm run build
- rm -rf node_modules
- cp -rf ./dist/* ./../web/h5/
- cd ../
- rm -rf app/caches node_modules
- yarn
- npm run compile
# copy seajs静态文件到web目录下
- app/console assets:install
# 生成js语言包
- app/console trans:dump-js
- git config --global user.email "gitlab@example.com"
- git config --global user.name "gitlab"
- git add web
- ls web/h5/static/css
- "git commit -m 'feat: #10000 compile'"
- git diff .
- app/console build:upgrade-package ${FROM_VERSION} ${VERSION}
artifacts:
paths:
- build/
expire_in: 30 mins
only:
- /^package\/.*$/
PHP
1
https://gitee.com/EduSoho/EduSoho.git
git@gitee.com:EduSoho/EduSoho.git
EduSoho
EduSoho
EduSoho
master

搜索帮助