-
Notifications
You must be signed in to change notification settings - Fork 38
/
pull-requests-custom-branch-portal-only.yml
295 lines (294 loc) · 10 KB
/
pull-requests-custom-branch-portal-only.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# This configuration has been automatically generated by the CircleCI Config SDK.
# For more information, see https://github.com/CircleCI-Public/circleci-config-sdk-ts
# SDK Version: 0.0.0-development
version: 2.1
setup: false
parameters:
gio_action:
type: string
default: pull_requests
description: ""
dry_run:
type: boolean
default: true
description: Run in dry run mode?
docker_tag_as_latest:
type: boolean
default: false
description: Is this version the latest version available?
graviteeio_version:
type: string
default: ""
description: Version of APIM to be used in docker images
apim_version_path:
type: string
default: /home/circleci/project/pom.xml
description: Path to pom.xml with APIM version
commands:
cmd-webui-install:
parameters:
apim-ui-project:
type: string
default: ""
description: the name of the UI project to build
steps:
- restore_cache:
name: Restore NPM cache
keys:
- << parameters.apim-ui-project >>-cache-v1-{{ .Branch }}-{{ checksum "<< parameters.apim-ui-project >>/package-lock.json" }}
- << parameters.apim-ui-project >>-cache-v1-{{ .Branch }}
- run:
name: Install dependencies
command: npm install
working_directory: << parameters.apim-ui-project >>
- save_cache:
name: Save NPM cache
key: << parameters.apim-ui-project >>-cache-v1-{{ .Branch }}-{{ checksum "<< parameters.apim-ui-project >>/package-lock.json" }}
paths:
- ./<< parameters.apim-ui-project >>/node_modules
cmd-notify-on-failure:
steps:
- keeper/env-export:
secret-url: keeper://ZOz4db245GNaETVwmPBk8w/field/password
var-name: SLACK_ACCESS_TOKEN
- slack/notify:
channel: C02JENTV2AX
branch_pattern: master,[0-9]+\.[0-9]+\.x
event: fail
template: basic_fail_1
cmd-create-docker-context:
steps:
- run:
name: Create docker context for buildx
command: |-
docker context create tls-env
docker buildx create tls-env --use
cmd-docker-azure-login:
steps:
- keeper/env-export:
secret-url: keeper://Q721P2LSOPJ9qiXLuf5AHQ/field/login
var-name: AZURE_DOCKER_REGISTRY_USERNAME
- keeper/env-export:
secret-url: keeper://Q721P2LSOPJ9qiXLuf5AHQ/field/password
var-name: AZURE_DOCKER_REGISTRY_PASSWORD
- run:
name: Login to Azure Container Registry
command: echo $AZURE_DOCKER_REGISTRY_PASSWORD | docker login --username $AZURE_DOCKER_REGISTRY_USERNAME --password-stdin graviteeio.azurecr.io
description: Login to Azure Container Registry
cmd-docker-azure-logout:
steps:
- run:
name: Logout from Azure Container Registry
command: docker logout graviteeio.azurecr.io
description: Logout from Azure Container Registry
cmd-build-ui-image:
parameters:
docker-image-name:
type: string
default: ""
description: the name of the image
apim-ui-project:
type: string
default: ""
description: the name of the UI project to build
steps:
- cmd-create-docker-context
- cmd-docker-azure-login
- run:
name: Build UI docker image
command: |-
docker buildx build --push --platform=linux/arm64,linux/amd64 -f docker/Dockerfile \
-t graviteeio.azurecr.io/<< parameters.docker-image-name >>:apim-1234-my-custom-branch-latest \
.
working_directory: << parameters.apim-ui-project >>
- cmd-docker-azure-logout
cmd-restore-maven-job-cache:
parameters:
jobName:
type: string
default: ""
description: The job name
steps:
- restore_cache:
keys:
- gravitee-api-management-v9-<< parameters.jobName >>-{{ .Branch }}-{{ checksum "pom.xml" }}
- gravitee-api-management-v9-<< parameters.jobName >>-{{ .Branch }}
- gravitee-api-management-v9-<< parameters.jobName >>
description: Restore Maven cache for a dedicated job
cmd-save-maven-job-cache:
parameters:
jobName:
type: string
default: ""
description: The job name
steps:
- run:
name: Exclude all APIM artefacts from cache.
command: rm -rf ~/.m2/repository/io/gravitee/apim
- save_cache:
key: gravitee-api-management-v9-<< parameters.jobName >>-{{ .Branch }}-{{ checksum "pom.xml" }}
paths:
- ~/.m2
when: always
description: Save Maven cache for a dedicated job
jobs:
job-webui-lint-test:
parameters:
apim-ui-project:
type: string
default: ""
description: the name of the UI project to build
resource_class:
type: string
default: medium
description: Resource class to use for executor
node_version:
type: string
default: "20.11"
description: Node version to use for executor
docker:
- image: cimg/node:<< parameters.node_version >>
resource_class: << parameters.resource_class >>
steps:
- checkout
- cmd-webui-install:
apim-ui-project: << parameters.apim-ui-project >>
- attach_workspace:
at: .
- run:
name: Check License
command: npm run lint:license
working_directory: << parameters.apim-ui-project >>
- run:
name: Run Prettier and ESLint
command: npm run lint
working_directory: << parameters.apim-ui-project >>
- run:
name: Run unit tests
command: npm run test:coverage
working_directory: << parameters.apim-ui-project >>
- cmd-notify-on-failure
- persist_to_workspace:
root: .
paths:
- << parameters.apim-ui-project >>/coverage/lcov.info
- store_artifacts:
path: << parameters.apim-ui-project >>/coverage/lcov.info
- store_test_results:
path: << parameters.apim-ui-project >>/coverage/junit.xml
job-webui-build:
parameters:
apim-ui-project:
type: string
default: ""
description: the name of the UI project to build
docker-image-name:
type: string
default: ""
description: the name of the image
node_version:
type: string
default: "20.11"
description: Node version to use for executor
docker:
- image: cimg/node:<< parameters.node_version >>
resource_class: large
steps:
- checkout
- attach_workspace:
at: .
- setup_remote_docker:
version: default
- cmd-webui-install:
apim-ui-project: << parameters.apim-ui-project >>
- run:
name: Update Build version
command: "sed -i 's/\"version\": \".*\"/\"version\": \"4.2.0\"/' << parameters.apim-ui-project >>/build.json"
- run:
name: Build
command: npm run build:prod
environment:
NODE_OPTIONS: --max_old_space_size=4086
working_directory: << parameters.apim-ui-project >>
- cmd-build-ui-image:
docker-image-name: << parameters.docker-image-name >>
apim-ui-project: << parameters.apim-ui-project >>
- cmd-notify-on-failure
- persist_to_workspace:
root: .
paths:
- << parameters.apim-ui-project >>/dist
job-sonarcloud-analysis:
parameters:
working_directory:
type: string
default: gravitee-apim-rest-api
description: Directory where the Sonarcloud analysis will be run
docker:
- image: sonarsource/sonar-scanner-cli:5.0.1
resource_class: large
steps:
- run:
name: Add SSH tool
command: apk add --no-cache openssh
- checkout
- attach_workspace:
at: .
- restore_cache:
keys:
- gravitee-api-management-v9-sonarcloud-analysis-<< parameters.working_directory >>-{{ .Branch }}-{{ checksum "pom.xml" }}
- gravitee-api-management-v9-sonarcloud-analysis-<< parameters.working_directory >>-{{ .Branch }}
- gravitee-api-management-v9-sonarcloud-analysis-<< parameters.working_directory >>
- keeper/env-export:
secret-url: keeper://9x9YgyU6DWzux4DPoHAzDQ/field/password
var-name: SONAR_TOKEN
- run:
name: Run Sonarcloud Analysis
command: sonar-scanner -Dsonar.projectVersion=4.2.0
working_directory: << parameters.working_directory >>
- cmd-notify-on-failure
- save_cache:
paths:
- /opt/sonar-scanner/.sonar/cache
key: gravitee-api-management-v9-sonarcloud-analysis-<< parameters.working_directory >>-{{ .Branch }}-{{ checksum "pom.xml" }}
when: always
job-validate-workflow-status:
docker:
- image: cimg/base:stable
resource_class: small
steps:
- run:
name: Check workflow jobs
command: echo "Congratulations! If you can read this, everything is OK"
workflows:
pull_requests:
jobs:
- job-webui-lint-test:
name: Lint & test APIM Portal
context:
- cicd-orchestrator
apim-ui-project: gravitee-apim-portal-webui
resource_class: large
node_version: "20.9"
- job-webui-build:
name: Build APIM Portal and publish image
context:
- cicd-orchestrator
apim-ui-project: gravitee-apim-portal-webui
docker-image-name: apim-portal-ui
node_version: "20.9"
- job-sonarcloud-analysis:
name: Sonar - gravitee-apim-portal-webui
context:
- cicd-orchestrator
requires:
- Lint & test APIM Portal
working_directory: gravitee-apim-portal-webui
- job-validate-workflow-status:
name: Validate workflow status
requires:
- Lint & test APIM Portal
- Build APIM Portal and publish image
orbs:
keeper: gravitee-io/keeper@0.6.3
slack: circleci/slack@4.12.5