Merge pull request #10 from dadosfera/ci/cd

Ci/cd
This commit is contained in:
Victor Radael
2022-02-08 15:26:01 -03:00
committed by GitHub
51 changed files with 348 additions and 134 deletions
-1
View File
@@ -1 +0,0 @@
TEST=test
+90
View File
@@ -0,0 +1,90 @@
name: Deploy
on:
push:
branches:
- dev
- stg
- main
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
semantic_version: 16
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
conventional-changelog-eslint
branches: |
['main']
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Pip
run: |
python3 -m pip install --upgrade pip
- name: Install Docker Compose
run: |
python3 -m pip install docker-compose --upgrade
- name: Install AWS CLI
run: |
python3 -m pip install awscli --upgrade
- name: Install AWS Elastic Beanstalk ClI
run: |
python3 -m pip install awsebcli --upgrade
- name: Configure AWS Region
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-east-1
- name: Extract Environment
shell: bash
run: |
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
echo "##[set-output name=result;]$(echo "prd")"
else
echo "##[set-output name=result;]$(echo ${GITHUB_REF#refs/heads/})"
fi
id: extract_environment
- name: Login to AWS ECR
id: login_ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, Tag, and Push Image to AWS ECR
env:
ENV: ${{ steps.extract_environment.outputs.result }}
IMAGE_TAG: latest
run: |
export ENV=$ENV
docker-compose -f build.docker-compose.yml build
docker-compose -f build.docker-compose.yml push
- name: Create ZIP file to Deploy AWS Beanstalk
env:
ENV: ${{ steps.extract_environment.outputs.result }}
run: |
sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml
zip deploy.zip docker-compose.yml
- name: Deploy AWS Beanstalk
env:
ENV: ${{ steps.extract_environment.outputs.result }}
AWS_REGION: us-east-1
APP_NAME: maestro
run: |
printf "n" | eb init $APP_NAME --region $AWS_REGION
eb use $APP_NAME-$ENV
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
eb deploy
+31
View File
@@ -0,0 +1,31 @@
name: Test
on:
pull_request:
branches:
- dev
- stg
- main
jobs:
test:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Docker Compose
run: |
python3 -m pip install docker-compose --upgrade
- name: Build
env:
ENV: ${{ steps.extract_environment.outputs.result }}
IMAGE_TAG: latest
run: |
export ENV=test
docker-compose -f build.docker-compose.yml build
- name: Run Test
run: |
export ENV=test
docker-compose run --rm maestro npm run test
+7 -1
View File
@@ -34,4 +34,10 @@ lerna-debug.log*
!.vscode/launch.json
!.vscode/extensions.json
.env
# Ignore .env files
*.env
# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
+6
View File
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
+1 -1
View File
@@ -1,4 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
}
+48
View File
@@ -0,0 +1,48 @@
{
"branch": "dev",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "eslint",
"releaseRules": [
{ "tag": "Breaking", "release": "major" },
{ "tag": "Build", "release": "minor" },
{ "tag": "Chore", "release": "minor" },
{ "tag": "Fix", "release": "patch" },
{ "tag": "New", "release": "minor" },
{ "tag": "Update", "release": "minor" },
{ "tag": "Upgrade", "release": "minor" }
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "eslint",
"releaseRules": [
{ "tag": "Breaking", "release": "major" },
{ "tag": "Build", "release": "minor" },
{ "tag": "Chore", "release": "minor" },
{ "tag": "Fix", "release": "patch" },
{ "tag": "New", "release": "minor" },
{ "tag": "Update", "release": "minor" },
{ "tag": "Upgrade", "release": "minor" }
]
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
"@semantic-release/github",
[
"@semantic-release/git", {
"assets": ["package.json", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
+1 -1
View File
@@ -9,4 +9,4 @@ COPY . /app/
COPY --from=packages /packages/node_modules /app/node_modules
RUN npm run build
EXPOSE 3333
ENTRYPOINT npm run start
ENTRYPOINT npm run start
+5
View File
@@ -0,0 +1,5 @@
version: "3.8"
services:
maestro:
build: .
image: 468720548566.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:latest
+27
View File
@@ -0,0 +1,27 @@
version: "3.8"
services:
maestro:
image: 468720548566.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:latest
container_name: maestro
restart: always
ports:
- 3333:3333
node_exporter:
image: prom/node-exporter:v1.3.1
container_name: node_exporter
restart: always
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
- /run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
- '--collector.systemd'
- '--collector.processes'
network_mode: host
pid: host
+6 -6
View File
@@ -21,12 +21,12 @@ import { RestEnrichmentsController } from './rest/rest-enrichments/rest-enrichme
import { RestFactoryController } from './rest/rest-factory/rest-factory.controller';
import { HealthModule } from './health/health.module';
@Module({
imports: [
RestInputsModule, RestOutputsModule, RestEnrichmentsModule, RestTransformationsModule, RestPipelinesModule, RestUserModule, RestFactoryModule, HealthModule,
// InputGrpcClientModule,
imports: [
RestInputsModule, RestOutputsModule, RestEnrichmentsModule, RestTransformationsModule, RestPipelinesModule, RestUserModule, RestFactoryModule, HealthModule,
// InputGrpcClientModule,
//OutputsModule,
//EnrichmentModule,
//TransformationsModule,
//EnrichmentModule,
//TransformationsModule,
//PipelinesModule
],
controllers: [],
@@ -39,6 +39,6 @@ export class AppModule implements NestModule{
.apply(LoggerMiddleware)
.forRoutes(RestInputsController,RestOutputsController,RestTransformationsController,RestPipelinesController,RestEnrichmentsController,RestFactoryController)
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
export class CreateEnrichmentDto {
type:string;
columns:string[]
+1
View File
@@ -17,6 +17,7 @@ import { GrpcClientConfiguration } from './config/grpc-client';
@ApiTags('enrichments')
@Controller('enrichment')
export class EnrichmentController implements OnModuleInit {
@Client(GrpcClientConfiguration)
private enrichmentServiceClient: ClientGrpc;
-1
View File
@@ -41,4 +41,3 @@ message CreateEnrichmentRequest {
message ListResponse {
repeated Enrichment enrichments = 2;
}
@@ -2,12 +2,12 @@
export class CreateInputGrpcClientDto {
cron:string;
name:string;
plugin:string;
values:string;
operation:string;
}
@@ -3,4 +3,3 @@ export class TestConnectionDTO{
values:string;
plugin:string;
}
@@ -1,14 +1,14 @@
export class InputGrpcClient {
id:string;
cron:string;
name:string;
plugin:string;
values:string;
operation:string;
}
+1 -1
View File
@@ -5,7 +5,7 @@ import { InputGrpcClientController } from './input-grpc-client.controller';
@Module({
controllers: [
InputGrpcClientController,
InputGrpcClientController,
// InputRestClientController
],
providers: [InputGrpcClientService],
+6 -6
View File
@@ -8,7 +8,7 @@ import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
@Controller('input')
export class InputRestClientController {
@Get('/test-connection/')
async testConnection(){
console.log(process.env.DEV_URL+`/test-connection`, "ON TEST CONNECTION ROUTE")
@@ -16,17 +16,17 @@ export class InputRestClientController {
return response
})
}
@Post()
async create(@Body() createInputDto: CreateInputGrpcClientDto){
console.log(createInputDto)
console.log(process.env.DEV_URL+`/input`, "ON CREATE ROUTE")
await axios.post(process.env.DEV_URL+'/input',createInputDto).then( (response) => {
return response
})
}
@Get()
async list(){
console.log(process.env.DEV_URL+`/input`, "ON GET ROUTE")
@@ -43,7 +43,7 @@ export class InputRestClientController {
return response
})
}
@Put(':id')
async update(
@@ -60,7 +60,7 @@ export class InputRestClientController {
@Delete(':id')
async delete(@Param() id: string){
console.log(process.env.DEV_URL+`/input/${id}`, "ON DELETE ROUTE")
await axios.delete(process.env.DEV_URL+`/input/${id}`).then( (response) => {
return response
})
+2 -2
View File
@@ -58,8 +58,8 @@ message TestConnectionRequest{
}
message TestConnectionResponse{
// nao sei como vai ser a resposta
bool respose = 1;
}
}
+2 -2
View File
@@ -3,7 +3,7 @@ import axios from 'axios';
import { NestMiddleware } from '@nestjs/common';
export class LoggerMiddleware implements NestMiddleware{
use = async (
request: Request,
@@ -27,4 +27,4 @@ export class LoggerMiddleware implements NestMiddleware{
}
};
}
}
-1
View File
@@ -5,4 +5,3 @@ export class CreateOutputDto {
values:string;
operation:string;
}
+1 -1
View File
@@ -2,5 +2,5 @@ import { PartialType } from '@nestjs/mapped-types';
import { CreateOutputDto } from './create-output.dto';
export class UpdateOutputDto extends PartialType(CreateOutputDto) {
}
+2
View File
@@ -19,7 +19,9 @@ import { UpdatePipelineDto } from './dto/update-pipeline.dto';
import { GrpcClientConfiguration } from './config/grpc-client';
@Controller('pipeline')
export class PipelinesController implements OnModuleInit {
@Client(GrpcClientConfiguration)
private pipelineServiceClient: ClientGrpc;
+4 -4
View File
@@ -37,7 +37,7 @@ message Input {
string values = 5;
string operation = 6;
}
message Output {
string id = 1;
string name = 2;
@@ -80,12 +80,12 @@ message ListResponse {
message getPipelineLogsMessagesRequest{
string id = 1;
string details = 2;
string details = 2;
}
message getPipelineLogsMessagesResponseItem{
string date = 1;
string log = 2;
string log = 2;
}
message getPipelineLogsMessagesResponse{
@@ -94,4 +94,4 @@ message getPipelineLogsMessagesResponse{
message getPipelineStatusResponse{
string status = 1;
}
}
@@ -1,5 +1,5 @@
export class CreateRestEnrichmentDto {
type:string;
columns
@@ -59,7 +59,7 @@ export class RestEnrichmentsController {
@Put(':id')
async update(@Param('id') id: string,@Headers() headers, @Body() body: UpdateRestEnrichmentDto) {
const connectionResponse = await axios.put(
`${process.env.DEV_URL}/enrichment/${id}`,
body,
@@ -2,16 +2,16 @@ import { ApiProperty } from "@nestjs/swagger";
export class HTTPInputValues{
@ApiProperty({
description:"Choosen url",
example:"http://testroute/dadosfera/inputs/values"
})
urls:string;
@ApiProperty({
description:"Schedule name",
example:"Test_Schedule"
})
schedule:string
}
}
@@ -2,52 +2,52 @@ import { ApiProperty } from "@nestjs/swagger";
export class JDBCInputvalues{
@ApiProperty({
description:"JDBC user",
example:"airflow"
})
jdbc_user: string;
@ApiProperty({
description:"JDBC password",
example:"password123"
})
jdbc_password: string;
@ApiProperty({
description:"Database",
example:"airflow"
})
database: string;
@ApiProperty({
description:"Connection endpoint",
example:"dadosfera-postgres-db.test123.us-east"
})
endpoint: string;
@ApiProperty({
description:"Schema name",
example:"cadastros"
})
schema?:string;
@ApiProperty({
description:"Tables names",
example:["pessoas", "clients"]
})
table: string[];
@ApiProperty({
description:"Port",
example:"5432"
})
port: string;
@ApiProperty({
description:"Engine name",
example:"postgres"
})
engine: string;
}
}
@@ -29,19 +29,19 @@ export class CreateRestInputDto {
}
})
cron:CronDTO;
@ApiProperty({
description:"Name of the input",
example:"Test_Input"
})
name:string;
@ApiProperty({
description:"Plugin",
example:"s3"
})
plugin:string;
@ApiProperty({
description:"Values for choosen input",
example:{
@@ -55,7 +55,7 @@ export class CreateRestInputDto {
}
})
values: SalesforceInputValuesDTO|HTTPInputValues|S3InputValues|JDBCInputvalues;
@ApiProperty({
description:"Operation name",
example:"input"
+15 -15
View File
@@ -14,89 +14,89 @@ export class CronDTO{
example:true
})
hour_interval: boolean;
@ApiProperty({
description:"Boolean for hour resourse",
example:true
})
hour_resourse: boolean;
@ApiProperty({
description:"Value for hour resourse",
example:3
})
hour_resourse_value: number;
@ApiProperty({
description:"Month day to the cron",
example:["3"]
})
month_day: string[];
@ApiProperty({
description:"Boolean for month day interval",
example:true
})
month_day_interval: boolean;
@ApiProperty({
description:"Boolean for month day resourse",
example:false
})
month_day_resourse: boolean;
@ApiProperty({
description:"Value for month day resourse",
example:null
})
month_day_resourse_value:number|null;
@ApiProperty({
description:"Month to the cron",
example:["3"]
})
month: string[];
@ApiProperty({
description:"Boolean from month interval",
example:false
})
month_interval: boolean;
@ApiProperty({
description:"Boolean from month resourse",
example:false
})
month_resourse: boolean;
@ApiProperty({
description:"Value to month resourse",
example:null
})
month_resourse_value:number|null;
@ApiProperty({
description:"Week days to the cron",
example:[]
})
week_days: string[];
@ApiProperty({
description:"Boolean for the week days",
example:false
})
week_days_interval: boolean;
@ApiProperty({
description:"Boolean for week day resourse",
example:false
})
week_days_resourse: boolean;
@ApiProperty({
description:"Hours to the cron",
example:null
})
week_days_resourse_value:number|null
}
}
@@ -14,37 +14,37 @@ export class S3InputValues{
example:"dadosfera-test"
})
target_bucket?: string;
@ApiProperty({
description:"client bucket path",
example:"dadosfera-test"
})
client_bucket: string;
@ApiProperty({
description:"Format to the file",
example:"csv"
})
format_file: string;
@ApiProperty({
description:"Clients AWS Access Key Id",
example:"AKIBN5B19D3NGZI"
})
client_aws_access_key_id: string;
@ApiProperty({
description:"Clients AWS Secret Access Key Id",
example:"ct5R1EjrVC78bvaJ636gG90O5NqOrOUoq4Ri"
})
client_aws_secret_access_key : string;
@ApiProperty({
description:"file params format",
example:{sep: "," , header: "true"}
})
format_file_params?: {
sep: string,
sep: string,
header: string
}
}
}
@@ -8,20 +8,20 @@ export class SalesforceInputValuesDTO{
example:"dadosfera@devs.com"
})
username_salesforce: string;
@ApiProperty({
description:"Salesforce password",
example:"Salesforce@test123"
})password_salesforce: string;
@ApiProperty({
description:"Salesforce Security Token",
example:"A67Tdg7qHUvhZDOFjWwtPMjmQ"
})security_token_salesforce: string;
@ApiProperty({
description:"Salesforce Query",
example:"SELECT * FROM Users"
})query_salesforce: string;
}
}
@@ -18,7 +18,7 @@ export class testConnectionDTO{
description:"Plugin name",
example:{
plugin: "mysql",
values: {
values: {
jdbc_user: "test",
jdbc_password: "test1234",
database: "users",
@@ -29,6 +29,6 @@ export class testConnectionDTO{
}
}
})
values:HTTPInputValues|SalesforceInputValuesDTO|S3InputValues|JDBCInputvalues
}
}
@@ -1,14 +1,14 @@
export class RestInput {
id:string;
cron:string;
name:string;
plugin:string;
values:string;
operation:string;
}
@@ -28,7 +28,7 @@ export class RestInputsController {
}
)
return connectionResponse.data
}
@@ -46,7 +46,7 @@ export class RestInputsController {
}
)
return connectionResponse.data
}
@@ -62,7 +62,7 @@ export class RestInputsController {
}
)
return connectionResponse.data
}
@@ -78,7 +78,7 @@ export class RestInputsController {
}
)
return connectionResponse.data
}
@@ -100,7 +100,7 @@ export class RestInputsController {
}
)
return connectionResponse.data
}
@@ -116,7 +116,7 @@ export class RestInputsController {
}
)
return connectionResponse.data
}
@@ -7,13 +7,13 @@ export class CreateRestOutputDto {
example:"Test Output"
})
name:string;
@ApiProperty({
description:"Plugin name",
example:"Test Plugin"
})
plugin:string;
@ApiProperty({
description:"Plugin values",
example:{
@@ -23,7 +23,7 @@ export class CreateRestOutputDto {
values:{
prefix:string
};
@ApiProperty({
description:"Operation name",
example:"output"
@@ -76,7 +76,7 @@ export class RestOutputsController {
@Delete(':id')
async remove(@Param('id') id: string,@Headers() headers) {
const connectionResponse = await axios.delete(
`${process.env.DEV_URL}/output/${id}`,
{
@@ -25,7 +25,7 @@ export class RestTransformationsController {
}
)
return connectionResponse.data
}
@@ -41,7 +41,7 @@ export class RestTransformationsController {
}
)
return connectionResponse.data
}
@@ -57,7 +57,7 @@ export class RestTransformationsController {
}
)
return connectionResponse.data
}
@@ -75,7 +75,7 @@ export class RestTransformationsController {
}
)
return connectionResponse.data
}
@@ -91,7 +91,7 @@ export class RestTransformationsController {
}
)
return connectionResponse.data
}
}
@@ -1,37 +1,37 @@
import { ApiProperty } from "@nestjs/swagger";
export class CreateRestUserDto {
@ApiProperty({
description:"User Email",
example:"dev@dadosfera.ai"
})
email: string;
email: string;
@ApiProperty({
description:"User Password",
example:"dadospassword123"
})
password: string;
@ApiProperty({
description:"User Username",
example:"dev_fera"
})
username: string;
@ApiProperty({
description:"User name",
example:"Fulano da Silva"
})
name: string;
@ApiProperty({
description:"Customer id",
example:"dadosfera"
})
customer_id: string;
@ApiProperty({
description:"User rules",
example:"['admin']"
+1 -1
View File
@@ -7,4 +7,4 @@ export class ResendCodeDTO{
example:"dev_fera"
})
username:string
}
}
+1 -1
View File
@@ -15,4 +15,4 @@ export class UserAuthDTO{
example:"dadospassword123"
})
password:string;
}
}
@@ -8,10 +8,10 @@ export class UserConfirmationDTO{
})
username:string;
@ApiProperty({
description:"Received Confirmation Code",
example:"315246"
})
confirmationCode:string;
}
}
+3 -3
View File
@@ -33,7 +33,7 @@ export class RestUserController {
@Post('/auth')
async auth(@Body() body: UserAuthDTO) {
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/user/auth`,
body,
@@ -50,7 +50,7 @@ export class RestUserController {
@Post('/confirm')
async confirm(@Body() body: UserConfirmationDTO) {
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/user/confirm`,
body,
@@ -81,5 +81,5 @@ export class RestUserController {
return connectionResponse.data
}
}
@@ -2,10 +2,10 @@
export class CreateTransformationDto {
inputSource:string;
table:string;
type:string;
params:string;
}
@@ -1,14 +1,14 @@
export class Transformation {
id:string;
inputSource:string;
table:string;
type:string;
params:string;
}
@@ -47,4 +47,3 @@ message CreateTransformationRequest {
message ListResponse {
repeated Transformation transformations = 2;
}
@@ -21,6 +21,7 @@ import { GrpcClientConfiguration } from './config/grpc-client';
@Controller('transformation')
export class TransformationsController implements OnModuleInit {
@Client(GrpcClientConfiguration)
private transformationServiceClient: ClientGrpc;
@@ -35,9 +36,11 @@ export class TransformationsController implements OnModuleInit {
@Post()
create(@Payload() createTransformationDto: CreateTransformationDto[]) {
return createTransformationDto.map((transf) =>
this.transformationService.create(transf),
);
}
@Get()
+1 -1
View File
@@ -34,4 +34,4 @@ message UserResponse {
message ShowResponse {
repeated UserResponse users = 1;
}
}
+4 -4
View File
@@ -5,16 +5,16 @@ export class AuthenticateController{
private username:string;
private password:string;
constructor(){
this.username = process.env.AUTH_USERNAME
this.password = process.env.AUTH_PASSWORD
}
async authenticate():Promise<string>{
const response = await axios.post(process.env.AUTH_ROUTE,
{
username:this.username,
@@ -26,4 +26,4 @@ export class AuthenticateController{
}
}
}
+1 -1
View File
File diff suppressed because one or more lines are too long