@seniorsistemas/exclusion-process-component 0.0.1-40efacd8-8a6c-4d38-8102-8c977c14410a → 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.
- package/.editorconfig +19 -0
- package/.gitlab-ci.yml +74 -0
- package/.prettierrc +8 -0
- package/.senior-ci-extensions.sh +21 -0
- package/.vscode/settings.json +6 -0
- package/CHANGELOG.md +22 -0
- package/README.md +16 -0
- package/angular.json +144 -0
- package/archive.tar.gz +0 -0
- package/e2e/app.e2e-spec.ts +14 -0
- package/e2e/app.po.ts +11 -0
- package/e2e/tsconfig.e2e.json +14 -0
- package/karma.conf.js +53 -0
- package/lib/.browserslistrc +5 -0
- package/lib/package.json +19 -0
- package/{enums/enum-exclusion-process-status.d.ts → lib/src/enums/enum-exclusion-process-status.ts} +1 -1
- package/lib/src/exclusion-details/exclusion-details.component.html +84 -0
- package/lib/src/exclusion-details/exclusion-details.component.scss +47 -0
- package/lib/src/exclusion-details/exclusion-details.component.spec.ts +171 -0
- package/lib/src/exclusion-details/exclusion-details.component.ts +235 -0
- package/lib/src/exclusion-details/exclusion-details.module.ts +23 -0
- package/{exclusion-details/protocols/exclusion-details.d.ts → lib/src/exclusion-details/protocols/exclusion-details.ts} +1 -0
- package/{exclusion-details/protocols/show-details-information.d.ts → lib/src/exclusion-details/protocols/show-details-information.ts} +1 -1
- package/lib/src/exclusions-list/exclusions-list.component.html +157 -0
- package/lib/src/exclusions-list/exclusions-list.component.spec.ts +526 -0
- package/lib/src/exclusions-list/exclusions-list.component.ts +335 -0
- package/lib/src/exclusions-list/exclusions-list.module.ts +52 -0
- package/lib/src/exclusions-list/exclusions-list.routing.ts +89 -0
- package/{exclusions-list/index.d.ts → lib/src/exclusions-list/index.ts} +0 -1
- package/lib/src/logical-delete.module.ts +22 -0
- package/{models/exclusion-process-step-group.d.ts → lib/src/models/exclusion-process-step-group.ts} +1 -0
- package/{models/exclusion-process-step.d.ts → lib/src/models/exclusion-process-step.ts} +1 -0
- package/{models/exclusion-process.d.ts → lib/src/models/exclusion-process.ts} +1 -0
- package/{models/list-params.d.ts → lib/src/models/list-params.ts} +1 -0
- package/{models/project-config.d.ts → lib/src/models/project-config.ts} +3 -1
- package/{public-api.d.ts → lib/src/public-api.ts} +0 -1
- package/lib/src/services/filter.service.spec.ts +290 -0
- package/lib/src/services/filter.service.ts +109 -0
- package/lib/src/services/logical-delete-config.service.spec.ts +59 -0
- package/lib/src/services/logical-delete-config.service.ts +25 -0
- package/lib/src/services/logical-delete.service.spec.ts +322 -0
- package/lib/src/services/logical-delete.service.ts +122 -0
- package/lib/test.ts +14 -0
- package/lib/tsconfig.lib.json +19 -0
- package/lib/tsconfig.lib.prod.json +6 -0
- package/lib/tsconfig.spec.json +12 -0
- package/lib/tslint.json +19 -0
- package/package.json +59 -18
- package/protractor.conf.js +28 -0
- package/senior-ci/.devcontainer/Dockerfile +27 -0
- package/senior-ci/.devcontainer/devcontainer.json +71 -0
- package/senior-ci/.editorconfig +14 -0
- package/senior-ci/.gitattributes +5 -0
- package/senior-ci/.gitlab-ci.yml +53 -0
- package/senior-ci/.pylintrc +562 -0
- package/senior-ci/.vscode/launch.json +102 -0
- package/senior-ci/CHANGELOG.md +1564 -0
- package/senior-ci/CONTRIBUTING.md +31 -0
- package/senior-ci/README.md +26 -0
- package/senior-ci/ci/ci.sh +74 -0
- package/senior-ci/ci/sonar_scanner.py +48 -0
- package/senior-ci/common/__init__.py +250 -0
- package/senior-ci/common/default-files/pom.xml +10 -0
- package/senior-ci/common/docker-helpers.sh +57 -0
- package/senior-ci/common/extensions.py +88 -0
- package/senior-ci/common/flutter-helpers.sh +3 -0
- package/senior-ci/common/getopt_helper.py +168 -0
- package/senior-ci/common/graphql_client.py +40 -0
- package/senior-ci/common/helm_helpers.py +40 -0
- package/senior-ci/common/notification-helpers.sh +15 -0
- package/senior-ci/common/npm-helper.sh +4 -0
- package/senior-ci/common/parallel-helper.sh +8 -0
- package/senior-ci/common/release-helpers.sh +196 -0
- package/senior-ci/common/s3cache-helpers.sh +47 -0
- package/senior-ci/common/senior-ci-extensions-helpers.sh +15 -0
- package/senior-ci/common/sonar_helper.py +203 -0
- package/senior-ci/common/validations/buildable_project.py +61 -0
- package/senior-ci/common/validations/check_deprecated_primitives.py +49 -0
- package/senior-ci/common/validations/check_project_path.py +40 -0
- package/senior-ci/common/validations/check_sonar_config_files.py +41 -0
- package/senior-ci/common/validations/check_tags.py +41 -0
- package/senior-ci/common/validations/validate_changelog.py +151 -0
- package/senior-ci/common/validations/validate_issues.py +320 -0
- package/senior-ci/docker/build.sh +18 -0
- package/senior-ci/docker/config-host.sh +29 -0
- package/senior-ci/docker/deploy-service.sh +79 -0
- package/senior-ci/docker/push.sh +22 -0
- package/senior-ci/frontend/npm/bibliotecas/ci.sh +149 -0
- package/senior-ci/frontend/npm/ci.sh +370 -0
- package/senior-ci/frontend/npm/release-translations.sh +164 -0
- package/senior-ci/helm/deploy.py +56 -0
- package/senior-ci/helm/publish.py +41 -0
- package/senior-ci/hook/release_notification.sh +88 -0
- package/senior-ci/hook/text_notification.sh +10 -0
- package/senior-ci/java/bibliotecas/ci.sh +215 -0
- package/senior-ci/java/sdl/ci.sh +372 -0
- package/senior-ci/java/sdl/scripts/hotfix.sh +78 -0
- package/senior-ci/mobile/flutter/apps/__main__.py +5 -0
- package/senior-ci/mobile/flutter/apps/ci.py +193 -0
- package/senior-ci/mobile/flutter/libs/__main__.py +5 -0
- package/senior-ci/mobile/flutter/libs/ci.py +178 -0
- package/senior-ci/mobile/flutter/scripts/release.sh +54 -0
- package/senior-ci/release-candidate/backend/get_version.sh +64 -0
- package/senior-ci/release-candidate/close_branch.sh +113 -0
- package/senior-ci/release-candidate/common/create_hotfix.sh +28 -0
- package/senior-ci/release-candidate/common/create_release.sh +30 -0
- package/senior-ci/release-candidate/create_branch.sh +64 -0
- package/senior-ci/release-candidate/frontend/get_version.sh +43 -0
- package/senior-ci/requirements-dev.txt +5 -0
- package/senior-ci/requirements.txt +5 -0
- package/senior-ci/scripts/apply_yamls.py +229 -0
- package/senior-ci/scripts/create_sre_issue/__main__.py +7 -0
- package/senior-ci/scripts/create_sre_issue/create_sre_issue.py +267 -0
- package/senior-ci/scripts/create_sre_issue/helpers.py +166 -0
- package/senior-ci/scripts/create_sre_issue/jira_manager.py +37 -0
- package/senior-ci/scripts/validate_changelog.sh +3 -0
- package/senior-ci/sonar-project.properties +1 -0
- package/server.js +5 -0
- package/sonar-project.properties +10 -0
- package/src/app/app.component.html +43 -0
- package/src/app/app.component.scss +36 -0
- package/src/app/app.component.ts +56 -0
- package/src/app/app.module.ts +64 -0
- package/src/app/shared/shared.module.ts +28 -0
- package/src/environments/environment.default.ts +3 -0
- package/src/environments/environment.prod.ts +6 -0
- package/src/environments/environment.ts +7 -0
- package/src/favicon.ico +0 -0
- package/src/index.html +17 -0
- package/src/locale/en-US.json +3 -0
- package/src/locale/es-ES.json +3 -0
- package/src/locale/pt-BR.json +3 -0
- package/src/main.ts +13 -0
- package/src/polyfills.ts +58 -0
- package/src/styles.scss +11 -0
- package/src/tsconfig.app.json +21 -0
- package/src/typings.d.ts +15 -0
- package/tsconfig.json +39 -0
- package/tslint.json +80 -0
- package/bundles/seniorsistemas-exclusion-process-component.umd.js +0 -1205
- package/bundles/seniorsistemas-exclusion-process-component.umd.js.map +0 -1
- package/bundles/seniorsistemas-exclusion-process-component.umd.min.js +0 -16
- package/bundles/seniorsistemas-exclusion-process-component.umd.min.js.map +0 -1
- package/esm2015/enums/enum-exclusion-process-status.js +0 -8
- package/esm2015/exclusion-details/exclusion-details.component.js +0 -216
- package/esm2015/exclusion-details/exclusion-details.module.js +0 -28
- package/esm2015/exclusion-details/index.js +0 -3
- package/esm2015/exclusion-details/protocols/exclusion-details.js +0 -1
- package/esm2015/exclusion-details/protocols/index.js +0 -2
- package/esm2015/exclusion-details/protocols/show-details-information.js +0 -3
- package/esm2015/exclusions-list/exclusions-list.component.js +0 -299
- package/esm2015/exclusions-list/exclusions-list.module.js +0 -47
- package/esm2015/exclusions-list/exclusions-list.routing.js +0 -115
- package/esm2015/exclusions-list/index.js +0 -4
- package/esm2015/logical-delete.module.js +0 -27
- package/esm2015/models/exclusion-process-step-group.js +0 -1
- package/esm2015/models/exclusion-process-step.js +0 -1
- package/esm2015/models/exclusion-process.js +0 -1
- package/esm2015/models/index.js +0 -1
- package/esm2015/models/list-params.js +0 -1
- package/esm2015/models/list-result.js +0 -1
- package/esm2015/models/project-config.js +0 -3
- package/esm2015/public-api.js +0 -4
- package/esm2015/seniorsistemas-exclusion-process-component.js +0 -11
- package/esm2015/services/filter.service.js +0 -104
- package/esm2015/services/index.js +0 -2
- package/esm2015/services/logical-delete-config.service.js +0 -29
- package/esm2015/services/logical-delete.service.js +0 -109
- package/esm5/enums/enum-exclusion-process-status.js +0 -8
- package/esm5/exclusion-details/exclusion-details.component.js +0 -235
- package/esm5/exclusion-details/exclusion-details.module.js +0 -31
- package/esm5/exclusion-details/index.js +0 -3
- package/esm5/exclusion-details/protocols/exclusion-details.js +0 -1
- package/esm5/exclusion-details/protocols/index.js +0 -2
- package/esm5/exclusion-details/protocols/show-details-information.js +0 -7
- package/esm5/exclusions-list/exclusions-list.component.js +0 -313
- package/esm5/exclusions-list/exclusions-list.module.js +0 -50
- package/esm5/exclusions-list/exclusions-list.routing.js +0 -127
- package/esm5/exclusions-list/index.js +0 -4
- package/esm5/logical-delete.module.js +0 -31
- package/esm5/models/exclusion-process-step-group.js +0 -1
- package/esm5/models/exclusion-process-step.js +0 -1
- package/esm5/models/exclusion-process.js +0 -1
- package/esm5/models/index.js +0 -1
- package/esm5/models/list-params.js +0 -1
- package/esm5/models/list-result.js +0 -1
- package/esm5/models/project-config.js +0 -3
- package/esm5/public-api.js +0 -4
- package/esm5/seniorsistemas-exclusion-process-component.js +0 -11
- package/esm5/services/filter.service.js +0 -109
- package/esm5/services/index.js +0 -2
- package/esm5/services/logical-delete-config.service.js +0 -30
- package/esm5/services/logical-delete.service.js +0 -112
- package/exclusion-details/exclusion-details.component.d.ts +0 -49
- package/exclusion-details/exclusion-details.module.d.ts +0 -2
- package/exclusions-list/exclusions-list.component.d.ts +0 -59
- package/exclusions-list/exclusions-list.module.d.ts +0 -2
- package/exclusions-list/exclusions-list.routing.d.ts +0 -29
- package/fesm2015/seniorsistemas-exclusion-process-component.js +0 -917
- package/fesm2015/seniorsistemas-exclusion-process-component.js.map +0 -1
- package/fesm5/seniorsistemas-exclusion-process-component.js +0 -981
- package/fesm5/seniorsistemas-exclusion-process-component.js.map +0 -1
- package/logical-delete.module.d.ts +0 -5
- package/seniorsistemas-exclusion-process-component.d.ts +0 -10
- package/seniorsistemas-exclusion-process-component.metadata.json +0 -1
- package/services/filter.service.d.ts +0 -19
- package/services/logical-delete-config.service.d.ts +0 -8
- package/services/logical-delete.service.d.ts +0 -20
- /package/{exclusion-details/index.d.ts → lib/src/exclusion-details/index.ts} +0 -0
- /package/{exclusion-details/protocols/index.d.ts → lib/src/exclusion-details/protocols/index.ts} +0 -0
- /package/{models/index.d.ts → lib/src/models/index.ts} +0 -0
- /package/{models/list-result.d.ts → lib/src/models/list-result.ts} +0 -0
- /package/{services/index.d.ts → lib/src/services/index.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# GUIA DE CONTRIBUIÇÃO PARA OS SCRIPTS DO SENIOR CI
|
|
2
|
+
|
|
3
|
+
O projeto está em migração para python, logo novas funcionalidades devem estar escritas em python, podendo já utilizar os padrões já existentes.
|
|
4
|
+
|
|
5
|
+
## Configuração de ambiente dev
|
|
6
|
+
|
|
7
|
+
1. Instale e configure o [Docker](https://www.docker.com/get-started) em seu sistema operacional;
|
|
8
|
+
2. Instale o [VS Code](https://code.visualstudio.com) ou [VS Code Insiders](https://code.visualstudio.com/insiders);
|
|
9
|
+
3. Instale as extensões do VS Code:
|
|
10
|
+
* [Dev Containers](vscode:extension/ms-vscode-remote.remote-containers);
|
|
11
|
+
* [SonarLint](vscode:extension/SonarSource.sonarlint-vscode);
|
|
12
|
+
4. [Configure a conexão](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode#connected-mode) com o SonarQube da Senior (https://sonar.senior.com.br);
|
|
13
|
+
5. Abra o projeto e aparecerá uma mensagem com o botão **Reopen in container**, aperte-o; <br/>
|
|
14
|
+
Você também pode executar o comando **Remote-Containers: Reopen in container** via F1;
|
|
15
|
+
6. Basta aguardar o ambiente ser inicializado e configurado. :blue_heart:
|
|
16
|
+
|
|
17
|
+
## Processo de Merge Request
|
|
18
|
+
|
|
19
|
+
Para realizar melhorias ou ajustes nos scripts utilizados na integração contínua dos produtos é necessário seguir os seguintes passos:
|
|
20
|
+
|
|
21
|
+
- Criar um branch no projeto Senior CI a partir da `develop`, no padrão de nomenclatura Senior (e.g. `feature/jira-1234`).
|
|
22
|
+
- Realizar as implementações necessárias para o sua melhoria no branch recém criado.
|
|
23
|
+
- Testar a melhoria em seu projeto que necessita da alteração. (Informações de como testar logo a seguir)
|
|
24
|
+
- Abrir uma issue no Jira para o time DevOps (projeto **DEVOPS** no Jira) solicitando a revisão do Merge Request e a liberação de uma nova versão oficial do Senior CI. Na descrição da issue **deve ser informado o motivo da alteração**, para que possamos entender o contexto (lembrando sempre que deve ser uma alteração que traga melhorias para **todos os outros times de desenvolvimento** e não só da sua equipe).
|
|
25
|
+
- Abrir um Merge Request no Senior CI associado à tarefa no Jira, esta tarefa serve como alerta para a equipe para analisar a alteração e realizar o aceite do merge e a liberação de uma nova versão do Senior CI.
|
|
26
|
+
|
|
27
|
+
## Como testar as alterações no seu projeto?
|
|
28
|
+
|
|
29
|
+
Para testar as alterações em um projeto isolado sem impactar nos demais projetos basta adicionar as variáveis `SCI_VERSION_TAG_BACKEND` e `SCI_VERSION_TAG_FRONTEND` nas configurações do seu **projeto** no GitLab (`Settings > CI / CD > Variables`), informando como valor das variáveis o nome do branch criado no repositório Senior CI com as suas alterações. Desse modo o CI irá utilizar os scripts do branch com a sua implementação na execução de um novo Job do seu projeto.
|
|
30
|
+
|
|
31
|
+
> Ao finalizar as alterações e ser realizado o aceite do Merge Request é importante que as variáveis `SCI_VERSION_TAG_BACKEND` e `SCI_VERSION_TAG_FRONTEND` sejam removidas das configurações do **projeto**. Quando o Merge Request for aceito o branch da implementação será excluído e caso as variáveis não tenham sido removidas ocorrerão erros em **todos os jobs do CI** executados no projeto em questão.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Senior Ci
|
|
2
|
+
|
|
3
|
+
Serviço Integração Continua para as técnologias G7.
|
|
4
|
+
|
|
5
|
+
## Visão geral
|
|
6
|
+
|
|
7
|
+
Este repositório é responsável pelos processos da Integração Continua. O projeto trabalha com os seguintes padrões:
|
|
8
|
+
|
|
9
|
+
- Validate Changelog (Scripts)
|
|
10
|
+
- Teams Hook (Notifications)
|
|
11
|
+
- Release Candidate (GitFlow)
|
|
12
|
+
- Docker
|
|
13
|
+
- JAVA (Openjdk 11)
|
|
14
|
+
- SDL
|
|
15
|
+
- Bibliotecas
|
|
16
|
+
- NPM (Node 10)
|
|
17
|
+
- APP
|
|
18
|
+
- Bibliotecas
|
|
19
|
+
|
|
20
|
+
## Guia de contribuição
|
|
21
|
+
|
|
22
|
+
O [guia de contribuição](CONTRIBUTING.md) é responsável por documentar os procedimentos de manutenção e publicação deste componente.
|
|
23
|
+
|
|
24
|
+
## Documentação de uso
|
|
25
|
+
|
|
26
|
+
As documentações de uso estão descritas na [Wiki](https://git.senior.com.br/engenharia/senior-ci/wikis/home).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e # Exit at first error
|
|
4
|
+
|
|
5
|
+
# Import release helpers
|
|
6
|
+
. senior-ci/common/release-helpers.sh
|
|
7
|
+
|
|
8
|
+
# Import notification helpers
|
|
9
|
+
. senior-ci/common/notification-helpers.sh
|
|
10
|
+
|
|
11
|
+
# Import Senior CI Extensions
|
|
12
|
+
. senior-ci/common/senior-ci-extensions-helpers.sh
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
update_ci_vars() {
|
|
16
|
+
if [ -z "$CQAT_URL" -o -z "$UPDATE_VARS" ]; then
|
|
17
|
+
echo 'As variáveis SCI_VERSION_TAG_FRONTEND, SCI_VERSION_TAG_BACKEND não serão atualizadas nos grupos, pois as variáveis CQAT_URL e UPDATE_VARS não estão definidas'
|
|
18
|
+
else
|
|
19
|
+
echo 'Atualizando variáveis SCI_VERSION_TAG_FRONTEND, SCI_VERSION_TAG_BACKEND em todos os grupos'
|
|
20
|
+
echo "SCI_VERSION_TAG_FRONTEND e SCI_VERSION_TAG_BACKEND = $VERSION_HYPHEN"
|
|
21
|
+
|
|
22
|
+
DATA='{'
|
|
23
|
+
DATA+='"query":"mutation($versionOfSeniorCI: String) {'
|
|
24
|
+
DATA+='updateVersionVars(version: $versionOfSeniorCI) { success, reason }'
|
|
25
|
+
DATA+='}",'
|
|
26
|
+
DATA+='"variables":{ "versionOfSeniorCI":"'$VERSION_HYPHEN'" }'
|
|
27
|
+
DATA+='}'
|
|
28
|
+
|
|
29
|
+
curl "$CQAT_URL"/graphql \
|
|
30
|
+
-X POST \
|
|
31
|
+
-H 'Content-Type: application/json' \
|
|
32
|
+
--data "$DATA"
|
|
33
|
+
fi
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
SONAR_URL="http://sonar.senior.com.br"
|
|
37
|
+
|
|
38
|
+
getopts "rux" op;
|
|
39
|
+
case "$op" in
|
|
40
|
+
r) echo "[CI] Starting Self-Release"
|
|
41
|
+
unshallow_repo
|
|
42
|
+
|
|
43
|
+
get_next_version $2
|
|
44
|
+
|
|
45
|
+
call_extension "before_release"
|
|
46
|
+
|
|
47
|
+
create_release_branch
|
|
48
|
+
|
|
49
|
+
call_extension "before_change_changelog"
|
|
50
|
+
|
|
51
|
+
update_changelog
|
|
52
|
+
|
|
53
|
+
call_extension "after_change_changelog"
|
|
54
|
+
|
|
55
|
+
create_release_tag
|
|
56
|
+
|
|
57
|
+
call_extension "after_release"
|
|
58
|
+
|
|
59
|
+
update_ci_vars
|
|
60
|
+
|
|
61
|
+
notify_release_teams_channel
|
|
62
|
+
;;
|
|
63
|
+
|
|
64
|
+
u) echo "[CI] Atualizando variáveis do CI"
|
|
65
|
+
unshallow_repo
|
|
66
|
+
|
|
67
|
+
VERSION_HYPHEN=`git describe --tags --abbrev=0`
|
|
68
|
+
|
|
69
|
+
update_ci_vars
|
|
70
|
+
;;
|
|
71
|
+
x) echo "[CI] Realizando análise e publicação dos resultados no SonarQube - $SONAR_URL"
|
|
72
|
+
python3 senior-ci/ci/sonar_scanner.py
|
|
73
|
+
;;
|
|
74
|
+
esac
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
sys.path.append("./senior-ci")
|
|
4
|
+
|
|
5
|
+
from common import exit_message
|
|
6
|
+
from common.getopt_helper import GetOptBuilder, Param
|
|
7
|
+
from common.sonar_helper import SonarHelper, SonarScannerType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SonarScannerCI(GetOptBuilder):
|
|
11
|
+
def __init__(self, argv):
|
|
12
|
+
builder = super()
|
|
13
|
+
builder.__init__(argv)
|
|
14
|
+
|
|
15
|
+
type_param = Param("type")
|
|
16
|
+
skip_param = Param("skip", default_value="False")
|
|
17
|
+
|
|
18
|
+
builder.add_param(type_param)
|
|
19
|
+
builder.add_param(skip_param)
|
|
20
|
+
|
|
21
|
+
builder.build()
|
|
22
|
+
|
|
23
|
+
scanner_type_str: str = type_param.get_param_value()
|
|
24
|
+
skip_build_str = skip_param.get_param_value()
|
|
25
|
+
|
|
26
|
+
skip_build = skip_build_str != "False"
|
|
27
|
+
|
|
28
|
+
scanner_type = None
|
|
29
|
+
|
|
30
|
+
if scanner_type_str:
|
|
31
|
+
try:
|
|
32
|
+
scanner_type = SonarScannerType[scanner_type_str]
|
|
33
|
+
except Exception:
|
|
34
|
+
all_scanner_types = [s_t.value for s_t in SonarScannerType]
|
|
35
|
+
exit_message(
|
|
36
|
+
f"Tipo informado inválido, os válidos são {all_scanner_types}",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
self.sonar_helper = SonarHelper(
|
|
40
|
+
sonar_scanner_type=scanner_type, skip_build=skip_build
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def exec(self):
|
|
44
|
+
self.sonar_helper.scanner_analyze()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
sonar_scanner_ci = SonarScannerCI(sys.argv[1:])
|
|
48
|
+
sonar_scanner_ci.exec()
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"""Module for common methods used on entire application"""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import random
|
|
5
|
+
import string
|
|
6
|
+
import sys
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
from enum import Enum
|
|
9
|
+
from subprocess import PIPE, STDOUT, Popen
|
|
10
|
+
from typing import List, NoReturn
|
|
11
|
+
|
|
12
|
+
from colorama import Back, Fore, Style
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ExitCode(Enum):
|
|
16
|
+
SUCCESS = 0
|
|
17
|
+
ERROR = 1
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Command(object):
|
|
21
|
+
output = ""
|
|
22
|
+
cmd: str
|
|
23
|
+
exit_code: ExitCode
|
|
24
|
+
|
|
25
|
+
def __init__(self, cmd: str):
|
|
26
|
+
self.cmd = cmd
|
|
27
|
+
|
|
28
|
+
def run(
|
|
29
|
+
self,
|
|
30
|
+
print_command=True,
|
|
31
|
+
print_output=True,
|
|
32
|
+
):
|
|
33
|
+
if print_command:
|
|
34
|
+
print_message(self.cmd)
|
|
35
|
+
|
|
36
|
+
process = Popen(
|
|
37
|
+
self.cmd,
|
|
38
|
+
stdout=PIPE,
|
|
39
|
+
stderr=STDOUT,
|
|
40
|
+
shell=True,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
while True:
|
|
44
|
+
line = process.stdout.readline()
|
|
45
|
+
if not line:
|
|
46
|
+
break
|
|
47
|
+
|
|
48
|
+
self.output += line.decode()
|
|
49
|
+
|
|
50
|
+
if print_output:
|
|
51
|
+
print(line.decode().replace("\n", ""))
|
|
52
|
+
|
|
53
|
+
exit_code = process.wait()
|
|
54
|
+
|
|
55
|
+
self._set_exit_code(exit_code)
|
|
56
|
+
|
|
57
|
+
return self
|
|
58
|
+
|
|
59
|
+
def _set_exit_code(self, exit_code: int):
|
|
60
|
+
if exit_code == 0:
|
|
61
|
+
self.exit_code = ExitCode.SUCCESS
|
|
62
|
+
else:
|
|
63
|
+
self.exit_code = ExitCode.ERROR
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def get_env_variable(variable_name: str, default_value: str = None) -> str:
|
|
67
|
+
"""Get the environment variable"""
|
|
68
|
+
|
|
69
|
+
var = os.getenv(variable_name)
|
|
70
|
+
|
|
71
|
+
if not var:
|
|
72
|
+
var = default_value
|
|
73
|
+
|
|
74
|
+
return var
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def get_env_variable_required(variable_name: str) -> str:
|
|
78
|
+
"""Get the environment variable and check if exist"""
|
|
79
|
+
|
|
80
|
+
var = get_env_variable(variable_name)
|
|
81
|
+
|
|
82
|
+
if not var:
|
|
83
|
+
exit_message(f"Variável obrigatória não informada: {variable_name}")
|
|
84
|
+
|
|
85
|
+
return var
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def convert_tag_to_semver(tag: str) -> str:
|
|
89
|
+
"""Convert a Gitlab Tag to semver format (vX-Y-Z => X.Y.Z)"""
|
|
90
|
+
|
|
91
|
+
return tag.replace("v", "").replace("-", ".")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def get_commit_tag_as_semver() -> str or None:
|
|
95
|
+
"""Get version from gitlab variable CI_COMMIT_TAG
|
|
96
|
+
and format it to semver format (vX-Y-Z => X.Y.Z)
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
commit_tag = get_env_variable_required("CI_COMMIT_TAG")
|
|
100
|
+
|
|
101
|
+
return convert_tag_to_semver(commit_tag) if commit_tag else None
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def get_version_from_gitlab() -> str:
|
|
105
|
+
"""Get version from gitlab variables
|
|
106
|
+
|
|
107
|
+
Get the tag if running from a tag or
|
|
108
|
+
add the branch name and SNAPSHOT
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
version = get_commit_tag_as_semver()
|
|
112
|
+
|
|
113
|
+
if not version:
|
|
114
|
+
commit_ref_slug = get_env_variable_required("CI_COMMIT_REF_SLUG")
|
|
115
|
+
|
|
116
|
+
version = f"{commit_ref_slug}-SNAPSHOT"
|
|
117
|
+
|
|
118
|
+
return version
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def print_message(message: str, fore_color=None) -> NoReturn:
|
|
122
|
+
"""Print a colored message"""
|
|
123
|
+
|
|
124
|
+
colored_message = get_colored_message(message, fore_color)
|
|
125
|
+
|
|
126
|
+
print(colored_message)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def print_messages(messages: List[str], fore_color=None) -> NoReturn:
|
|
130
|
+
"""Print many colored messages"""
|
|
131
|
+
|
|
132
|
+
for message in messages:
|
|
133
|
+
print_message(message, fore_color)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def get_colored_message(
|
|
137
|
+
message, fore_color: Fore = None, back_color: Back = None
|
|
138
|
+
) -> str:
|
|
139
|
+
"""Color a message"""
|
|
140
|
+
|
|
141
|
+
fore_color_code = fore_color if fore_color else ""
|
|
142
|
+
back_color_code = back_color if back_color else ""
|
|
143
|
+
|
|
144
|
+
reset_style_code = Style.RESET_ALL if back_color or fore_color else ""
|
|
145
|
+
|
|
146
|
+
return f"{back_color_code}{fore_color_code}[CI] {message}{reset_style_code}"
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def start_collapsible_section(header: str, fore_color: Fore = None) -> str:
|
|
150
|
+
"""Print a message with the GitLab syntax to create a collapse section
|
|
151
|
+
and return the id for use when close the section
|
|
152
|
+
|
|
153
|
+
https://docs.gitlab.com/ee/ci/jobs/index.html#custom-collapsible-sections
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
section_id = "".join(random.choices(string.ascii_uppercase + string.digits, k=10))
|
|
157
|
+
|
|
158
|
+
colored_header = get_colored_message(header, fore_color)
|
|
159
|
+
|
|
160
|
+
print(" ")
|
|
161
|
+
print(
|
|
162
|
+
f"\033[0Ksection_start:{datetime.utcnow().strftime('%s')}:{section_id}\r\033[0K{colored_header}"
|
|
163
|
+
)
|
|
164
|
+
print(" ")
|
|
165
|
+
|
|
166
|
+
return section_id
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def end_collapsible_section(section_id: str) -> NoReturn:
|
|
170
|
+
"""Close the section"""
|
|
171
|
+
|
|
172
|
+
print(
|
|
173
|
+
f"\033[0Ksection_end:{datetime.utcnow().strftime('%s')}:{section_id}\r\033[0K"
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def exit_message(message: str) -> NoReturn:
|
|
178
|
+
"""Print a red error message and stop the execution"""
|
|
179
|
+
|
|
180
|
+
print_message(message, Fore.LIGHTRED_EX)
|
|
181
|
+
sys.exit(2)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def exec_command(command: str, print_command=True, print_output=True) -> Command:
|
|
185
|
+
"""Run a command"""
|
|
186
|
+
|
|
187
|
+
cmd = Command(command)
|
|
188
|
+
return cmd.run(print_command, print_output)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def exec_command_without_print(command: str) -> NoReturn:
|
|
192
|
+
"""
|
|
193
|
+
Deprecated: use directly `exec_command(command, print_command=False)`
|
|
194
|
+
|
|
195
|
+
Execute a command without print it
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
exec_command(command, print_command=False)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def exec_command_and_return(command) -> Command:
|
|
202
|
+
"""
|
|
203
|
+
Deprecated: use directly `exec_command(command)`
|
|
204
|
+
|
|
205
|
+
Print a command then execute and return the output
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
return exec_command(command)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def cd_path(path: str) -> NoReturn:
|
|
212
|
+
"""Print a path then navigate"""
|
|
213
|
+
|
|
214
|
+
print(f"Navigating to path: {path}", flush=True)
|
|
215
|
+
os.chdir(path)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def unshallow_repo() -> NoReturn:
|
|
219
|
+
"""Get all references of repository"""
|
|
220
|
+
|
|
221
|
+
section_id = start_collapsible_section(
|
|
222
|
+
"Atualizando repositório git com todas as referências", Fore.YELLOW
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
is_shallow = exec_command(
|
|
226
|
+
"git rev-parse --is-shallow-repository", print_output=False
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
if is_shallow.output.rstrip() == "true":
|
|
230
|
+
exec_command("git fetch --unshallow", print_output=False)
|
|
231
|
+
|
|
232
|
+
exec_command("git fetch --all", print_output=False)
|
|
233
|
+
|
|
234
|
+
print_message("Repositório atualizado")
|
|
235
|
+
|
|
236
|
+
end_collapsible_section(section_id)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def is_path_exist(path: str) -> bool:
|
|
240
|
+
"""Validate the existence of a path"""
|
|
241
|
+
|
|
242
|
+
return os.path.exists(path)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def is_frontend() -> bool:
|
|
246
|
+
"""Verify if project is frontend"""
|
|
247
|
+
|
|
248
|
+
ci_project_name = get_env_variable_required("CI_PROJECT_NAME")
|
|
249
|
+
|
|
250
|
+
return "-frontend" in ci_project_name
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
2
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
3
|
+
<modelVersion>4.0.0</modelVersion>
|
|
4
|
+
<groupId>br.com.senior</groupId>
|
|
5
|
+
<artifactId>ci-default-template</artifactId>
|
|
6
|
+
<packaging>jar</packaging>
|
|
7
|
+
<version>1.0-SNAPSHOT</version>
|
|
8
|
+
<dependencies>
|
|
9
|
+
</dependencies>
|
|
10
|
+
</project>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
docker_login() {
|
|
4
|
+
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASS
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
create_dockerhub_repo(){
|
|
8
|
+
if [ -z "$SKIP_REPOCREATION" ]; then
|
|
9
|
+
echo "[CI] Verificando se o repositorio ja existe no Dockerhub"
|
|
10
|
+
|
|
11
|
+
SDL_PROPERTIES="sdl.properties"
|
|
12
|
+
POM_XML="pom.xml"
|
|
13
|
+
|
|
14
|
+
if [[ -z "$SVC_IMAGE" && -f "$SDL_PROPERTIES" ]]; then
|
|
15
|
+
IMAGE_NAME=`cat $SDL_PROPERTIES | sed -n -e 's/generator.app.name=//p'`
|
|
16
|
+
IMAGE_NAME=`echo ${IMAGE_NAME%%[[:cntrl:]]} | xargs`
|
|
17
|
+
elif [[ -z "$SVC_IMAGE" && -f "$POM_XML" ]]; then
|
|
18
|
+
IMAGE_NAME=`mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout`
|
|
19
|
+
IMAGE_NAME=`echo ${IMAGE_NAME%%[[:cntrl:]]} | xargs`
|
|
20
|
+
elif [ -n "$SVC_IMAGE" ]; then
|
|
21
|
+
IMAGE_NAME=$SVC_IMAGE
|
|
22
|
+
else
|
|
23
|
+
echo "[CI] Não foi possível encontrar o nome da imagem do serviço. Por favor entre com contato com a equipe DevOps."
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
echo "[CI] Validando o repo $IMAGE_NAME no Dockerhub. Para o projeto no gitlab $CI_PROJECT_NAME"
|
|
28
|
+
|
|
29
|
+
DATA='{
|
|
30
|
+
"query": "mutation($repository: String, $gitRepo: String) { createDockerhubRepo(repository: $repository, gitRepo: $gitRepo) { result } }",
|
|
31
|
+
"variables": { "repository":"'$IMAGE_NAME'","gitRepo":"'$CI_PROJECT_NAME'" }
|
|
32
|
+
}'
|
|
33
|
+
|
|
34
|
+
RESPONSE_CQAT=`curl -sS \
|
|
35
|
+
-X POST \
|
|
36
|
+
-H "Content-Type: application/json" \
|
|
37
|
+
--data "$DATA" \
|
|
38
|
+
$CQAT_URL/graphql`
|
|
39
|
+
|
|
40
|
+
if jq -e . >/dev/null 2>&1 <<<"$RESPONSE_CQAT"; then
|
|
41
|
+
echo "[CI] Validando retorno da criação do repo."
|
|
42
|
+
else
|
|
43
|
+
echo "[CI] Não foi possível se comunicar com o CQAT. Por favor entre com contato com a equipe DevOps."
|
|
44
|
+
echo $RESPONSE_CQAT
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
ERROR_MESSAGES=`echo $RESPONSE_CQAT | jq -r ".errors | if . != null then .[].message else empty end" 2>&-`
|
|
49
|
+
|
|
50
|
+
if [ -n "$ERROR_MESSAGES" ]; then
|
|
51
|
+
echo "[CI] Ocorreu um erro ao executar a validação/criação do repo."
|
|
52
|
+
echo $ERROR_MESSAGES
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
fi
|
|
56
|
+
}
|
|
57
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Extension module to create customizations"""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import importlib
|
|
5
|
+
import importlib.util
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
sys.path.append("./senior-ci")
|
|
9
|
+
|
|
10
|
+
from . import print_message
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Extensions:
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
):
|
|
17
|
+
senior_ci_extensions_file = Path(".senior_ci_extensions.py")
|
|
18
|
+
|
|
19
|
+
self.senior_ci_extensions = None
|
|
20
|
+
if senior_ci_extensions_file.is_file():
|
|
21
|
+
print_message(
|
|
22
|
+
"Carregando arquivo de extensões - .senior_ci_extensions.py"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
spec = importlib.util.spec_from_file_location(
|
|
26
|
+
"senior_ci_extensions", senior_ci_extensions_file
|
|
27
|
+
)
|
|
28
|
+
self.senior_ci_extensions = importlib.util.module_from_spec(spec)
|
|
29
|
+
spec.loader.exec_module(self.senior_ci_extensions)
|
|
30
|
+
|
|
31
|
+
else:
|
|
32
|
+
print_message(
|
|
33
|
+
"Arquivo de extensões não encontrado (.senior_ci_extensions.py). Continuando execução padrão do CI."
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def before_build(self):
|
|
37
|
+
self._exec_hook("before_build")
|
|
38
|
+
|
|
39
|
+
def after_build(self):
|
|
40
|
+
self._exec_hook("after_build")
|
|
41
|
+
|
|
42
|
+
def before_release_snapshot(self):
|
|
43
|
+
self._exec_hook("before_release_snapshot")
|
|
44
|
+
|
|
45
|
+
def after_release_snapshot(self):
|
|
46
|
+
self._exec_hook("after_release_snapshot")
|
|
47
|
+
|
|
48
|
+
def before_release(self):
|
|
49
|
+
self._exec_hook("before_release")
|
|
50
|
+
|
|
51
|
+
def after_release(self):
|
|
52
|
+
self._exec_hook("after_release")
|
|
53
|
+
|
|
54
|
+
def before_change_changelog(self):
|
|
55
|
+
self._exec_hook("before_change_changelog")
|
|
56
|
+
|
|
57
|
+
def after_change_changelog(self):
|
|
58
|
+
self._exec_hook("after_change_changelog")
|
|
59
|
+
|
|
60
|
+
def before_packaging(self):
|
|
61
|
+
self._exec_hook("before_packaging")
|
|
62
|
+
|
|
63
|
+
def after_packaging(self):
|
|
64
|
+
self._exec_hook("after_packaging")
|
|
65
|
+
|
|
66
|
+
def before_deploy(self):
|
|
67
|
+
self._exec_hook("before_deploy")
|
|
68
|
+
|
|
69
|
+
def after_deploy(self):
|
|
70
|
+
self._exec_hook("after_deploy")
|
|
71
|
+
|
|
72
|
+
def before_sonar(self):
|
|
73
|
+
self._exec_hook("before_sonar")
|
|
74
|
+
|
|
75
|
+
def after_sonar(self):
|
|
76
|
+
self._exec_hook("after_sonar")
|
|
77
|
+
|
|
78
|
+
def _exec_hook(self, hook):
|
|
79
|
+
if self.senior_ci_extensions and hasattr(self.senior_ci_extensions, hook):
|
|
80
|
+
print_message(f"Disparando hook {hook} do .senior_ci_extensions.py")
|
|
81
|
+
hook = getattr(self.senior_ci_extensions, hook)
|
|
82
|
+
hook()
|
|
83
|
+
|
|
84
|
+
self.do_nothing()
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def do_nothing():
|
|
88
|
+
"""Method for when the hook was not found"""
|