@seniorsistemas/exclusion-process-component 0.0.1-c049d10c-e93a-4d63-9c2a-b17bca40c324 → 0.6.0-44030ff3-2eeb-49f7-8927-0920cc01a805

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/.editorconfig +19 -0
  2. package/.gitlab-ci.yml +74 -0
  3. package/.prettierrc +8 -0
  4. package/.senior-ci-extensions.sh +21 -0
  5. package/.vscode/settings.json +6 -0
  6. package/CHANGELOG.md +22 -0
  7. package/README.md +16 -0
  8. package/angular.json +144 -0
  9. package/archive.tar.gz +0 -0
  10. package/e2e/app.e2e-spec.ts +14 -0
  11. package/e2e/app.po.ts +11 -0
  12. package/e2e/tsconfig.e2e.json +14 -0
  13. package/karma.conf.js +53 -0
  14. package/lib/.browserslistrc +5 -0
  15. package/lib/package.json +19 -0
  16. package/{enums/enum-exclusion-process-status.d.ts → lib/src/enums/enum-exclusion-process-status.ts} +1 -1
  17. package/lib/src/exclusion-details/exclusion-details.component.html +84 -0
  18. package/lib/src/exclusion-details/exclusion-details.component.scss +47 -0
  19. package/lib/src/exclusion-details/exclusion-details.component.spec.ts +171 -0
  20. package/lib/src/exclusion-details/exclusion-details.component.ts +235 -0
  21. package/lib/src/exclusion-details/exclusion-details.module.ts +23 -0
  22. package/{exclusion-details/protocols/exclusion-details.d.ts → lib/src/exclusion-details/protocols/exclusion-details.ts} +1 -0
  23. package/{exclusion-details/protocols/show-details-information.d.ts → lib/src/exclusion-details/protocols/show-details-information.ts} +1 -1
  24. package/lib/src/exclusions-list/exclusions-list.component.html +157 -0
  25. package/lib/src/exclusions-list/exclusions-list.component.spec.ts +526 -0
  26. package/lib/src/exclusions-list/exclusions-list.component.ts +335 -0
  27. package/lib/src/exclusions-list/exclusions-list.module.ts +52 -0
  28. package/lib/src/exclusions-list/exclusions-list.routing.ts +89 -0
  29. package/lib/src/exclusions-list/index.ts +2 -0
  30. package/lib/src/logical-delete.module.ts +22 -0
  31. package/{models/exclusion-process-step-group.d.ts → lib/src/models/exclusion-process-step-group.ts} +1 -0
  32. package/{models/exclusion-process-step.d.ts → lib/src/models/exclusion-process-step.ts} +1 -0
  33. package/{models/exclusion-process.d.ts → lib/src/models/exclusion-process.ts} +1 -0
  34. package/{models/list-params.d.ts → lib/src/models/list-params.ts} +1 -0
  35. package/{models/project-config.d.ts → lib/src/models/project-config.ts} +3 -1
  36. package/lib/src/services/filter.service.spec.ts +290 -0
  37. package/lib/src/services/filter.service.ts +109 -0
  38. package/lib/src/services/index.ts +1 -0
  39. package/lib/src/services/logical-delete-config.service.spec.ts +59 -0
  40. package/lib/src/services/logical-delete-config.service.ts +25 -0
  41. package/lib/src/services/logical-delete.service.spec.ts +322 -0
  42. package/lib/src/services/logical-delete.service.ts +122 -0
  43. package/lib/test.ts +14 -0
  44. package/lib/tsconfig.lib.json +19 -0
  45. package/lib/tsconfig.lib.prod.json +6 -0
  46. package/lib/tsconfig.spec.json +12 -0
  47. package/lib/tslint.json +19 -0
  48. package/package.json +59 -18
  49. package/protractor.conf.js +28 -0
  50. package/senior-ci/.devcontainer/Dockerfile +27 -0
  51. package/senior-ci/.devcontainer/devcontainer.json +71 -0
  52. package/senior-ci/.editorconfig +14 -0
  53. package/senior-ci/.gitattributes +5 -0
  54. package/senior-ci/.gitlab-ci.yml +53 -0
  55. package/senior-ci/.pylintrc +562 -0
  56. package/senior-ci/.vscode/launch.json +102 -0
  57. package/senior-ci/CHANGELOG.md +1564 -0
  58. package/senior-ci/CONTRIBUTING.md +31 -0
  59. package/senior-ci/README.md +26 -0
  60. package/senior-ci/ci/ci.sh +74 -0
  61. package/senior-ci/ci/sonar_scanner.py +48 -0
  62. package/senior-ci/common/__init__.py +250 -0
  63. package/senior-ci/common/default-files/pom.xml +10 -0
  64. package/senior-ci/common/docker-helpers.sh +57 -0
  65. package/senior-ci/common/extensions.py +88 -0
  66. package/senior-ci/common/flutter-helpers.sh +3 -0
  67. package/senior-ci/common/getopt_helper.py +168 -0
  68. package/senior-ci/common/graphql_client.py +40 -0
  69. package/senior-ci/common/helm_helpers.py +40 -0
  70. package/senior-ci/common/notification-helpers.sh +15 -0
  71. package/senior-ci/common/npm-helper.sh +4 -0
  72. package/senior-ci/common/parallel-helper.sh +8 -0
  73. package/senior-ci/common/release-helpers.sh +196 -0
  74. package/senior-ci/common/s3cache-helpers.sh +47 -0
  75. package/senior-ci/common/senior-ci-extensions-helpers.sh +15 -0
  76. package/senior-ci/common/sonar_helper.py +203 -0
  77. package/senior-ci/common/validations/buildable_project.py +61 -0
  78. package/senior-ci/common/validations/check_deprecated_primitives.py +49 -0
  79. package/senior-ci/common/validations/check_project_path.py +40 -0
  80. package/senior-ci/common/validations/check_sonar_config_files.py +41 -0
  81. package/senior-ci/common/validations/check_tags.py +41 -0
  82. package/senior-ci/common/validations/validate_changelog.py +151 -0
  83. package/senior-ci/common/validations/validate_issues.py +320 -0
  84. package/senior-ci/docker/build.sh +18 -0
  85. package/senior-ci/docker/config-host.sh +29 -0
  86. package/senior-ci/docker/deploy-service.sh +79 -0
  87. package/senior-ci/docker/push.sh +22 -0
  88. package/senior-ci/frontend/npm/bibliotecas/ci.sh +149 -0
  89. package/senior-ci/frontend/npm/ci.sh +370 -0
  90. package/senior-ci/frontend/npm/release-translations.sh +164 -0
  91. package/senior-ci/helm/deploy.py +56 -0
  92. package/senior-ci/helm/publish.py +41 -0
  93. package/senior-ci/hook/release_notification.sh +88 -0
  94. package/senior-ci/hook/text_notification.sh +10 -0
  95. package/senior-ci/java/bibliotecas/ci.sh +215 -0
  96. package/senior-ci/java/sdl/ci.sh +372 -0
  97. package/senior-ci/java/sdl/scripts/hotfix.sh +78 -0
  98. package/senior-ci/mobile/flutter/apps/__main__.py +5 -0
  99. package/senior-ci/mobile/flutter/apps/ci.py +193 -0
  100. package/senior-ci/mobile/flutter/libs/__main__.py +5 -0
  101. package/senior-ci/mobile/flutter/libs/ci.py +178 -0
  102. package/senior-ci/mobile/flutter/scripts/release.sh +54 -0
  103. package/senior-ci/release-candidate/backend/get_version.sh +64 -0
  104. package/senior-ci/release-candidate/close_branch.sh +113 -0
  105. package/senior-ci/release-candidate/common/create_hotfix.sh +28 -0
  106. package/senior-ci/release-candidate/common/create_release.sh +30 -0
  107. package/senior-ci/release-candidate/create_branch.sh +64 -0
  108. package/senior-ci/release-candidate/frontend/get_version.sh +43 -0
  109. package/senior-ci/requirements-dev.txt +5 -0
  110. package/senior-ci/requirements.txt +5 -0
  111. package/senior-ci/scripts/apply_yamls.py +229 -0
  112. package/senior-ci/scripts/create_sre_issue/__main__.py +7 -0
  113. package/senior-ci/scripts/create_sre_issue/create_sre_issue.py +267 -0
  114. package/senior-ci/scripts/create_sre_issue/helpers.py +166 -0
  115. package/senior-ci/scripts/create_sre_issue/jira_manager.py +37 -0
  116. package/senior-ci/scripts/validate_changelog.sh +3 -0
  117. package/senior-ci/sonar-project.properties +1 -0
  118. package/server.js +5 -0
  119. package/sonar-project.properties +10 -0
  120. package/src/app/app.component.html +43 -0
  121. package/src/app/app.component.scss +36 -0
  122. package/src/app/app.component.ts +56 -0
  123. package/src/app/app.module.ts +64 -0
  124. package/src/app/shared/shared.module.ts +28 -0
  125. package/src/environments/environment.default.ts +3 -0
  126. package/src/environments/environment.prod.ts +6 -0
  127. package/src/environments/environment.ts +7 -0
  128. package/src/favicon.ico +0 -0
  129. package/src/index.html +17 -0
  130. package/src/locale/en-US.json +3 -0
  131. package/src/locale/es-ES.json +3 -0
  132. package/src/locale/pt-BR.json +3 -0
  133. package/src/main.ts +13 -0
  134. package/src/polyfills.ts +58 -0
  135. package/src/styles.scss +11 -0
  136. package/src/tsconfig.app.json +21 -0
  137. package/src/typings.d.ts +15 -0
  138. package/tsconfig.json +39 -0
  139. package/tslint.json +80 -0
  140. package/bundles/seniorsistemas-exclusion-process-component.umd.js +0 -747
  141. package/bundles/seniorsistemas-exclusion-process-component.umd.js.map +0 -1
  142. package/bundles/seniorsistemas-exclusion-process-component.umd.min.js +0 -16
  143. package/bundles/seniorsistemas-exclusion-process-component.umd.min.js.map +0 -1
  144. package/esm2015/enums/enum-exclusion-process-status.js +0 -8
  145. package/esm2015/exclusion-details/exclusion-details.component.js +0 -216
  146. package/esm2015/exclusion-details/exclusion-details.module.js +0 -28
  147. package/esm2015/exclusion-details/index.js +0 -3
  148. package/esm2015/exclusion-details/protocols/exclusion-details.js +0 -1
  149. package/esm2015/exclusion-details/protocols/index.js +0 -2
  150. package/esm2015/exclusion-details/protocols/show-details-information.js +0 -3
  151. package/esm2015/logical-delete.module.js +0 -27
  152. package/esm2015/models/exclusion-process-step-group.js +0 -1
  153. package/esm2015/models/exclusion-process-step.js +0 -1
  154. package/esm2015/models/exclusion-process.js +0 -1
  155. package/esm2015/models/index.js +0 -1
  156. package/esm2015/models/list-params.js +0 -1
  157. package/esm2015/models/list-result.js +0 -1
  158. package/esm2015/models/project-config.js +0 -3
  159. package/esm2015/public-api.js +0 -3
  160. package/esm2015/seniorsistemas-exclusion-process-component.js +0 -9
  161. package/esm2015/services/filter.service.js +0 -104
  162. package/esm2015/services/logical-delete-config.service.js +0 -29
  163. package/esm2015/services/logical-delete.service.js +0 -109
  164. package/esm5/enums/enum-exclusion-process-status.js +0 -8
  165. package/esm5/exclusion-details/exclusion-details.component.js +0 -235
  166. package/esm5/exclusion-details/exclusion-details.module.js +0 -31
  167. package/esm5/exclusion-details/index.js +0 -3
  168. package/esm5/exclusion-details/protocols/exclusion-details.js +0 -1
  169. package/esm5/exclusion-details/protocols/index.js +0 -2
  170. package/esm5/exclusion-details/protocols/show-details-information.js +0 -7
  171. package/esm5/logical-delete.module.js +0 -31
  172. package/esm5/models/exclusion-process-step-group.js +0 -1
  173. package/esm5/models/exclusion-process-step.js +0 -1
  174. package/esm5/models/exclusion-process.js +0 -1
  175. package/esm5/models/index.js +0 -1
  176. package/esm5/models/list-params.js +0 -1
  177. package/esm5/models/list-result.js +0 -1
  178. package/esm5/models/project-config.js +0 -3
  179. package/esm5/public-api.js +0 -3
  180. package/esm5/seniorsistemas-exclusion-process-component.js +0 -9
  181. package/esm5/services/filter.service.js +0 -109
  182. package/esm5/services/logical-delete-config.service.js +0 -30
  183. package/esm5/services/logical-delete.service.js +0 -112
  184. package/exclusion-details/exclusion-details.component.d.ts +0 -49
  185. package/exclusion-details/exclusion-details.module.d.ts +0 -2
  186. package/fesm2015/seniorsistemas-exclusion-process-component.js +0 -495
  187. package/fesm2015/seniorsistemas-exclusion-process-component.js.map +0 -1
  188. package/fesm5/seniorsistemas-exclusion-process-component.js +0 -530
  189. package/fesm5/seniorsistemas-exclusion-process-component.js.map +0 -1
  190. package/logical-delete.module.d.ts +0 -5
  191. package/seniorsistemas-exclusion-process-component.d.ts +0 -8
  192. package/seniorsistemas-exclusion-process-component.metadata.json +0 -1
  193. package/services/filter.service.d.ts +0 -19
  194. package/services/logical-delete-config.service.d.ts +0 -8
  195. package/services/logical-delete.service.d.ts +0 -20
  196. /package/{exclusion-details/index.d.ts → lib/src/exclusion-details/index.ts} +0 -0
  197. /package/{exclusion-details/protocols/index.d.ts → lib/src/exclusion-details/protocols/index.ts} +0 -0
  198. /package/{models/index.d.ts → lib/src/models/index.ts} +0 -0
  199. /package/{models/list-result.d.ts → lib/src/models/list-result.ts} +0 -0
  200. /package/{public-api.d.ts → lib/src/public-api.ts} +0 -0
