-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
executable file
·102 lines (85 loc) · 2.57 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
# Define pipeline stages
stages:
- lint
- codestyle
- tests
# Cache libraries in between jobs
cache:
- key:
files:
- composer.lock
paths:
- vendor/
# ENV variables
variables:
DOCKER_DRIVER: "overlay2"
XDEBUG_MODE: "coverage"
IMAGE: vshut/ci-cd-php8.2:1.7
# Fast Compression to speed up pipelines
FF_USE_FASTZIP: "true"
ARTIFACT_COMPRESSION_LEVEL: "fast"
CACHE_COMPRESSION_LEVEL: "fast"
# Composer
COMPOSER_DISCARD_CHANGES: "true"
# Shared
.php-version-cmd: &php-version-cmd
- php -v
.cp-env-cmd: &cp-env-cmd
- cp .env.test .env || cp .env.testing .env || cp .env.dist .env || cp .env.example .env || true
.composer-install-cmd: &composer-install-cmd
- composer install --no-cache --prefer-dist --no-interaction --no-progress --no-ansi --ignore-platform-req=ext-sockets
.create-artifacts-dir-cmd: &create-artifacts-dir-cmd
- mkdir -p .artifacts
# Scripts to run before each job
before_script:
- *create-artifacts-dir-cmd
- *php-version-cmd
- *cp-env-cmd
- *composer-install-cmd
.codestyle-job:
image: ${IMAGE}
stage: codestyle
php-cs-fixer:
extends: .codestyle-job
script:
- ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --dry-run --allow-risky=yes --using-cache=no -v
php-md:
extends: .codestyle-job
script:
- ./vendor/bin/phpmd src,tests text phpmd.ruleset.xml > .artifacts/phpmd-report.json
artifacts:
reports:
codequality: .artifacts/phpmd-report.json
php-stan:
extends: .codestyle-job
script:
- ./vendor/bin/phpstan analyse --memory-limit=512M --no-progress --error-format gitlab > .artifacts/phpstan-report.json
artifacts:
reports:
codequality: .artifacts/phpstan-report.json
.tests-job:
stage: tests
script:
- ./vendor/bin/phpunit --testdox --colors=never --coverage-xml .artifacts/.phpunit/phpunit-coverage-report.xml --coverage-html .artifacts/.phpunit/phpunit-coverage-report.html --coverage-text --log-junit .artifacts/.phpunit/report.xml --disallow-test-output --coverage-cobertura .artifacts/.phpunit/coverage.xml
- php check-code-coverage.php .artifacts/.phpunit/phpunit-coverage-report.xml/index.xml 100
coverage: /^\s*Lines:\s*\d+.\d+\%/
artifacts:
reports:
junit: .artifacts/.phpunit/report.xml
coverage_report:
coverage_format: cobertura
path: .artifacts/.phpunit/coverage.xml
unit:
extends: .tests-job
image: ${IMAGE}
.lint-job:
cache: []
before_script:
- ''
composer:
extends: .lint-job
image: ${IMAGE}
stage: lint
script:
- composer --version
- composer validate --no-check-all --strict