-
Notifications
You must be signed in to change notification settings - Fork 0
/
not-ready.gitlab-ci.yml
executable file
·230 lines (219 loc) · 6.8 KB
/
not-ready.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
stages:
- build
- test
- development
# The shared template for Drupal8CI builds and tests.
.drupal8ci_template: &drupal8ci_template
except:
- master
image: juampynr/drupal8ci:latest
services:
- mariadb:10.3
- selenium/standalone-chrome-debug:3.7.1-beryllium
before_script:
- mkdir -p /var/www/html
- ln -s $CI_PROJECT_DIR/docroot /var/www/html/web
- apache2-foreground&
variables:
#CI_DEBUG_TRACE: 1
MYSQL_ALLOW_EMPTY_PASSWORD: 1
DB_URL: "mysql://root@mariadb/drupal8"
SIMPLETEST_DB: "mysql://root@mariadb/drupal8"
SIMPLETEST_BASE_URL: "http://localhost"
BROWSERTEST_OUTPUT_DIRECTORY: "$CI_PROJECT_DIR/web/sites/simpletest"
BEHAT_PARAMS: >
{
"extensions" : {
"Bex\\Behat\\ScreenshotExtension" : {
"image_drivers" : {
"local" : { "screenshot_directory" : "$CI_PROJECT_DIR/artifacts/screenshots" }
}
}
}
}
#deploy
deploy_staging: &drupal8ci_staging
image: juampynr/drupal8ci:latest
stage: development
dependencies:
- drupal8ci:build
script:
#- shopt -s huponexit
- echo "Deploy to development server"
- composer install
- rm -rf .git
#- ssh-add <(echo "$STAGING_KEY")
#- ssh -p22 server_user@server_host " <<EOF
- cd /var/www/html/web/
#- drush sql:dump --result-file=../../backups/${CI_BUILD_ID}.sql"
- mkdir /var/www/html/_tmp
- drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite
#- EOF
#- scp -P22 -r ./* server_user@server_host:/var/www/html/_tmp
#- ssh -p22 server_user@server_host " <<EOF
#- mv /var/www/html/ /var/www/html/old
#- mv /var/www/html/_tmp /var/www/html/
#- mv /var/www/html/old/sites/default/settings.env.php /var/www/html/my-drupal-site/sites/default/settings.env.php"
#- rm -rf /var/www/html/old
#- rm -rf /var/www/html/_tmp
#- cd /var/www/html/my-drupal-site/web/
- drush cim -y
- drush updb -y
- EOF
environment:
name: development
url: https://development.site.production-preview.com/
before_script:
- shopt -s huponexit
- apt-get update
#install additional gd extension, that is required by Drupal
- apt-get install libpng-dev -y
- docker-php-ext-install gd
#install composer
- apt-get install zip unzip -y
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php
- php -r "unlink('composer-setup.php');"
#install composer package to run parallel tasks
- composer -n global require -n "hirak/prestissimo"
- composer -n global require -n "drush/drush"
- mkdir -p /var/www/html
- ln -s $CI_PROJECT_DIR/docroot /var/www/html/web
- apache2-foreground&
#install ssh agent
#- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
#- mkdir -p ~/.ssh
#- eval $(ssh-agent -s)
#- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
services:
- mariadb:10.3
- selenium/standalone-chrome-debug:3.7.1-beryllium
artifacts:
paths:
- vendor
- web
only:
- master
variables:
CI_DEBUG_TRACE: 1
MYSQL_ALLOW_EMPTY_PASSWORD: 1
DB_URL: "mysql://root@mariadb/drupal8"
SIMPLETEST_DB: "mysql://root@mariadb/drupal8"
SIMPLETEST_BASE_URL: "http://localhost"
BROWSERTEST_OUTPUT_DIRECTORY: "$CI_PROJECT_DIR/web/sites/simpletest"
BEHAT_PARAMS: >
{
"extensions" : {
"Bex\\Behat\\ScreenshotExtension" : {
"image_drivers" : {
"local" : { "screenshot_directory" : "$CI_PROJECT_DIR/artifacts/screenshots" }
}
}
}
}
# The shared template for Drupal8CI tests.
.drupal8ci_test_template: &drupal8ci_test_template
<<: *drupal8ci_template
stage: test
dependencies:
- drupal8ci:build
environment:
name: test
url: https://test.site.production-preview.com/
## Build the testing environment.
drupal8ci:build:
<<: *drupal8ci_template
stage: build
script:
- composer install
- robo install:dependencies
services:
- mariadb:10.3
- selenium/standalone-chrome-debug:3.7.1-beryllium
artifacts:
paths:
- vendor
- web
except:
- master
## Job to run Unit and Kernel tests.
drupal8ci:unit_kernel_tests:
<<: *drupal8ci_test_template
script:
- robo setup:drupal || true
- cp .gitlab-ci/phpunit.xml web/core/
- mkdir -p artifacts/phpunit
- chmod -R 777 artifacts
- cd web
- sudo -E -u www-data
../vendor/bin/phpunit -c core
--debug --verbose --log-junit
../artifacts/phpunit/phpunit.xml
modules/custom
artifacts:
paths:
- artifacts/phpunit
## Job to run the update path and Behat tests.
# This doesn't currently work because of the following GitLab issue:
# https://gitlab.com/gitlab-org/gitlab-selenium-server/issues/1
#drupal8ci:behat_tests:
# <<: *drupal8ci_test_template
# script:
# - robo setup:drupal || true
# - cd web
# # For a quick start, set the following environment variable to a URL that contains
# # a database dump. Alternativelly, give CircleCI access to your development environment
# # and use Drush site aliases to run `drush sql-sync`.
# - wget -O dump.sql $DB_DUMP_URL
# - ../vendor/bin/drush sql-cli < dump.sql
# - ../vendor/bin/drush updatedb -y -v
# - ../vendor/bin/drush config-import -y -v
# - cd $CI_PROJECT_DIR
# - curl http://localhost
# - cp .gitlab-ci/behat.yml tests/behat.yml
# - chown -R www-data:www-data web/sites/default/files
# - vendor/bin/behat --verbose -c tests/behat.yml
# artifacts:
# paths:
# - artifacts/behat
# - artifacts/screenshots
## Job to check coding standards.
drupal8ci:code_sniffer:
<<: *drupal8ci_test_template
script:
- vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer
- mkdir -p artifacts/phpcs
- vendor/bin/phpcs
--standard=Drupal
--report=junit
--report-junit=artifacts/phpcs/phpcs.xml
web/modules/custom
- vendor/bin/phpcs
--standard=DrupalPractice
--report=junit
--report-junit=artifacts/phpcs/phpcs.xml
web/modules/custom
artifacts:
paths:
- artifacts/phpcs/phpcs.xml
## Job to check test coverage.
drupal8ci:code_coverage:
<<: *drupal8ci_test_template
script:
- robo setup:drupal || true
- cp .gitlab-ci/phpunit.xml web/core/
- mkdir -p artifacts/coverage-xml
- mkdir -p artifacts/coverage-html
- chmod -R 777 artifacts
- cd web
- timeout 60m sudo -E -u www-data
../vendor/bin/phpunit
--verbose --debug
-c core
--coverage-xml ../artifacts/coverage-xml
--coverage-html ../artifacts/coverage-html
--testsuite nonfunctional
modules/custom
artifacts:
paths:
- artifacts