-
Notifications
You must be signed in to change notification settings - Fork 12
/
.gitlab-ci.yml
104 lines (103 loc) · 4.52 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
include:
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml
services:
- docker:20.10.16-dind
stages:
- test
- lint
- base
variables:
MYSQL_DATABASE: matomo
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: matomo
MYSQL_PASSWORD: matomo
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
sast:
stage: test
phpunit:
rules:
- if: $CI_COMMIT_BRANCH
stage: test
image: docker:20.10.16
allow_failure: true
variables:
MYSQL_DATABASE: matomo
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: matomo
MYSQL_PASSWORD: matomo
IMAGE: digitalist/matomo:5.x-pcov
before_script:
- apk update && apk add git coreutils iputils docker-compose
- mkdir -p /root/.docker
- cat $DOCKER_AUTH_CONFIG > /root/.docker/config.json
script:
- docker-compose up -d --quiet-pull
- sleep 20
- docker-compose exec matomo bash -c "php --version"
- docker-compose exec --user=root matomo bash -c "cd plugins/ExtraTools && composer install --no-interaction --no-progress"
- docker-compose exec matomo ./console matomo:install --install-file=/var/www/html/config/install.json --force
- docker-compose exec matomo ./console site:add --name=Foo --urls=https://foo.bar
- docker-compose exec matomo touch /var/www/html/.gitmodules
- docker-compose exec matomo ./console development:enable
- docker-compose exec matomo ./console config:set --section=tests --key=http_host --value=web
- docker-compose exec matomo ./console config:set --section=tests --key=request_uri --value=/
- docker-compose exec matomo ./console config:set --section=database_tests --key=host --value=db
- docker-compose exec matomo ./console config:set --section=database_tests --key=username --value=root
- docker-compose exec matomo ./console config:set --section=database_tests --key=password --value=root
- docker-compose exec matomo ./console config:set --section=database_tests --key=dbname --value=matomo_test
- docker-compose exec matomo ./console config:set --section=database_tests --key=tables_prefix --value=""
- docker-compose exec matomo ./console plugin:activate ExtraTools
- docker-compose exec matomo /var/www/html/plugins/ExtraTools/vendor/bin/phpunit -c plugins/ExtraTools/tests/phpunit.xml --coverage-text --testdox --log-junit report.xml --coverage-cobertura phpunit-coverage.xml || true
- mkdir -p test
- mkdir -p coverage
- docker cp matomo:/var/www/html/report.xml test/report.xml
- docker cp matomo:/var/www/html/phpunit-coverage.xml test/phpunit-coverage.xml
- docker-compose down
artifacts:
when: always
reports:
junit: test/report.xml
coverage_report:
coverage_format: cobertura
path: test/phpunit-coverage.xml
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
phpstan:
rules:
- if: $CI_COMMIT_BRANCH
allow_failure: true
stage: lint
image: docker:20.10.16
variables:
MYSQL_DATABASE: matomo
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: matomo
MYSQL_PASSWORD: matomo
IMAGE: digitalist/matomo:5.x-pcov
before_script:
- apk update && apk add git coreutils iputils docker-compose
- mkdir -p /root/.docker
- cat $DOCKER_AUTH_CONFIG > /root/.docker/config.json
script:
- docker-compose up -d --quiet-pull
- sleep 2
- docker-compose exec matomo bash -c "cd plugins/ExtraTools && composer install --no-interaction --no-progress"
- docker-compose exec matomo bash -c "/var/www/html/plugins/ExtraTools/vendor/bin/phpstan analyze --error-format=junit -c /var/www/html/plugins/ExtraTools/tests/phpstan.neon --no-progress --level=1 plugins/ExtraTools/ > phpstan80.xml" || true
- docker-compose exec matomo bash -c "/var/www/html/plugins/ExtraTools/vendor/bin/phpstan analyze --error-format=gitlab -c /var/www/html/plugins/ExtraTools/tests/phpstan.neon --no-progress --level=1 plugins/ExtraTools/ > phpstan-report.json" || true
- docker-compose exec matomo bash -c "/var/www/html/plugins/ExtraTools/vendor/bin/phpstan analyze -c /var/www/html/plugins/ExtraTools/tests/phpstan.neon --level=0 plugins/ExtraTools/" || true
- docker cp matomo:/var/www/html/phpstan80.xml phpstan80.xml
- docker cp matomo:/var/www/html/phpstan-report.json phpstan-report.json
- docker-compose down
artifacts:
when: always
paths:
- phpstan80.xml
- phpstan-report.json
reports:
codequality: "./phpstan-report.json"
junit:
- phpstan80.xml