-
Notifications
You must be signed in to change notification settings - Fork 19
/
.gitlab-ci.yml
209 lines (181 loc) · 4.77 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# 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/.secret-detection.yml'
# Global --------------------------
# Use 17 (LTS) as base
image: eclipse-temurin:17-alpine
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
JAVA_TOOL_OPTIONS: ""
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
stages:
- check
- build
- test
- publish
before_script:
- GRADLE_USER_HOME="$(pwd)/.gradle"
- export GRADLE_USER_HOME
# stage: check ----------------------
.spotless_base:
stage: check
script: ./gradlew spotlessCheck
spotless_scheduled:
extends: .spotless_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
spotless_manual:
extends: .spotless_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
.license_check_base:
stage: check
script:
- ./license_checker.sh '*.java' | 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]
variables:
SECRET_DETECTION_HISTORIC_SCAN: "true"
before_script:
- echo "overriding default before_script..."
rules:
- if: $CI_MERGE_REQUEST_ID
# stage: build ----------------------
.build_base:
stage: build
script:
- ./gradlew assemble
artifacts:
paths:
- deepl-java/build/
build_scheduled:
extends: .build_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
build_manual:
extends: .build_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
# stage: test -------------------------
.test_base:
stage: test
extends: .test
variables:
KUBERNETES_MEMORY_LIMIT: 8Gi
parallel:
matrix:
- DOCKER_IMAGE: "eclipse-temurin:18-alpine"
- DOCKER_IMAGE: "openjdk:8-alpine"
USE_MOCK_SERVER: "use mock server"
- DOCKER_IMAGE: "eclipse-temurin:8-focal"
USE_MOCK_SERVER: "use mock server"
- DOCKER_IMAGE: "eclipse-temurin:11-alpine"
USE_MOCK_SERVER: "use mock server"
- DOCKER_IMAGE: "eclipse-temurin:17-alpine"
USE_MOCK_SERVER: "use mock server"
- DOCKER_IMAGE: "eclipse-temurin:19-alpine"
USE_MOCK_SERVER: "use mock server"
image: ${DOCKER_IMAGE}
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
- ./gradlew test
artifacts:
paths:
- deepl-java/build/reports/tests/test
reports:
junit:
- deepl-java/build/reports/tests/test/index.html
when: always
test_scheduled:
extends: .test_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
test_manual:
stage: test
extends: .test_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
.test_examples_base:
stage: test
extends: .test
variables:
MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
parallel:
matrix:
- DOCKER_IMAGE: "maven:3.9"
- DOCKER_IMAGE: "maven:3.8-openjdk-18-slim"
- DOCKER_IMAGE: "maven:3.8-openjdk-8-slim"
- DOCKER_IMAGE: "maven:3.9-sapmachine-17"
- DOCKER_IMAGE: "maven:3.9-eclipse-temurin-8"
- DOCKER_IMAGE: "maven:3.9-eclipse-temurin-21"
image: ${DOCKER_IMAGE}
script:
- cd examples/maven/deepl-test-app
- mvn install -B -PbuildProject -l mvn_build.log
- mvn verify -PrunIntegrationTests
artifacts:
paths:
- examples/maven/deepl-test-app/mvn_build.log
when: always
test_examples_scheduled:
extends: .test_examples_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
test_examples_manual:
extends: .test_examples_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
# stage: publish -------------------------
publish:
stage: publish
extends: .publish
dependencies:
- build_scheduled
- build_manual
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
script:
- ./gradlew publish
publish_manual:
stage: publish
extends: .publish
when: manual
dependencies:
- build_scheduled
- build_manual
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
script:
- ./gradlew publish