-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
175 lines (165 loc) · 3.47 KB
/
.gitlab-ci.yml
File metadata and controls
175 lines (165 loc) · 3.47 KB
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
default:
image: node:16
stages:
- install
- test
- build
- deploy
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
.npm-client:
cache:
- &node-modules-cache-client
key:
files:
- client/package-lock.json
paths:
- client/node_modules/
policy: pull
before_script:
- cd client
.npm-server:
cache:
- &node-modules-cache-server
key:
files:
- server/package-lock.json
paths:
- server/node_modules/
policy: pull
before_script:
- cd server
.install:
stage: install
script:
- npm ci --cache .npm --prefer-offline
install-client:
extends:
- .npm-client
- .install
cache:
- <<: *node-modules-cache-client
policy: pull-push
- key: $CI_JOB_NAME
paths:
- client/.npm/
install-server:
extends:
- .npm-server
- .install
cache:
- <<: *node-modules-cache-server
policy: pull-push
- key: $CI_JOB_NAME
paths:
- server/.npm/
.format:
stage: test
script:
- npm run format:check
format-client:
extends:
- .npm-client
- .format
needs: [install-client]
format-server:
extends:
- .npm-server
- .format
needs: [install-server]
.lint:
stage: test
script:
- npm run lint
lint-client:
extends:
- .npm-client
- .lint
needs: [install-client]
lint-server:
extends:
- .npm-server
- .lint
needs: [install-server]
test-client:
extends: .npm-client
stage: test
image: timbru31/node-chrome:16
needs: [install-client]
script:
- npm test -- --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox
test-server:
extends: .npm-server
stage: test
needs: [install-server]
script:
- npm test
.docker:
image: docker:20
services:
- docker:20-dind
variables:
CONTAINER_PRODUCTION_IMAGE: $CI_REGISTRY_IMAGE/$SUBPROJECT:production-$CI_COMMIT_SHA
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
.docker-client:
extends: .docker
variables:
SUBPROJECT: client
.docker-server:
extends: .docker
variables:
SUBPROJECT: server
.build:
stage: build
variables:
CONTAINER_MR_IMAGE: $CI_REGISTRY_IMAGE/$SUBPROJECT:mr-$CI_MERGE_REQUEST_IID
script:
- docker build --pull -t $CONTAINER_BUILD_IMAGE -f $SUBPROJECT/Dockerfile .
- docker push $CONTAINER_BUILD_IMAGE
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
variables:
CONTAINER_BUILD_IMAGE: $CONTAINER_MR_IMAGE
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
variables:
CONTAINER_BUILD_IMAGE: $CONTAINER_PRODUCTION_IMAGE
build-client:
extends:
- .docker-client
- .build
needs:
- format-client
- lint-client
- test-client
build-server:
extends:
- .docker-server
- .build
needs:
- format-server
- lint-server
- test-server
.deploy:
stage: deploy
variables:
CONTAINER_DEPLOY_IMAGE: $CI_REGISTRY_IMAGE/$SUBPROJECT:latest
script:
- apk add --no-cache curl
- docker pull $CONTAINER_PRODUCTION_IMAGE
- docker tag $CONTAINER_PRODUCTION_IMAGE $CONTAINER_DEPLOY_IMAGE
- docker push $CONTAINER_DEPLOY_IMAGE
- curl --request POST $WEBHOOK_URL
environment: production/$SUBPROJECT
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
deploy-client:
extends:
- .docker-client
- .deploy
deploy-server:
extends:
- .docker-server
- .deploy