-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
198 lines (183 loc) · 5.38 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
image: $CI_REGISTRY/swe-database-team/gitlab-ci/whois-build:v0.0.6
variables:
MAVEN_OPTS: -Dmaven.repo.local=.m2/repository
PROJECT_NAME: "db-web-ui"
ARTIFACT_NAME: "db-web-ui"
ARTIFACT_DIR: "backend"
GROUP_ID: "net.ripe.whois"
CYPRESS_CACHE_FOLDER: "./cache/Cypress"
include:
- project: 'swe-database-team/gitlab-ci'
file: '/templates/release-template.yml'
- project: 'swe-database-team/gitlab-ci'
file: '/templates/deployment-template.yml'
stages:
- build
- test
- sonar
- release
- deploy
- browserstack
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- frontend/node_modules/
- frontend/package-lock.json
- .m2/repository
- frontend/cache/Cypress/
- frontend/src/assets/supportedBrowsers.js
- frontend/src/assets/blockedBrowsers.js
build:
tags:
- whois
stage: build
script:
- mvn $MAVEN_OPTS $MAVEN_CLI_OPTS clean package -DskipTests -Dversion=${CI_COMMIT_SHA}
artifacts:
paths:
- backend/target/db-web-ui*.jar
expire_in: 6 months
build-container:
tags:
- whois
stage: build
before_script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
script:
- >
docker build
--pull
--build-arg CI_COMMIT_SHA=$CI_COMMIT_SHA
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
.
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
backend:
tags:
- whois
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if: '$CI_COMMIT_REF_NAME == "master"'
when: always
- when: manual
allow_failure: true
script:
- cd backend && mvn test
artifacts:
paths:
- backend/target/
reports:
junit:
- backend/target/surefire-reports/TEST-*.xml
- backend/target/failsafe-reports/TEST-*.xml
expire_in: 1 month
e2e-cypress-chrome:
tags:
- whois
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if: '$CI_COMMIT_REF_NAME == "master"'
when: always
- when: manual
allow_failure: true
script:
- echo "127.0.0.1 localhost.ripe.net" >> /etc/hosts
- export DISPLAY=:20
- Xvfb :20 -screen 0 1920x1080x16 &
- cd frontend && npm run cypress:chrome
artifacts:
when: on_failure
paths:
- frontend/test/cypress/videos/**/*.mp4
- frontend/test/cypress/screenshots/**/*.png
expire_in: 1 month
e2e-cypress-firefox:
tags:
- whois
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if: '$CI_COMMIT_REF_NAME == "master"'
when: always
- when: manual
allow_failure: true
script:
- echo "127.0.0.1 localhost.ripe.net" >> /etc/hosts
- export DISPLAY=:20
- Xvfb :20 -screen 0 1920x1080x16 &
- cd frontend && npm run cypress:firefox
artifacts:
when: on_failure
paths:
- frontend/test/cypress/videos/**/*.mp4
- frontend/test/cypress/screenshots/**/*.png
expire_in: 1 month
frontend:
tags:
- whois
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if: '$CI_COMMIT_REF_NAME == "master"'
when: always
- when: manual
allow_failure: true
script:
- cd frontend && npm run test
artifacts:
paths:
- frontend/lcov.info
expire_in: 1 month
sonar:
stage: sonar
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the SonarQube analysis task
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if: '$CI_COMMIT_REF_NAME == "master"'
when: always
- when: manual
allow_failure: true
script:
- mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectVersion=$CI_COMMIT_SHORT_SHA -Dsonar.projectKey=db-web-ui -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONAR_TOKEN} -DskipTests
allow_failure: true
dependencies:
- backend
- frontend
release:
stage: release
only:
- tags
script:
- if [ "$CI_COMMIT_TAG" ]; then NEW_VERSION="$CI_COMMIT_SHORT_SHA"; else NEW_VERSION="$CI_COMMIT_SHORT_SHA-SNAPSHOT"; fi
- mvn versions:set -DnewVersion=$NEW_VERSION -Dartifact=$ARTIFACT_NAME
- mvn -DskipTests -DskipITs -Djar.finalName=$ARTIFACT_NAME-$NEW_VERSION.jar deploy
extends: .release_template
release-container:
stage: release
only:
- tags
before_script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
browserstack:
stage: browserstack
script:
- cd backend && mvn verify -Dbrowserstack_key=${BROWSERSTACK_KEY} -Dversion=${CI_COMMIT_SHORT_SHA} -Pselenium
needs:
- deploy_prod
only:
- tags
artifacts:
paths:
- backend/target/db-web-ui*.jar