-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
151 lines (137 loc) · 3.2 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
image: node:20.17.0
stages:
- install
- verify
- deploy
- e2e
variables:
YARN_CACHE_FOLDER: '$CI_PROJECT_DIR/cache/yarn'
.rules:
rules:
- if: ($CI_PIPELINE_SOURCE == "merge_request_event")
- if: ($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "dev")
.cache_template: &cache_config
key:
files:
- yarn.lock
paths:
- cache/yarn
- node_modules
- frontend/node_modules
- backend/node_modules
install:
stage: install
interruptible: true
image: node:alpine
rules:
- if: ($CI_PIPELINE_SOURCE == "merge_request_event")
changes:
- yarn.lock
- if: ($CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push")
changes:
- yarn.lock
- if: $REINSTALL == "true"
cache:
<<: *cache_config
policy: push
script:
- echo 'yarn-offline-mirror ".yarn-cache/"' >> .yarnrc
- echo 'yarn-offline-mirror-pruning true' >> .yarnrc
- yarn install --frozen-lockfile --ignore-engines
format:
stage: verify
interruptible: true
image: node:alpine
rules:
- !reference [.rules, rules]
cache:
<<: *cache_config
policy: pull
script:
- yarn install --frozen-lockfile --ignore-engines
- yarn format:check
lint:
stage: verify
interruptible: true
image: node:alpine
rules:
- !reference [.rules, rules]
cache:
<<: *cache_config
policy: pull
script:
- yarn install --frozen-lockfile --ignore-engines
- yarn lint
needs:
- format
test-frontend:
stage: verify
interruptible: true
image: node:alpine
rules:
- !reference [.rules, rules]
cache:
<<: *cache_config
policy: pull
script:
- yarn install --frozen-lockfile --ignore-engines
- yarn frontend test
needs:
- lint
build-frontend:
stage: verify
interruptible: true
image: node:alpine
rules:
- if: ($CI_PIPELINE_SOURCE == "merge_request_event")
- if: ($CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push")
cache:
<<: *cache_config
policy: pull
script:
- yarn install --frozen-lockfile --ignore-engines
- yarn frontend build
needs:
- test-frontend
build-backend:
stage: verify
interruptible: true
image: node:alpine
rules:
- if: ($CI_PIPELINE_SOURCE == "merge_request_event")
- if: ($CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push")
cache:
<<: *cache_config
policy: pull
script:
- yarn install --frozen-lockfile --ignore-engines
- yarn backend build
needs:
- lint
pull-changes:
stage: deploy
interruptible: true
image: alpine:latest
before_script:
- 'command -v ssh-agent >/dev/null || ( apk update && apk add openssh-client )'
- eval $(ssh-agent -s)
- chmod 400 "$SSH_PRIVATE_KEY"
- ssh-add "$SSH_PRIVATE_KEY"
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- ssh -oStrictHostKeyChecking=no [email protected] "cd code/project && git pull"
only:
- main # This will run only on the 'main' branch
e2e-testing:
stage: e2e
image: mcr.microsoft.com/playwright:v1.48.1-noble
cache:
<<: *cache_config
policy: pull
script:
- echo FRONTEND_URL="$FRONTEND_URL" >> .env
- echo BACKEND_URL="$BACKEND_URL" >> .env
- yarn test:e2e
only:
- main