-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.gitlab-ci.yml
130 lines (118 loc) · 2.63 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
stages:
- docker
- build
- lint
- test
# ========= Anchors (Partials) =========
.php_base: &php_base
image: $CI_REGISTRY_IMAGE/php:8.3
tags:
- docker
.test_base: &test_base
stage: test
before_script:
- rm -rf vendor
- php -d memory_limit=-1 /usr/bin/composer require --dev phpunit/phpunit:^$PHPUNIT_VERSION
- php -d memory_limit=-1 /usr/bin/composer install
script:
- composer du
- composer test:coverage
artifacts:
when: on_failure
expire_in: 4 hours
paths:
- storage/logs/
reports:
junit: coverage/phpunit.junit.xml
coverage_report:
coverage_format: cobertura
path: coverage/cobertura.xml
coverage: /^\s*Lines:\s*\d+.\d+\%/
tags:
- docker
.docker_base: &docker_base
stage: docker
image: docker:20.10.8-alpine3.14
services:
- docker:20.10.8-dind-alpine3.14
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CONTAINER_IMAGE:$PHP_VERSION || true
- docker build --cache-from $CONTAINER_IMAGE:$PHP_VERSION --build-arg PHP_IMAGE=php:$PHP_VERSION -t $CONTAINER_IMAGE:$PHP_VERSION ./.docker/$SERVICE_NAME
- docker push $CONTAINER_IMAGE:$PHP_VERSION
when: manual
tags:
- docker
.docker_variables: &docker_variables
CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/$SERVICE_NAME
DOCKER_DRIVER: devicemapper
DOCKER_TLS_CERTDIR: ''
GIT_STRATEGY: fetch
GIT_DEPTH: "1"
# ======================
# Docker jobs
# ======================
docker:php81:
<<: *docker_base
variables:
SERVICE_NAME: php
PHP_VERSION: "8.1"
<<: *docker_variables
docker:php82:
<<: *docker_base
variables:
SERVICE_NAME: php
PHP_VERSION: "8.2"
<<: *docker_variables
docker:php83:
<<: *docker_base
variables:
SERVICE_NAME: php
PHP_VERSION: "8.3"
<<: *docker_variables
# ======================
# Build jobs
# ======================
build:php:
<<: *php_base
stage: build
script:
- composer install
artifacts:
paths:
- vendor/
expire_in: 2 hours
cache:
paths:
- vendor
key: php
# ======================
# Lint jobs
# ======================
lint:php:
<<: *php_base
stage: lint
script:
- composer phpcs
dependencies:
- build:php
allow_failure: true
# ======================
# Test jobs
# ======================
test:php81:
<<: *test_base
image: $CI_REGISTRY_IMAGE/php:8.1
variables:
PHPUNIT_VERSION: "9.5"
test:php82:
<<: *test_base
image: $CI_REGISTRY_IMAGE/php:8.2
variables:
PHPUNIT_VERSION: "9.5"
test:php83:
<<: *test_base
image: $CI_REGISTRY_IMAGE/php:8.3
variables:
PHPUNIT_VERSION: "9.5"