-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
205 lines (182 loc) · 4.78 KB
/
config.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
version: 2.1
orbs:
aws_assume_role: lbh-hackit/[email protected]
cypress: cypress-io/cypress@3
node: circleci/node@7
sonarcloud: sonarsource/sonarcloud@2
executors:
node:
docker:
- image: cimg/node:20.18.2-browsers
working_directory: ~/project
python:
docker:
- image: cimg/python:3.7
references:
workspace_root: &workspace_root '.'
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
commands:
assume-role-and-persist-workspace:
description: 'Assumes deployment role and persists credentials across jobs'
parameters:
aws-account:
type: string
steps:
- checkout
- aws_assume_role/assume_role:
account: <<parameters.aws-account>>
profile_name: default
role: 'LBH_Circle_CI_Deployment_Role'
- persist_to_workspace:
root: '~'
paths:
- .aws
deploy-lambda:
description: 'Deploys application'
parameters:
stage:
type: string
default: staging
steps:
- checkout
- attach_workspace:
at: '~'
- run:
name: Install serverless CLI
command: sudo npm i -g serverless
- run:
name: Deploy application
command: |
npm prune --omit=dev
sls deploy -s <<parameters.stage>>
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Jobs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
jobs:
build:
executor: node
steps:
- checkout
- attach_workspace:
at: *workspace_root
- node/install-packages
- run:
name: Build Next application
command: npm run build --omit=dev
- persist_to_workspace:
root: *workspace_root
paths:
- build
- node_modules
lint-and-test:
executor: node
steps:
- checkout
- attach_workspace:
at: *workspace_root
- run:
name: Run linter
command: npm run lint:ci
- run:
name: Run prettier
command: npm run prettier:test
- run:
name: Run unit tests
command: npm run test:unit:ci
environment:
JEST_JUNIT_OUTPUT_DIR: test_results
JEST_JUNIT_ADD_FILE_ATTRIBUTE: 'true'
- store_test_results:
path: test_results
- store_artifacts:
path: coverage
run-cypress-e2e:
executor: node
steps:
- checkout
- attach_workspace:
at: *workspace_root
- run:
name: Copy envs
command: cp .env.sample .env
- cypress/install
- cypress/run-tests:
start-command: npm run start:ci
cypress-command: npx wait-on http-get://127.0.0.1:3000/api/ping && npx cypress run
- store_test_results:
path: cypress/results
- store_artifacts:
path: cypress/results
sonar-scan:
executor: node
steps:
- checkout
- attach_workspace:
at: *workspace_root
- sonarcloud/scan
assume-role-staging:
executor: python
steps:
- assume-role-and-persist-workspace:
aws-account: $AWS_ACCOUNT_STAGING
assume-role-production:
executor: python
steps:
- assume-role-and-persist-workspace:
aws-account: $AWS_ACCOUNT_PRODUCTION
deploy-staging:
executor: node
steps:
- deploy-lambda:
stage: staging
deploy-production:
executor: node
steps:
- deploy-lambda:
stage: production
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Workflows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
workflows:
version: 2
continuous-delivery:
jobs:
- build
- lint-and-test:
requires:
- build
- run-cypress-e2e:
requires:
- build
- sonar-scan:
context: SonarCloud
requires:
- lint-and-test
- assume-role-staging:
context:
- api-assume-role-document-evidence-store-staging-context
requires:
- build
- run-cypress-e2e
- lint-and-test
filters:
branches:
only:
- main
- deploy-staging:
context:
- 'Serverless Framework'
requires:
- assume-role-staging
- permit-deploy-production:
type: approval
requires:
- deploy-staging
- assume-role-production:
context: api-assume-role-document-evidence-store-production-context
requires:
- permit-deploy-production
- deploy-production:
context:
- 'Serverless Framework'
requires:
- assume-role-production