This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
194 lines (185 loc) · 3.93 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
stages:
- Dependencies
- Build Javascript
- Test Javascript
- Coverage
- Build Container
- Publish Container
- Deploy
workflow:
rules:
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "staging" || $CI_COMMIT_BRANCH == "trying" || $CI_COMMIT_BRANCH == "dog" || $CI_COMMIT_BRANCH == "acceptance"'
when: always
- if: '$CI_COMMIT_BRANCH == "staging" || $CI_COMMIT_BRANCH == "trying"'
when: never
- if: '$CI_COMMIT_BRANCH =~ /(.tmp)/'
when: never
- if: '$CI_PIPELINE_SOURCE == "external_pull_request_event"'
when: never
- if: $CI_COMMIT_TAG
when: always
JS Dependencies:
needs: [ ]
stage: Dependencies
image: containers.monetr.dev/node:16.1.0-buster
tags:
- k8s:shared
script:
- yarn install --no-lockfile # Will use my npm proxy/registry allowing for faster pulling of dependencies.
cache:
key: ${CI_COMMIT_SHA}
paths:
- ./node_modules
policy: push
Build:
except:
refs:
- main
- tags
needs:
- "JS Dependencies"
stage: Build Javascript
image: containers.monetr.dev/node:16.1.0-buster
tags:
- k8s:shared
script:
- make build
cache:
key: ${CI_COMMIT_SHA}
paths:
- ./build
- ./node_modules
policy: pull-push
Build - Staging:
only:
refs:
- main
needs:
- "JS Dependencies"
stage: Build Javascript
variables:
ENVIRONMENT: Staging
image: containers.monetr.dev/node:16.1.0-buster
tags:
- k8s:shared
script:
- make build ENVIRONMENT=$ENVIRONMENT
cache:
key: ${CI_COMMIT_SHA}-${ENVIRONMENT}
paths:
- ./build
- ./node_modules
policy: pull-push
Build - Acceptance:
only:
refs:
- tags
needs:
- "JS Dependencies"
stage: Build Javascript
variables:
ENVIRONMENT: Acceptance
image: containers.monetr.dev/node:16.1.0-buster
tags:
- k8s:shared
script:
- make build ENVIRONMENT=$ENVIRONMENT
cache:
key: ${CI_COMMIT_SHA}-${ENVIRONMENT}
paths:
- ./build
- ./node_modules
policy: pull-push
Test:
needs:
- "JS Dependencies"
stage: Test Javascript
image: containers.monetr.dev/node:16.1.0-buster
tags:
- k8s:shared
script:
- yarn coverage
cache:
key: ${CI_COMMIT_SHA}
paths:
- ./node_modules
policy: pull
artifacts:
name: "$CI_COMMIT_SHA-coverage-report"
paths:
- ./reports
expire_in: 7 days
Yeet Coverage:
needs:
- "Test"
environment:
name: DeepSource
stage: Coverage
when: manual
image: ubuntu:20.04
tags:
- k8s:shared
variables:
DEBIAN_FRONTEND: noninteractive
before_script:
- apt-get update
- apt-get install curl git-all -y
- curl https://deepsource.io/cli | sh
script:
- DEEPSOURCE_DSN=$K8S_SECRET_DEEPSOURCE_DSN ./bin/deepsource report --analyzer test-coverage --key go --value-file ./coverage.txt
cache:
key: ${CI_COMMIT_SHA}
paths:
- ./coverage.txt
policy: pull
Deploy - Staging:
only:
refs:
- main
except:
refs:
- tags
environment:
name: Staging
url: https://app.staging.monetr.dev
needs:
- "Build - Staging"
stage: Deploy
image: containers.monetr.dev/ubuntu:20.04
tags:
- k8s:shared
variables:
ENVIRONMENT: Staging
before_script:
- gcloud auth activate-service-account --key-file $GCS_SERVICE_ACCOUNT
script:
- make deploy
cache:
key: ${CI_COMMIT_SHA}-${ENVIRONMENT}
paths:
- ./build
policy: pull
Deploy - Acceptance:
only:
refs:
- tags
environment:
name: Acceptance
url: https://acceptance.monetr.dev
needs:
- "Build - Acceptance"
stage: Deploy
image: containers.monetr.dev/ubuntu:20.04
tags:
- k8s:shared
variables:
ENVIRONMENT: Acceptance
before_script:
- gcloud auth activate-service-account --key-file $GCS_SERVICE_ACCOUNT
script:
- make deploy
cache:
key: ${CI_COMMIT_SHA}-${ENVIRONMENT}
paths:
- ./build
policy: pull