-
Notifications
You must be signed in to change notification settings - Fork 20
/
.gitlab-ci.yml
104 lines (96 loc) · 4.76 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
image: registry.gitlab.com/run_as_root/quality_as_root/pipeline/magento2-community:2.3.4-php73
stages:
- prepare
- test
variables:
COMPOSER_CACHE_DIR: $CI_PROJECT_DIR/.composer
COMPOSER_BIN: 'composer'
ROBO_BIN: 'php ./build/tools/bin/robo'
# mysql config
MYSQL_ROOT_PASSWORD: root
# db settings
APP_DB_HOST: mysql
APP_DB_USER: root
APP_DB_PASS: $MYSQL_ROOT_PASSWORD
APP_DB1_NAME: db01
APP_DB2_NAME: db01_tests
before_script:
# install & start ssh-agent
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval $(ssh-agent -s)
# add ssh-key to ssh-agent
#- ssh-add <(echo "$DOCKER_PHP_PRIVATE_KEY")
# DEBUG - ssh -v -T -F .ssh/config <HOSTNAME> exit
.composer_cache: &composer_cache
cache:
key: ${CI_PROJECT_ID}
paths:
- .composer
.composer_cache_pull: &composer_cache_pull
cache:
policy: pull
key: ${CI_PROJECT_ID}
paths:
- .composer
prepare:
stage: prepare
<<: *composer_cache
script:
- $COMPOSER_BIN install --prefer-dist --working-dir=build/tools
tests:unit:
stage: test
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
<<: *composer_cache_pull
script:
- docker-php-ext-enable xdebug
# composer
- $COMPOSER_BIN selfupdate
- $COMPOSER_BIN install --prefer-dist --working-dir=build/tools
- $COMPOSER_BIN --working-dir="/application" config minimum-stability dev
- $COMPOSER_BIN --working-dir="/application" config prefer-stable true
- $COMPOSER_BIN --working-dir="/application" config repositories.m2-prometheus path $CI_PROJECT_DIR
- $COMPOSER_BIN --working-dir="/application" require "run-as-root/magento2-prometheus-exporter":"*"
- $COMPOSER_BIN --working-dir="/application" dump-autoload
- rm -Rf www && ln -s /application www
# run tests
- php www/vendor/bin/phpunit -c phpunit.xml.dist --debug --log-junit build/output/phpunit/junit.xml --coverage-clover build/output/phpunit/clover.xml --coverage-html build/output/phpunit/coverage-html --coverage-text --colors=never
- bash <(curl -s https://codecov.io/bash)
# static analysis
- mkdir -p build/output/phpstan build/output/phpmd build/output/phpcpd build/output/phpcs build/output/pdepend
- php build/tools/bin/phpmetrics --report-html=build/output/phpmetrics src
- php build/tools/bin/phpmd src html cleancode,codesize,controversial,design,naming,unusedcode --exclude=Test > build/output/phpmd/phpmd.html || true
- php build/tools/bin/phpcpd --regexps-exclude="#.*Test.*#" --log-pmd=build/output/phpcpd/phpcpd.xml src
- php build/tools/bin/pdepend --overview-pyramid=build/output/pdepend/overview-pyramid.svg --jdepend-chart=build/output/pdepend/jdepend-chart.svg src
artifacts:
paths:
- build/output/
expire_in: 7 days
tests:integration:
stage: test
services:
- mysql:5.7
<<: *composer_cache_pull
script:
- docker-php-ext-enable xdebug
# composer
- $COMPOSER_BIN selfupdate
- $COMPOSER_BIN install --prefer-dist --working-dir=build/tools
- $COMPOSER_BIN --working-dir="/application" config minimum-stability dev
- $COMPOSER_BIN --working-dir="/application" config prefer-stable true
- $COMPOSER_BIN --working-dir="/application" config repositories.m2-prometheus path $CI_PROJECT_DIR
- $COMPOSER_BIN --working-dir="/application" require "run-as-root/magento2-prometheus-exporter":"*"
- $COMPOSER_BIN --working-dir="/application" dump-autoload
- rm -Rf www && ln -s /application www
# prepare dbs
- mysqladmin --host=$APP_DB_HOST --user=$APP_DB_USER --password=$APP_DB_PASS create $APP_DB1_NAME
- mysqladmin --host=$APP_DB_HOST --user=$APP_DB_USER --password=$APP_DB_PASS create $APP_DB2_NAME
- php www/bin/magento setup:install --db-host=$APP_DB_HOST --db-name=$APP_DB1_NAME --db-password=$APP_DB_PASS --db-user=$APP_DB_USER [email protected] --admin-firstname=Admin --admin-lastname=Admin --admin-password=admin123 --admin-user=admin --backend-frontname=admin --base-url=http://rar.m2-prometheus.test --currency=EUR --language=en_US --session-save=files --timezone=Europe/Berlin --use-rewrites=1
- php www/bin/magento setup:upgrade
- cp build/tests/integration/install-config-mysql.php www/dev/tests/integration/etc/install-config-mysql.php
- cp www/dev/tests/integration/etc/config-global.php.dist www/dev/tests/integration/etc/config-global.php
# run tests
- cd www/dev/tests/integration && php $CI_PROJECT_DIR/www/vendor/bin/phpunit --debug -c $CI_PROJECT_DIR/phpunit-integration.xml.dist --log-junit $CI_PROJECT_DIR/build/output/phpunit-integration/junit.xml --coverage-clover $CI_PROJECT_DIR/build/output/phpunit-integration/clover.xml --coverage-html $CI_PROJECT_DIR/build/output/phpunit-integration/coverage-html --coverage-text
artifacts:
paths:
- build/output/
expire_in: 7 days