-
Notifications
You must be signed in to change notification settings - Fork 25
/
.gitlab-ci.yml
151 lines (131 loc) · 3.56 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
# 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 --------------------------
image: mcr.microsoft.com/dotnet/sdk:5.0-alpine
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
variables:
DOTNET_CLI_HOME: ${CI_PROJECT_DIR}
XDG_DATA_HOME: ${CI_PROJECT_DIR}
# stage: check ----------------------
.license_check_base:
stage: check
script:
- ./license_checker.sh '*.cs' | 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: build ----------------------
build:
stage: build
parallel:
matrix:
- CONFIGURATION:
- Debug
- Release
script:
- dotnet build --configuration $CONFIGURATION
artifacts:
paths:
- DeepL/bin/
- DeepL/obj/
- DeepLTests/bin/
- DeepLTests/obj/
package:
stage: build
needs: ["build"]
script:
- dotnet pack --no-restore --configuration Release -o package/Release
artifacts:
paths:
- package/
# stage: test -------------------------
.test_base:
stage: test
extends: .test
dependencies:
- build
parallel:
matrix:
- DOCKER_IMAGE: "mcr.microsoft.com/dotnet/sdk:5.0-alpine"
FRAMEWORK: "net5.0"
CONFIGURATION: "Release"
- DOCKER_IMAGE: "mcr.microsoft.com/dotnet/sdk:3.1-alpine"
FRAMEWORK: "netcoreapp3.1"
CONFIGURATION:
- Debug
- Release
USE_MOCK_SERVER: "use mock server"
- DOCKER_IMAGE: "mcr.microsoft.com/dotnet/sdk:5.0-alpine"
FRAMEWORK: "net5.0"
CONFIGURATION:
- Debug
- Release
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
- dotnet test
--configuration $CONFIGURATION
--framework $FRAMEWORK
--logger:"junit;LogFilePath=..\artifacts\{assembly}-test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose"
artifacts:
reports:
junit:
- artifacts/*test-result.xml
test_scheduled:
extends: .test_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2
test_manual:
extends: .test_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
# stage: publish -------------------------
nuget upload:
stage: publish
extends: .publish
dependencies:
- package
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
script:
- dotnet nuget push package/Release/DeepL.net.*.nupkg --api-key $NUGET_API_KEY
--source https://api.nuget.org/v3/index.json --timeout 30