-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
164 lines (151 loc) · 3.89 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
# set the default docker image
image: registry.gitlab.com/tjvb/phpimages:php80
stages:
- prepare # prepare the cache
- check # check the codestyles
- test
- report
# This is a default before script that is used for all jobs that need to have the composer scripts installed
.set_exclude_group: &set_exclude_group
before_script:
- EXCLUDE_GROUP=""
- |
if [ -z "$CI_COMMIT_BRANCH" ]; then
EXCLUDE_GROUP="--exclude-group=branch-needed"
else
git checkout $CI_COMMIT_BRANCH
fi
prepare_cache:
stage: prepare
script:
- composer validate
- composer install
# we use this artifact for all the jobs
artifacts:
name: "vendor"
paths:
- vendor/*
phpstan:
stage: check
script:
# check for phpstan errors
- php -d memory_limit=500M vendor/bin/phpstan analyse --error-format=gitlab | tee phpstan.json
dependencies:
- prepare_cache
needs:
- prepare_cache
artifacts:
paths:
- phpstan.json
reports:
codequality: phpstan.json
when: always
lint:
stage: check
script:
# lint recursive
- find src/ -type f -name '*.php' -exec php -l {} \; | (! grep -v "No syntax errors detected" )
dependencies: []
phpmd:
stage: check
script:
- composer phpmd
dependencies:
- prepare_cache
needs:
- prepare_cache
code-style:
stage: check
script:
- composer cs
dependencies:
- prepare_cache
needs:
- prepare_cache
# We check the content with vale
vale:
image:
name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/jdkato/vale
entrypoint: [""]
stage: check
script:
- /bin/vale --config=tools/vale/.vale.ini docs README.md CONTRIBUTING.md
needs: []
dependencies: []
infection:
stage: test
image: registry.gitlab.com/tjvb/phpimages:php83
script:
- composer update
- vendor/bin/phpunit --migrate-configuration || true
- composer infection
dependencies:
- prepare_cache
needs:
- prepare_cache
artifacts:
paths:
- build/infection/
reports:
codequality: build/infection/code-climate-gitlab.json
when: always
test_lowest:
stage: test
<<: *set_exclude_group
script:
- git checkout $CI_COMMIT_BRANCH
# Install composer
- rm -f composer.lock
- composer update --prefer-lowest
- vendor/bin/phpunit --coverage-text --colors=never --log-junit=phpunitresult/junit.xml --testdox-html=phpunitresult/testdox.html $EXCLUDE_GROUP
artifacts:
paths:
- phpunitresult
reports:
junit: phpunitresult/junit.xml
dependencies:
- prepare_cache
needs:
- prepare_cache
test:
parallel:
matrix:
- PHP:
- 80
- 81
- 82
- 83
- 84
image: registry.gitlab.com/tjvb/phpimages:php$PHP
<<: *set_exclude_group
script:
- composer update
- vendor/bin/phpunit --migrate-configuration || true
- XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --colors=never --coverage-cobertura=phpunitresult/cobertura-coverage.xml --log-junit=phpunitresult/junit.xml $EXCLUDE_GROUP
- sed -i 's~ filename="~ filename="src/~' phpunitresult/cobertura-coverage.xml
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
artifacts:
reports:
junit: phpunitresult/junit.xml
coverage_report:
coverage_format: cobertura
path: phpunitresult/cobertura-coverage.xml
dependencies:
- prepare_cache
needs:
- prepare_cache
combine_docs:
stage: report
script:
- cp README.md docs/README.md
- cp CHANGELOG.md docs/CHANGELOG.md
- cp CONTRIBUTING.md docs/CONTRIBUTING.md
- cp LICENSE.md docs/LICENSE.md
- cp phpunitresult/testdox.html docs/testdox.html
artifacts:
paths:
- docs/
dependencies:
- test_lowest
needs:
- test_lowest