forked from edusoho/edusoho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
216 lines (204 loc) · 9.15 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#注意:定制项目请在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:
- 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
only:
variables:
- $REPOSITORY == "custom"
5.5 with php-cs-fixer only for main:
stage: test
image: codeages/ci-php:5.5-5
services:
- mysql:5.5
- redis:latest
script:
- 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
only:
variables:
- $REPOSITORY == "main"
7.0 For Non-Develop:
stage: test
image: codeages/ci-php:7.0-7
services:
- mysql:5.5
- redis:latest
script:
- bin/phpunit-diff
only:
refs:
- master
- release
- trigger
variables:
- $REPOSITORY == "main"
- $REPOSITORY == "custom"
7.0 For Develop:
stage: test
image: codeages/ci-php:7.0-7
services:
- mysql:5.5
- redis:latest
script:
- sed -i 's/memory_limit.*/memory_limit = 2000M/g' /etc/php/7.0/phpdbg/php.ini
- phpdbg -qrr bin/phpunit -c app/ --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/ --coverage-text --colors=never --testsuite UnitC2D --coverage-clover reports_tmp/phpunit.coverage.xml_2 --log-junit reports_tmp/phpunit.xml_2
- phpdbg -qrr bin/phpunit -c app/ --coverage-text --colors=never --testsuite UnitE2P --coverage-clover reports_tmp/phpunit.coverage.xml_3 --log-junit reports_tmp/phpunit.xml_3
- phpdbg -qrr bin/phpunit -c app/ --coverage-text --colors=never --testsuite UnitQ2T --coverage-clover reports_tmp/phpunit.coverage.xml_4 --log-junit reports_tmp/phpunit.xml_4
- phpdbg -qrr bin/phpunit -c app/ --coverage-text --colors=never --testsuite UnitU2Z --coverage-clover reports_tmp/phpunit.coverage.xml_5 --log-junit reports_tmp/phpunit.xml_5
- 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 5.5:
stage: test
image: ruanwenqin/ci-php:5.5-7
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://packagist.laravel-china.org
- 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
# 执行newman的 API 单元测试
- cd tests/api/Newman && newman run collection.json --iteration-data param.json --environment environment.json
only:
refs:
- develop
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