Skip to content

Commit

Permalink
Merge pull request #2 from fga-eps-mds/devel
Browse files Browse the repository at this point in the history
Release 1
  • Loading branch information
saracampss authored Aug 3, 2024
2 parents 881917f + e08cbf0 commit 3b5812f
Show file tree
Hide file tree
Showing 19 changed files with 5,844 additions and 808 deletions.
140 changes: 140 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: backend-beneficios-ci

on:
push:
branches: [main, devel]
pull_request:
branches:
- main
- devel
types: [opened, synchronize, reopened]

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: 📬 Caching
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/dist
key: ${{ runner.os }}-node-${{ hashFiles('*/package-lock.json') }}-${{ hashFiles('/.{js,jsx,ts,tsx}') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-
- name: 🧰 Instala bibliotecas e dependências
run: npm i

- name: 🔍 Verifica estilização do código
run: npm run check-format

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: 📬 Caching
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/dist
key: ${{ runner.os }}-node-${{ hashFiles('*/package-lock.json') }}-${{ hashFiles('/.{js,jsx,ts,tsx}') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-
- name: 🧰 Instala bibliotecas e dependências
run: npm i

- name: 🧹 Verifica eslint
run: npm run lint

test:
runs-on: ubuntu-latest
env:
MONGO_URI: ${{ secrets.MONGO_URI }}
MONGO_INITDB_ROOT_USERNAME: ${{ secrets.MONGO_INITDB_ROOT_USERNAME }}
MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.MONGO_INITDB_ROOT_PASSWORD }}
DB_HOST: ${{ secrets.DB_HOST }}
PORT: ${{ secrets.PORT }}
EMAIL: ${{ secrets.EMAIL }}
SECRET: ${{ secrets.SECRET }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: 📬 Caching
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/dist
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('/.{js,jsx,ts,tsx}') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-
- name: 🧰 Instala bibliotecas e dependências
run: npm i

- name: 🧪 Roda suíte de testes
run: npm test -- --passWithNoTests

sonarcloud:
name: sonarcloud
needs: [test]
runs-on: ubuntu-latest
env:
MONGO_URI: ${{ secrets.MONGO_URI }}
MONGO_INITDB_ROOT_USERNAME: ${{ secrets.MONGO_INITDB_ROOT_USERNAME }}
MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.MONGO_INITDB_ROOT_PASSWORD }}
DB_HOST: ${{ secrets.DB_HOST }}
PORT: ${{ secrets.PORT }}
EMAIL: ${{ secrets.EMAIL }}
SECRET: ${{ secrets.SECRET }}
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 📬 Caching
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/dist
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.{js,jsx,ts,tsx}') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-
- name: 🧰 Instala bibliotecas e dependências
run: npm i

- name: 📜 Relatório do eslint
run: npx eslint -f json -o reports/eslint-report.json src || true

- name: 🧪 Testes e cobertura
run: JEST_SONAR=jest-sonar CI=true npm test -- --coverage --passWithNoTests

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: backend-beneficios-release

on:
push:
branches: [main, devel]
tags:
- "v*"

jobs:
generate-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: "Get Previous tag"
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 1.0.0

- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Cria métricas do SonarCloud
run: python metrics/sonar-metrics.py ${{ github.event.repository.name }} ${{ github.ref_name }}

- name: Commita arquivos de métricas do SonarCloud
run: |
git config --global user.email "${{ secrets.GIT_EMAIL }}"
git config --global user.name "${{ secrets.GIT_USER }}"
git clone --single-branch --branch main "https://x-access-token:${{ secrets.PERSONAL_TOKEN }}@github.com/fga-eps-mds/2024.1-SENTINELA-DOC" doc
mkdir -p doc/analytics-raw-data
cp -R fga-eps-mds*.json doc/analytics-raw-data
cd doc
git add .
git commit -m "Métricas SonarCloud - ${{ github.event.repository.name }} ${{ github.ref_name }}"
git push
echo "Arquivos de métricas gerado com sucesso."
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ yarn-error.log
# Arquivos de configuração de IDEs
.idea
.vscode
.env
.env

/coverage
20 changes: 20 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
echo '🏗️👷 Estilizando e verificando os padrões do seu código antes de commitar . . .\n'

# Check Prettier standards
npm run check-format ||
(
echo '\n🤢🤮 Parece haver um problema de estilo 🤢🤮
Checagem do Prettier falhou... Rode um npm run format, adicione as alterações e tente novamente.\n';
false;
)

# Check ESLint Standards
npm run lint ||
(
echo '\n😤🏀👋😤 Daqui não passa! 😤🏀👋😤
Checagem do ESLint falhou... Faça as alterações listadas acima e tente novamente.\n'
false;
)

# If everything passes... Now we can commit
echo '\n\n✅✅✅✅ Você ganhou dessa vez, commitando agora. ✅✅✅✅\n'
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github
*.md
coverage
dist
*.json
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": false
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 2024.1-SENTINELA-BACKEND-FINACEIRO
# 2024.1-SENTINELA-BACKEND-BENEFICIOS

## Variáveis de ambiente

Expand Down
64 changes: 32 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
version: '3.8'
version: "3.8"
services:
mongodb:
image: mongo:7.0
container_name: benefitsdb
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
ports:
- "27019:27017"
env_file: .env
volumes:
- mongo-data:/data/db
networks:
- backend_network
command: ["mongod", "--quiet", "--logpath", "/dev/null"]
mongodb:
image: mongo:7.0
container_name: benefitsdb
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
ports:
- "27019:27017"
env_file: .env
volumes:
- mongo-data:/data/db
networks:
- backend_network
command: ["mongod", "--quiet", "--logpath", "/dev/null"]

express_backend:
build: .
container_name: express_backend_benfits
ports:
- "3003:3003"
env_file: .env
environment:
MONGO_URI: ${MONGO_URI}
depends_on:
- mongodb
networks:
- backend_network
volumes:
- ./:/app
express_backend:
build: .
container_name: express_backend_benfits
ports:
- "3003:3003"
env_file: .env
environment:
MONGO_URI: ${MONGO_URI}
depends_on:
- mongodb
networks:
- backend_network
volumes:
- ./:/app

volumes:
mongo-data:
mongo-data:

networks:
backend_network:
backend_network:
11 changes: 11 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const pluginPrettier = require("eslint-plugin-prettier/recommended");

module.exports = [
pluginPrettier,
{
rules: {
"no-console": "warn",
"no-unused-vars": "error",
},
},
];
Loading

0 comments on commit 3b5812f

Please sign in to comment.