This repository has been archived by the owner on Feb 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
214 lines (200 loc) · 4.92 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
210
211
212
213
214
# This file was obtained from https://gitlab.com/mdhtr/gitlab-pages-swagger-ui/raw/master/.gitlab-ci.yml
# and then modified
stages:
- test
- build-documentation
- build
- documentation
include:
- template: Code-Quality.gitlab-ci.yml
# specify the location of the Open API Specification files within your project
# and the filename of the specification that you would like to display by default
variables:
DOCS_FOLDER: api-specification
SPEC_TO_DISPLAY: openapi.yml
# Use IBM OpenAPI validator to check for any errors in API specification
validate-api-specification:
image: node:alpine
stage: test
before_script:
- cd api-specification
- npm install --dev-only
script:
- npm run validate
tags:
- trdocker
test_api-client:
image: node:13.10-alpine3.10
script:
- cd js-api-client
# install dependencies
- npm install
- npm install --dev-only
# build
- npm run build
# install code coverage dependencies
- npm install -g nyc codecov
# run tests with code coverage
- nyc --reporter=lcov npm test && codecov
tags:
- trdocker
code_quality:
# disable cache for this job
cache: {}
# for some reason code quality only works on gitlab shared runners
only:
- merge_requests
- develop
- master
tags:
- shared
stage: test
api_client_doc:
stage: build-documentation
image:
name: squidfunk/mkdocs-material:4.6.1
entrypoint: [""]
before_script:
- apk add make
script:
- cd js-api-client
- make doc
- mv site ../api-client
only:
- master
artifacts:
paths:
- api-client
tags:
- trdocker
api_client_doc_pdf:
stage: build-documentation
image:
name: pandoc/latex
entrypoint: [""]
before_script:
- apk add make
script:
- cd js-api-client
- make pdf-doc
only:
- master
artifacts:
paths:
- "*.pdf"
tags:
- trdocker
# publishes all files from the $DOCS_FOLDER together with the static version of SwaggerUI
# sets the specification file named in $SPEC_TO_DISPLAY to be displayed by default
api_doc:
stage: build-documentation
image: node:alpine
script:
- cd api-specification
- npm install --dev-only
- mkdir api
- cp -rp node_modules/swagger-ui-dist/* api
- cp -rp $DOCS_FOLDER/* api
- sed -i "s#https://petstore\.swagger\.io/v2/swagger\.json#$SPEC_TO_DISPLAY#g" api/index.html
- mv api ../api-doc
artifacts:
paths:
- api-doc
only:
- master
tags:
- trdocker
# template service build job
.build_service:
stage: build
image: docker:stable
# disable cache for this job
cache: {}
before_script:
- apk add make
- apk add git
- make docker-login
script:
- make build
- make tag
- make deploy
tags:
- trdocker
api:
extends: .build_service
# name of service to build is the name of the job
variables:
SERVICE: $CI_JOB_NAME
# only build on changes to api
only:
changes:
- api/**/*
- .gitlab-ci/yml
- Makefile
# api-windows:
# stage: build
# image: mcr.microsoft.com/windows:1909
# # disable cache for this job
# cache: {}
# before_script:
# - \@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
# - choco install make docker -y
# - make docker-login
# script:
# - make build
# - make tag
# - make deploy
# # name of service to build is the name of the job
# variables:
# SERVICE: api
# DOCKERFILE_PREFIX: windows.
# # only build on changes to api
# only:
# changes:
# - api/**/*
# - .gitlab-ci/yml
# - Makefile
# tags:
# - shared-windows
frontend:
extends: .build_service
# name of service to build is the name of the job
variables:
SERVICE: $CI_JOB_NAME
# only build on changes to frontend
only:
changes:
- frontend/**/*
- .gitlab-ci/yml
- Makefile
script:
- make build
- make tag
- make deploy
- VERSION=test-mode-1 BUILD_ARGS="--build-arg TEST_MODE=1" make build
- VERSION=test-mode-1 make tag
- VERSION=test-mode-1 make deploy
- VERSION=test-mode-2 BUILD_ARGS="--build-arg TEST_MODE=2" make build
- VERSION=test-mode-2 make tag
- VERSION=test-mode-2 make deploy
# publishes all files from the $DOCS_FOLDER together with the static version of SwaggerUI
# sets the specification file named in $SPEC_TO_DISPLAY to be displayed by default
pages:
image: alpine
stage: documentation
script:
- mkdir public
- mv ./docs/index.html public
# copy codeclimate report, allow failure
# - cp codeclimate.html public
- cp -r docs public
- cp README.md public
- cp -r api-client public/
- mv api-doc public/api
artifacts:
paths:
- public
only:
- master
tags:
- trdocker