-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
157 lines (118 loc) · 2.82 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
# TBD:
# Implement deploy jobs to run via gitlab runner with docker executor ...
# .. (instead of shell executor) and implement usage of pm2 deployment system.
stages:
- build
- test
- deploy
variables:
NODE_VER: '16.18.1'
WEB_APP_FOLDER: web-app
P2P_SERVICE_FOLDER: p2p-service
cache: &global_cache
key: $CI_COMMIT_REF_SLUG
paths:
- $WEB_APP_FOLDER/node_modules/
- $P2P_SERVICE_FOLDER/node_modules/
policy: pull-push
build_app:
stage: build
image: node:$NODE_VER
tags: [ 'docker' ]
artifacts:
paths:
- $WEB_APP_FOLDER/.next/
script:
- cd $WEB_APP_FOLDER
- yarn
- yarn build
only:
refs:
- merge_requests
- main
changes:
- web-app/**/*
test_app:
stage: test
image: node:$NODE_VER
tags: [ 'docker' ]
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
artifacts:
paths:
- $WEB_APP_FOLDER/coverage/
- $WEB_APP_FOLDER/reports/junit.xml
reports:
coverage_report:
coverage_format: cobertura
path: $WEB_APP_FOLDER/coverage/cobertura-coverage.xml
junit: $WEB_APP_FOLDER/reports/junit.xml
script:
- cd $WEB_APP_FOLDER
- yarn
- yarn test:ci-coverage
only:
refs:
- merge_requests
- main
changes:
- web-app/**/*
test_storybook:
stage: test
# Using playwright docker image (docker image version must match the ...
# .. version used by the app)
image: mcr.microsoft.com/playwright:v1.32.3-focal
tags: [ 'docker' ]
script:
- cd $WEB_APP_FOLDER
- yarn
- yarn test:ci-generate-output
- yarn test-storybook:ci
artifacts:
paths:
- $WEB_APP_FOLDER/reports/jest-test-results.json
only:
refs:
- merge_requests
- main
changes:
- web-app/**/*
deploy_app:
stage: deploy
before_script:
- cd $HOME/dom-pwa/
- git config --global user.email "[email protected]"
- git config --global user.name "andrii"
- GIT_SSH_COMMAND='ssh -i /home/gitlab-runner/.ssh/gitlab_rsa' git pull
script:
- cd $WEB_APP_FOLDER
- yarn
- yarn build
- pm2 restart dom
after_script:
- exit
only:
refs:
- main
changes:
- web-app/**/*
when: manual
deploy_storybook:
stage: deploy
script:
# Currently, there is a problem with using artifacts from a runner that ...
# uses a docker executor on a runner with a shell executor.
# See: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1180
# As a workaround, we run jest tests again to generate the test results ...
# .. in the production folder for Storybook to use.
- cd $WEB_APP_FOLDER
- yarn test:ci-generate-output
- pm2 restart storybook
after_script:
- exit
needs: [ 'deploy_app' ]
only:
refs:
- main
changes:
- web-app/**/*
when: manual