Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Renovate #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artillery/report.html
artillery/report.json
.docker
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FRONT_DIR=frontend
BACKEND_DIR=backend

clean: down-docker remove-files

up-docker: clean-backend
docker compose up -d --build --remove-orphans

down-docker:
docker compose --profile app down
docker compose --profile load-test down

remove-files:
rm -rf ./artillery/report.html
rm -rf ./artillery/report.json
rm -rf $(FRONT_DIR)/node_modules
rm -rf $(BACKEND_DIR)/blob
rm -rf $(BACKEND_DIR)/coverage
rm -rf $(BACKEND_DIR)/node_modules
rm -rf $(BACKEND_DIR)/dist

run-backend: clean
docker compose --profile app up -d

run-test-load: clean
docker compose --profile load-test up --build --remove-orphans --abort-on-container-exit
docker compose --profile report up --build --remove-orphans --abort-on-container-exit
npx open-cli $(PWD)/artillery/report.html

run-test-e2e: clean
cd $(BACKEND_DIR) && npm install && npm run test:vite:e2e
npx open-cli $(BACKEND_DIR)/coverage/index.html

run-all: run-backend
cd $(FRONT_DIR) && npm install
cd $(FRONT_DIR) && npx open-cli http://localhost:5173 && npm run dev

71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Here's a documentation guide you can use for your project README:

---

# Project Setup and Execution

This guide provides instructions for setting up and running the project using Docker and Makefile. This setup is designed to run in a Linux/Macos X environment. Before you start, ensure you have the following prerequisites installed:

## Prerequisites

- **Docker**: Ensure Docker is installed and running on your machine. You can follow the official [Docker installation guide](https://docs.docker.com/get-docker/) for your specific Linux distribution.

- **Make**: Make sure the Make utility is installed. On most Linux distributions, you can install it using your package manager. For example, on Ubuntu, you can run:

Linux
```bash
sudo apt-get install make
```

Macos
```bash
brew install make
```

Windows
```bash
choco install make
```

## Setup and Execution

### Running Backend Only

If you want to start only the backend service, execute:

```bash
make run-backend
```

This will start the backend service and its dependencies defined under the `app` profile in Docker Compose.

### Running Load Tests

To execute load tests, run:

```bash
make run-test-load
```

This command builds and starts the load test environment using Artillery and generates a report. After the test completes, it will open the HTML report located at `./artillery/report.html`.

### Running End-to-End Tests

For end-to-end tests, use the following command:

```bash
make run-test-e2e
```

This will navigate to the backend directory, install necessary dependencies, and run the end-to-end tests using the Vite testing setup. Once the tests are complete, it opens the coverage report at `./backend/coverage/index.html`.

### Running the Full Application

To run both the backend and frontend services, use:

```bash
make run-all
```

This command starts the backend service, installs frontend dependencies, and launches the frontend in development mode. The application will be accessible at `http://localhost:5173`.
npx open-clik
113 changes: 113 additions & 0 deletions artillery/processor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
const DATA = [
'Mariposa',
'Prisma',
'Orvalho',
'Neblina',
'Silêncio',
'Labirinto',
'Miragem',
'Eclipse',
'Catedral',
'Oásis',
'Horizonte',
'Enigma',
'Fulgor',
'Nostalgia',
'Bruma',
'Épico',
'Fantasia',
'Solstício',
'Utopia',
'Renovação',
'Vórtice',
'Saga',
'Constelação',
'Metamorfose',
'Aurora',
'Paradoxo',
'Fábula',
'Galáxia',
'Reflexo',
'Infinito',
'Abacaxi',
'Aventura',
'Balão',
'Carro',
'Dama',
'Elefante',
'Foguete',
'Gato',
'Horizonte',
'Ilha',
'Jogo',
'Kiwi',
'Lápis',
'Mágica',
'Navio',
'Ovelha',
'Pássaro',
'Quadro',
'Rato',
'Sapo',
'Tartaruga',
'Urso',
'Vaca',
'Xaxim',
'Zebra',
'Árvore',
'Bolha',
'Casa',
'Dente',
'Escola',
'Fada',
'Gelo',
'História',
'Imagem',
'Janela',
'Ketchup',
'Livro',
'Morte',
'Noite',
'Ovo',
'Pente',
'Quente',
'Rua',
'Sol',
'Tinta',
'Uva',
'Vento',
'Xadrez',
'Yoga',
'Zangão',
'Açúcar',
'Baleia',
'Caneta',
'Doce',
'Escova',
'Feijão',
'Garrafa',
'Helicóptero',
'Inseto',
'Jujuba',
];

function shuffle(array) {
const shuffledArray = array.slice();

for (let i = shuffledArray.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));

[shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
}

return shuffledArray;
}

function randomWord(context, events, done) {
context.vars.word = shuffle(DATA)[0];
return done();
}

module.exports = {
randomWord: randomWord,
};
27 changes: 27 additions & 0 deletions artillery/search.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
config:
target: 'http://backend:3000/api'
phases:
- duration: 10
arrivalRate: 5
rampTo: 25
name: Warm up phase
- duration: 10
arrivalRate: 25
rampTo: 50
name: Ramp up load
- duration: 10
arrivalRate: 50
rampTo: 75
name: Spike phase

processor: './processor.js'

scenarios:
- flow:
- loop:
- function: 'randomWord'
- get:
url: '/search'
qs:
text: '{{ word }}'
count: 10
3 changes: 3 additions & 0 deletions backend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.{js,ts,jsx,tsx}]
indent_style = tab
indent_size = 2
6 changes: 6 additions & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CACHE_TYPE='redis'
REDIS_HOST='localhost'
REDIS_PORT=6379
REDIS_PASSWORD=redispwd0001
ROOT_DIR=$PDW
PORT=3000
25 changes: 25 additions & 0 deletions backend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
49 changes: 49 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# compiled output
/dist
/node_modules
/build

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
5 changes: 5 additions & 0 deletions backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2
}
23 changes: 23 additions & 0 deletions backend/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"type": "node"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${file}",
"outFiles": ["${workspaceFolder}/**/*.js"]
}
]
}
3 changes: 3 additions & 0 deletions backend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
Loading