@@ -0,0 +1,320 @@
1
+ """Validate the Custom Issues of a project"""
2
+
3
+ import sys
4
+ from datetime import datetime, timedelta
5
+ from typing import List
6
+
7
+ from colorama import Fore
8
+
9
+ sys.path.append("./senior-ci")
10
+
11
+ from common import (
12
+ end_collapsible_section,
13
+ exit_message,
14
+ get_env_variable,
15
+ get_env_variable_required,
16
+ print_message,
17
+ start_collapsible_section,
18
+ )
19
+ from common.graphql_client import GraphqlClient
20
+ from common.validations.check_deprecated_primitives import CheckDeprecatedPrimitives
21
+ from common.validations.check_project_path import CheckProjectPath
22
+ from common.validations.check_sonar_config_files import CheckConfigFiles
23
+ from common.validations.check_tags import CheckTags
24
+
25
+
26
+ class CustomIssue:
27
+ """Entity of a Custom Issue"""
28
+
29
+ rule: str
30
+ must_be_fixed_until: datetime
31
+ description: str
32
+ notification_text: str
33
+
34
+ def __init__(self, client_graphql: GraphqlClient = GraphqlClient()) -> None:
35
+ self.client_graphql = client_graphql
36
+
37
+ def create(self):
38
+ """Create a CustomIssue for project"""
39
+
40
+ query = """
41
+ mutation ($projectId: Int!, $customIssue: CustomIssueInput!) {
42
+ createCustomCiIssue(
43
+ customIssueInfo: $customIssue
44
+ gitlabInfo:{
45
+ projectId: $projectId
46
+ }
47
+ ) {
48
+ success
49
+ message
50
+ }
51
+ }
52
+ """
53
+
54
+ params = {
55
+ "projectId": int(get_env_variable_required("CI_PROJECT_ID")),
56
+ "customIssue": self.convert_to_json(),
57
+ }
58
+
59
+ self.client_graphql.call(query, params)
60
+
61
+ def convert_from_json(self, payload):
62
+ """Convert a payload to this class"""
63
+
64
+ self.rule = payload["rule"]
65
+ self.must_be_fixed_until = payload["mustBeFixedUntil"]
66
+
67
+ if self.must_be_fixed_until:
68
+ self.must_be_fixed_until = datetime.strptime(
69
+ self.must_be_fixed_until, "%Y-%m-%dT%H:%M:%S"
70
+ )
71
+
72
+ self.description = payload["description"]
73
+ self.notification_text = payload["notificationText"]
74
+
75
+ return self
76
+
77
+ def convert_to_json(self):
78
+ """Convert this class to a json"""
79
+
80
+ return {
81
+ "rule": self.rule,
82
+ "mustBeFixedUntil": self.must_be_fixed_until.strftime("%Y-%m-%dT%H:%M:%S"),
83
+ "description": self.description,
84
+ "notificationText": self.notification_text,
85
+ }
86
+
87
+
88
+ class ProjectIssuesStatus:
89
+ """Entity of a Project Issues Status"""
90
+
91
+ should_break_job: bool
92
+ issues: List[CustomIssue]
93
+
94
+ def __init__(self, client_graphql: GraphqlClient = GraphqlClient()) -> None:
95
+ self.client_graphql = client_graphql
96
+ self._get_project_issue_status()
97
+
98
+ def show_status(self):
99
+ """Print the status of a job and/or project"""
100
+
101
+ print_message("Validando existência de alguma pendência no projeto.")
102
+ print(" ")
103
+
104
+ if self.issues:
105
+ section_id = start_collapsible_section(
106
+ "Existem algumas pendências a serem resolvidas, segue relação:",
107
+ )
108
+
109
+ for issue in self._get_required_issues():
110
+ must_be_fixed_until = issue.must_be_fixed_until
111
+ description = issue.description
112
+
113
+ date_to_fix_message = None
114
+
115
+ if must_be_fixed_until:
116
+ date_to_fix = issue.must_be_fixed_until.strftime("%d/%m/%Y")
117
+
118
+ date_to_fix_message = (
119
+ f"Data de corte para quebrar o job: {date_to_fix}"
120
+ )
121
+
122
+ print_message(
123
+ f"{description} {date_to_fix_message if date_to_fix_message else ''}",
124
+ Fore.RED if self.should_break_job else Fore.LIGHTYELLOW_EX,
125
+ )
126
+
127
+ if self.should_break_job:
128
+ exit_message(
129
+ "O job foi impedido de continuar devido as pendências acima. :x"
130
+ )
131
+
132
+ print(" ")
133
+
134
+ print_message(
135
+ "Nenhuma das pendências acima quebrará este job, porém é importante ajustá-las antes que se tornem impeditivas ;)",
136
+ Fore.YELLOW,
137
+ )
138
+
139
+ end_collapsible_section(section_id)
140
+ else:
141
+ print_message("Nenhuma pendência encontrada, parabéns!", Fore.GREEN)
142
+
143
+ print(" ")
144
+
145
+ def _get_required_issues(self):
146
+ self.issues.sort(
147
+ key=lambda issue: issue.must_be_fixed_until
148
+ if issue.must_be_fixed_until
149
+ else datetime.now()
150
+ )
151
+
152
+ required_issues = self.issues
153
+
154
+ if self.should_break_job:
155
+ required_issues = list(
156
+ filter(lambda issue: issue.must_be_fixed_until is None, self.issues)
157
+ )
158
+
159
+ if not required_issues:
160
+ required_issues = list(
161
+ filter(
162
+ lambda issue: issue.must_be_fixed_until < datetime.now(),
163
+ self.issues,
164
+ )
165
+ )
166
+
167
+ return required_issues
168
+
169
+ def _get_project_issue_status(self):
170
+ query = """
171
+ query ($projectId: Int!, $jobStage: String, $commitSha: String) {
172
+ projectIssuesStatus(
173
+ projectId: $projectId,
174
+ jobStage: $jobStage,
175
+ commitSha: $commitSha
176
+ ) {
177
+ shouldBreakJob
178
+ issues {
179
+ rule
180
+ mustBeFixedUntil
181
+ description
182
+ notificationText
183
+ }
184
+ }
185
+ }
186
+ """
187
+
188
+ params = {
189
+ "projectId": int(get_env_variable_required("CI_PROJECT_ID")),
190
+ "jobStage": get_env_variable_required("CI_JOB_STAGE"),
191
+ "commitSha": get_env_variable_required("CI_COMMIT_SHA"),
192
+ }
193
+
194
+ result = self.client_graphql.call(query, params)
195
+
196
+ project_issues_status_result = result["projectIssuesStatus"]
197
+
198
+ self.convert_from_json(project_issues_status_result)
199
+
200
+ def convert_from_json(self, payload):
201
+ """Convert a payload to this class"""
202
+
203
+ self.should_break_job = payload["shouldBreakJob"]
204
+ self.issues = list(
205
+ map(
206
+ lambda issueResult: CustomIssue().convert_from_json(issueResult),
207
+ payload["issues"],
208
+ )
209
+ )
210
+
211
+ return self
212
+
213
+
214
+ sci_project_type = get_env_variable("SCI_PROJECT_TYPE")
215
+
216
+ skip_check_deprecated_primitives = get_env_variable("SKIP_CHECK_DEPRECATED_PRIMITIVES")
217
+
218
+ graphql_client = GraphqlClient()
219
+
220
+ if not skip_check_deprecated_primitives:
221
+ check_tags = CheckDeprecatedPrimitives(graphql_client)
222
+ result_check = check_tags.check()
223
+
224
+ if not result_check.success:
225
+ custom_issues = CustomIssue(graphql_client)
226
+ custom_issues.rule = "HAS_DEPRECATED_PRIMITIVES"
227
+ custom_issues.description = "Foi encontrado primitivas deprecadas no projeto."
228
+ custom_issues.notification_text = result_check.reason
229
+
230
+ today = datetime.today()
231
+ next_two_week = today + timedelta(days=15)
232
+
233
+ must_be_fixed_until = result_check.last_deprecated_date
234
+
235
+ if must_be_fixed_until < today or must_be_fixed_until < next_two_week:
236
+ must_be_fixed_until = today + timedelta(days=60)
237
+
238
+ custom_issues.must_be_fixed_until = must_be_fixed_until
239
+
240
+ custom_issues.create()
241
+
242
+ skip_check_tags = get_env_variable("SKIP_CHECK_TAGS")
243
+
244
+ if not skip_check_tags and sci_project_type not in ["ANGULAR_GENERATED"]:
245
+ check_tags = CheckTags(graphql_client)
246
+ result_check = check_tags.check()
247
+
248
+ if not result_check.success:
249
+ custom_issues = CustomIssue(graphql_client)
250
+ custom_issues.rule = "MISSING_SONAR_TAGS"
251
+ custom_issues.description = "Não foram encontradas tags do sonar no projeto."
252
+ custom_issues.notification_text = result_check.reason
253
+
254
+ today = datetime.today()
255
+ next_week = today + timedelta(days=7)
256
+
257
+ custom_issues.must_be_fixed_until = next_week
258
+
259
+ custom_issues.create()
260
+
261
+ skip_check_project_path = get_env_variable("SKIP_CHECK_PROJECT_PATH")
262
+
263
+ if not skip_check_project_path:
264
+
265
+ check_project_path = CheckProjectPath(graphql_client)
266
+
267
+ result_check = check_project_path.check()
268
+
269
+ if not result_check.success:
270
+ custom_issues = CustomIssue(graphql_client)
271
+ custom_issues.rule = "PROJECT_PATH_AND_NAME_ARE_NOT_THE_SAME"
272
+ custom_issues.description = (
273
+ "O path do projeto e o nome do projeto são diferentes."
274
+ )
275
+ custom_issues.notification_text = result_check.reason
276
+
277
+ today = datetime.today()
278
+ tomorrow = today + timedelta(days=1)
279
+
280
+ custom_issues.must_be_fixed_until = tomorrow
281
+
282
+ custom_issues.create()
283
+
284
+ skip_check_config_files = get_env_variable("SKIP_CHECK_CONFIG_FILES")
285
+
286
+ if not skip_check_config_files and sci_project_type in [
287
+ "APP_BASE",
288
+ "ANGULAR_SENIORX",
289
+ "ANGULAR_APP",
290
+ "ANGULAR_LIB",
291
+ "FLUTTER_APP",
292
+ "FLUTTER_LIB",
293
+ ]:
294
+
295
+ check_sonar_config_files = CheckConfigFiles(graphql_client)
296
+
297
+ result = check_sonar_config_files.check()
298
+
299
+ if not result.success:
300
+ custom_issues = CustomIssue(graphql_client)
301
+ custom_issues.rule = "SONARQUBE_OR_PROJECT_CONFIG_ARE_WRONG"
302
+ custom_issues.description = (
303
+ "Os arquivos de configuração do Sonar ou do Projeto não estão alinhados. "
304
+ "Ao corrigir esse problema, pode ocorrer uma queda no coverage. "
305
+ "Qualquer dúvida entre em contato com o time de DevOps."
306
+ )
307
+ custom_issues.notification_text = result.reason
308
+
309
+ today = datetime.today()
310
+ next_week = today + timedelta(days=7)
311
+
312
+ custom_issues.must_be_fixed_until = next_week
313
+
314
+ custom_issues.create()
315
+
316
+ skip_issue_validate = get_env_variable("SKIP_ISSUE_VALIDATE")
317
+
318
+ if not skip_issue_validate:
319
+ project_issues_status = ProjectIssuesStatus(graphql_client)
320
+ project_issues_status.show_status()
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit at first error
4
+
5
+ echo "[CI] buildando a imagem $SVC_IMAGE."
6
+ if [ -n "$TARGET" ]; then
7
+ docker build --target $TARGET --network host -t seniorsa/$SVC_IMAGE .
8
+ else
9
+ docker build --network host -t $HUB_USER/$SVC_IMAGE .
10
+ fi
11
+
12
+ CI_COMMIT_TAG="${CI_COMMIT_TAG//-/.}"
13
+ CI_COMMIT_TAG="${CI_COMMIT_TAG:1}"
14
+ VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_REF_SLUG-SNAPSHOT}"
15
+
16
+ if [ -z "$SKIP_IMAGE_SCAN" ]; then
17
+ trivy --clear-cache --severity HIGH,CRITICAL seniorsa/$SVC_IMAGE
18
+ fi
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ if [ "$EUID" -ne 0 ]
4
+ then echo "Esse script deve ser executado como root! Tente novamente utilizando sudo."
5
+ exit 1
6
+ fi
7
+
8
+ echo "[CI] Iniciando a configuração da execução remota do docker"
9
+ echo "[CI] Criando o diretório /etc/systemd/system/docker.service.d"
10
+ mkdir -p /etc/systemd/system/docker.service.d
11
+
12
+ echo "[CI] Realizando a criação do arquivo options.conf"
13
+ rm -f /etc/systemd/system/docker.service.d/options.conf
14
+ touch /etc/systemd/system/docker.service.d/options.conf
15
+
16
+ cat <<EOF > /etc/systemd/system/docker.service.d/options.conf
17
+ [Service]
18
+ ExecStart=
19
+ ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375
20
+ EOF
21
+ echo "[CI] Arquivo options.conf configurado com sucesso!"
22
+
23
+ echo "[CI] Reiniciando o systemctl"
24
+ systemctl daemon-reload
25
+
26
+ echo "[CI] Reiniciando o docker"
27
+ systemctl restart docker
28
+
29
+ echo "[CI] Host configurado com sucesso para receber deploys via Docker! Para mais informações consulte https://git.senior.com.br/engenharia/senior-ci/wikis/home"
@@ -0,0 +1,79 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit at first error
4
+
5
+ # Import docker helpers
6
+ . senior-ci/common/docker-helpers.sh
7
+
8
+ echo ""
9
+
10
+ if [ -e .senior-ci-extensions.sh ]; then
11
+ echo "[CI] Carregando arquivo de extensões - .senior-ci-extensions.sh"
12
+ . .senior-ci-extensions.sh
13
+ else
14
+ echo "[CI] Arquivo de extensões não encontrado (.senior-ci-extensions.sh). Continuando execução padrão do CI."
15
+ fi
16
+
17
+ call_extension() {
18
+ if [ -n "$(type -t $1)" ] && [ "$(type -t $1)" = function ]; then
19
+ echo "[CI] Disparando hook $1 do .senior-ci-extensions.sh"
20
+ $1
21
+ fi
22
+ };
23
+
24
+
25
+ call_extension "before_deploy"
26
+
27
+ DOCKER_HOST="tcp://$SVC_DEPLOY_TARGET:2375"
28
+
29
+ CI_COMMIT_TAG="${CI_COMMIT_TAG//-/.}"
30
+ CI_COMMIT_TAG="${CI_COMMIT_TAG:1}"
31
+ VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_REF_SLUG-SNAPSHOT}"
32
+
33
+ if [ "$SVC_NAME" == "" ]; then
34
+ SVC_NAME=$SVC_IMAGE
35
+ fi
36
+
37
+ if [ "$SVC_TIMEZONE" == "" ]; then
38
+ SVC_TIMEZONE="-e TZ=America/Sao_Paulo"
39
+ fi
40
+
41
+ echo ""
42
+ echo "[CI] Realizando o deploy do serviço $SVC_IMAGE:$VERSION no host $SVC_DEPLOY_TARGET"
43
+ echo ""
44
+ echo "[CI] O serviço $SVC_NAME($SVC_IMAGE:$VERSION) vai se conectar ao RabbitMQ do ambiente $CI_ENVIRONMENT_URL"
45
+ echo ""
46
+
47
+ docker_login
48
+
49
+ echo "[CI] Baixando imagem seniorsa/$SVC_IMAGE:$VERSION"
50
+ docker -H $DOCKER_HOST pull seniorsa/$SVC_IMAGE:$VERSION
51
+
52
+ echo ""
53
+
54
+ docker -H $DOCKER_HOST rm -f $SVC_NAME
55
+
56
+ echo "[CI] Subindo container $SVC_NAME($SVC_IMAGE:$VERSION)"
57
+ echo ""
58
+ docker -H $DOCKER_HOST run -d --name=$SVC_NAME \
59
+ -e JAVA_OPTS="$SVC_JAVA_OPTS" \
60
+ $SVC_TIMEZONE \
61
+ -e BROKER_HOST=$CI_ENVIRONMENT_URL \
62
+ $SVC_ENVIRONMENT \
63
+ --log-opt max-size=5m --log-opt max-file=1 \
64
+ $MEMORY_LIMIT \
65
+ --restart=unless-stopped \
66
+ $VOLUME_MAPPING \
67
+ seniorsa/$SVC_IMAGE:$VERSION
68
+
69
+ if [ -n "$SLACK_HOOK" ]; then
70
+ echo "[CI] Enviando notificação no Slack"
71
+ echo ""
72
+ DEPLOY_USERNAME="${GITLAB_USER_EMAIL%@senior.com.br}"
73
+ curl -s -X POST "$SLACK_HOOK" -H 'Content-Type: application/json' -d '{ "text": "O usuário `'$DEPLOY_USERNAME'` realizou um deploy do serviço `'$SVC_IMAGE:$VERSION'` com o nome `'$SVC_NAME'` no host `'$SVC_DEPLOY_TARGET'`."}'
74
+ fi
75
+
76
+ call_extension "after_deploy"
77
+
78
+ echo ""
79
+ echo "[CI] Deploy realizado com sucesso!"
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit at first error
4
+
5
+
6
+ if [ -z "$HUB_USER" ]; then
7
+ HUB_USER="seniorsa"
8
+ fi
9
+
10
+ # Import docker helpers
11
+ . senior-ci/common/docker-helpers.sh
12
+
13
+ . senior-ci/docker/build.sh
14
+
15
+ docker_login
16
+
17
+ docker tag $HUB_USER/$SVC_IMAGE $HUB_USER/$SVC_IMAGE:$VERSION
18
+
19
+ create_dockerhub_repo
20
+
21
+ echo "[CI] fazendo push da imagem $HUB_USER/$SVC_IMAGE e versão $VERSION para o docker hub"
22
+ docker push $HUB_USER/$SVC_IMAGE:$VERSION
@@ -0,0 +1,149 @@
1
+ #!/bin/bash
2
+
3
+ echo "----------------------------------------------------------------------------------"
4
+ echo "[CI] Variáveis:"
5
+ echo "[CI] - SCI_VERSION_TAG_FRONTEND=$SCI_VERSION_TAG_FRONTEND"
6
+ echo "[CI] - CANNED_ACL=$CANNED_ACL"
7
+ echo "[CI] - CDN_PATH=$CDN_PATH"
8
+ echo "[CI] - SOURCE_FOLDER_NPM=$SOURCE_FOLDER_NPM"
9
+ echo "----------------------------------------------------------------------------------"
10
+
11
+ set -e # Exit at first error
12
+
13
+ # Import release helpers
14
+ . senior-ci/common/release-helpers.sh
15
+
16
+ # Import notification helpers
17
+ . senior-ci/common/notification-helpers.sh
18
+
19
+ # Senior CI Extensions
20
+ . senior-ci/common/senior-ci-extensions-helpers.sh
21
+
22
+ # Import npm struture helpers
23
+ . senior-ci/common/npm-helper.sh
24
+
25
+
26
+ HELP_MESSAGE="Caso tenha qualquer dúvida sobre o processo, consulte nossa Wiki - https://git.senior.com.br/engenharia/senior-ci/wikis/home"
27
+
28
+ prepareVersionSnapshot() {
29
+ if [[ $VERSION = *"-SNAPSHOT"* ]]; then
30
+ UUID_VERSION=$(get_attribute "version\":")-$(uuidgen)
31
+ npm --no-git-tag-version version $UUID_VERSION
32
+ TAG_NPM="--tag $VERSION"
33
+ fi
34
+ }
35
+
36
+
37
+ packing() {
38
+
39
+ echo "[CI] Iniciando processo de publicação do projeto."
40
+
41
+ if [ "$CDN_PATH" ]; then
42
+ : "${CANNED_ACL:?CANNED_ACL não configurado no cluster.}"
43
+
44
+ npm --version
45
+ echo "[CI] Publicando a versão $VERSION no bucket S3 do CDN - $CDN_PATH/$VERSION"
46
+ aws s3 cp dist s3://$CDN_PATH/$VERSION --recursive --acl $CANNED_ACL
47
+ fi
48
+
49
+ : "${NPM_TOKEN:?Configure a variável NPM_TOKEN nas settings do seu projeto no GitLab. $HELP_MESSAGE}"
50
+ echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
51
+
52
+ echo "[CI] Publicando o pacote no NPM Registry - //registry.npmjs.org"
53
+ if [ "$NPM_TOKEN" ]; then
54
+ npm config set registry https://registry.npmjs.org/
55
+ fi
56
+
57
+ npm publish $SOURCE_FOLDER_NPM --access public $TAG_NPM
58
+ }
59
+
60
+ getopts "bsrpx" op;
61
+ case "$op" in
62
+
63
+ b) echo "[CI] Executando compilação e validação de formatação do código"
64
+ python3 senior-ci/common/validations/validate_issues.py
65
+
66
+ call_extension "before_build"
67
+ npm run build
68
+ npm run lint --if-present
69
+ call_extension "after_build"
70
+ ;;
71
+
72
+ s) echo "[CI] Realizando release: SNAPSHOT"
73
+ call_extension "before_release_snapshot"
74
+ VERSION="$2-SNAPSHOT"
75
+ prepareVersionSnapshot
76
+ npm run build
77
+ packing
78
+ call_extension "after_release_snapshot"
79
+ ;;
80
+
81
+ r) echo "[CI] Realizando release: $2"
82
+ python3 senior-ci/common/validations/validate_issues.py
83
+
84
+ unshallow_repo
85
+
86
+ get_next_version $2
87
+
88
+ create_release_branch
89
+
90
+ call_extension "before_release"
91
+
92
+ npm version --no-git-tag-version "$VERSION"
93
+ [[ -f bower.json ]] && sed -i -E "s/(\"version\":[[:space:]]*\").+(\")/\1${VERSION}\2/g" bower.json
94
+
95
+ call_extension "before_change_changelog"
96
+
97
+ update_changelog
98
+
99
+ call_extension "after_change_changelog"
100
+
101
+ create_release_tag
102
+
103
+ call_extension "after_release"
104
+
105
+ echo "[CI] Criação da release versão $VERSION realizado com sucesso. Execute o job 'package' para publicar esta versão no CDN e NPM Registry."
106
+
107
+ notify_release_teams_channel
108
+ ;;
109
+
110
+ p) echo "[CI] Publicação da versão"
111
+
112
+ call_extension "before_packaging"
113
+
114
+ VERSION=$(git describe --exact-match --tags | grep "^v[0-9]\{1,\}-[0-9]\{1,\}-[0-9]\{1,\}$" | sed "s/-\([[:digit:]]\)/\.\1/g" | sed 's/^\s*.//g')
115
+ if [ -z "${VERSION}" ]; then
116
+ VERSION=$(get_attribute "version\":")
117
+ fi
118
+
119
+ npm run build
120
+ packing
121
+
122
+ USER_DEPLOY_MAIL="${GITLAB_USER_EMAIL%@senior.com.br}"
123
+ DEPLOY_TEAMS_MESSAGE="O usuário $USER_DEPLOY_MAIL liberou a versão <$CI_PROJECT_URL/blob/$CI_COMMIT_REF_NAME/CHANGELOG.md#anchor-$VERSION_WITHOUT_DOTS|$VERSION> do projeto $CI_PROJECT_NAME."
124
+
125
+ call_extension "after_packaging"
126
+
127
+ notify_text_teams_channel "$DEPLOY_TEAMS_MESSAGE"
128
+
129
+ echo "[CI] Versão $VERSION publicada com sucesso!"
130
+ ;;
131
+
132
+ x) echo "[CI] Realizando validação de testes e análise no SonarQube"
133
+ call_extension "before_build"
134
+
135
+ SKIP_BUILD=$(python3 senior-ci/common/validations/buildable_project.py)
136
+ echo $SKIP_BUILD | sed 's@False@@g'
137
+
138
+ if [ "$SKIP_BUILD" = "False" ]; then
139
+
140
+ npm test
141
+
142
+ fi
143
+
144
+ call_extension "after_build"
145
+
146
+ python3 senior-ci/ci/sonar_scanner.py -s $SKIP_BUILD
147
+ ;;
148
+
149
+ esac