forked from DeepLcom/deepl-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
155 lines (135 loc) · 3.74 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
# Note: This GitLab CI configuration is used for internal testing, users can ignore it.
include:
- project: '${CI_PROJECT_NAMESPACE}/ci-libs-for-client-libraries'
file:
- '/${CI_PROJECT_NAME}/.gitlab-ci.yml'
- project: 'deepl/ops/ci-cd-infrastructure/gitlab-ci-lib'
file:
- '/templates/.buildkit.yml'
- '/templates/.secret-detection.yml'
variables:
DOCKER_IMAGE_PREFIX: ${HARBOR_REGISTRY}/${HARBOR_REGISTRY_PROJECT}/${CI_PROJECT_NAME}-build
COMPOSER_HOME: /.composer
# Global --------------------------
cache:
key:
files:
- composer.json
- composer.lock
paths:
- vendor/
- /.composer
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
stages:
- build
- check
- test
before_script:
# Install project dependencies using Composer
- php /composer.phar install
# stage: build ---------------------
build image:
stage: build
extends: .buildkit
variables:
DOCKER_IMAGE: ${DOCKER_IMAGE_PREFIX}_${PHP_VERSION}
BUILDKIT_IMAGE: ${DOCKER_IMAGE}:latest
BUILDKIT_EXTRA_ARGS: "--opt build-arg:PHP_VERSION=${PHP_VERSION}"
parallel:
matrix:
- PHP_VERSION: "8.3-alpine"
- PHP_VERSION: "8.2-alpine"
- PHP_VERSION: "8.1-alpine"
- PHP_VERSION: "8.0-alpine"
- PHP_VERSION: "7.4-alpine"
- PHP_VERSION: "7.3-alpine"
# stage: check ----------------------
.code_sniffer_base:
stage: check
image: ${DOCKER_IMAGE_PREFIX}_8.3-alpine
script:
- vendor/bin/phpcs
code_sniffer_scheduled:
extends: .code_sniffer_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
code_sniffer_manual:
extends: .code_sniffer_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
.license_check_base:
stage: check
image: ${DOCKER_IMAGE_PREFIX}_8.3-alpine
script:
- ./license_checker.sh '*.php' | tee license_check_output.txt
- '[ ! -s license_check_output.txt ]'
license_check_scheduled:
extends: .license_check_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
license_check_manual:
extends: .license_check_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
secret_detection:
extends: .secret-detection
stage: check
image: !reference [.secret-detection, image]
before_script:
- echo "overriding default before_script..."
rules:
- if: $CI_MERGE_REQUEST_ID
# stage: test ----------------------
.test_base:
stage: test
extends: .test
retry: 1
parallel:
matrix:
- PHP_VERSION: "8.3-alpine"
- PHP_VERSION: "8.3-alpine"
USE_MOCK_SERVER: "use mock server"
- PHP_VERSION: "8.2-alpine"
USE_MOCK_SERVER: "use mock server"
- PHP_VERSION: "8.1-alpine"
USE_MOCK_SERVER: "use mock server"
- PHP_VERSION: "8.0-alpine"
USE_MOCK_SERVER: "use mock server"
- PHP_VERSION: "7.4-alpine"
USE_MOCK_SERVER: "use mock server"
- PHP_VERSION: "7.3-alpine"
image: ${DOCKER_IMAGE_PREFIX}_${PHP_VERSION}
script:
- >
if [[ ! -z "${USE_MOCK_SERVER}" ]]; then
echo "Using mock server"
export DEEPL_SERVER_URL=http://deepl-mock:3000
export DEEPL_MOCK_SERVER_PORT=3000
export DEEPL_PROXY_URL=http://deepl-mock:3001
export DEEPL_MOCK_PROXY_SERVER_PORT=3001
fi
- echo $CI_PIPELINE_ID
- vendor/bin/phpunit --random-order-seed $CI_PIPELINE_ID
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: reports/cobertura.xml
junit:
- reports/junit.xml
when: always
test_scheduled:
extends: .test_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
test_manual:
extends: .test_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"