Skip to content

Commit

Permalink
Feature/ci tests (#25)
Browse files Browse the repository at this point in the history
* adiciona volumes no docker-compose

* adiciona npm run coverage

* remove execução dos binários do node_modules

* adiciona testes no CI

* adiciona coverage no CI

* adiciona comando no Makefile

* documenta comandos make adicionados
  • Loading branch information
rodrigondec authored Jun 8, 2020
1 parent cba80a1 commit 9b5642a
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 12 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: coverage report upload

on:
push:
branches:
- restart
pull_request:
branchs:
- 'feature/**'
- 'hotfix/**'
- 'release/**'

jobs:
coverage:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'

- name: Install dependencies
run: npm install

- name: Up firebase
run: make up.firebase

- name: Make coverage
run: npm run coverage

- uses: codecov/codecov-action@v1
with:
file: coverage/coverage-final.json
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: tests

on:
push:
branches:
- master
- dev
pull_request:
branchs:
- 'feature/**'
- 'hotfix/**'
- 'release/**'

jobs:
style:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'

- name: Install dependencies
run: npm install

- name: check style
run: npm run style:check

test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'

- name: Install dependencies
run: npm install

- name: Up firebase
run: make up.firebase

- name: Test
run: npm run test
36 changes: 31 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
all:
make up
build:
docker-compose --build
up:
docker-compose up --detach --force-recreate --renew-anon-volumes --remove-orphans
docker-compose build

up:
make up $(args)

up.detach:
docker-compose up --detach --force-recreate --renew-anon-volumes --remove-orphans $(args)

up.firebase:
docker-compose up --detach idvogados_firebase

down:
docker-compose down $(args)

down.volumes:
docker-compose down --volumes

bash:
docker-compose run idvogados_api bash

cli:
docker-compose run idvogados_api npm run cli

tests:
docker-compose run idvogados_api npm run test

coverage:
docker-compose run idvogados_api npm run coverage

style.check:
docker-compose run idvogados_api npm run style:check
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: '3.6'

volumes:
node_modules_volume: {}

services:
idvogados_api:
container_name: idvogados_api
Expand All @@ -11,6 +14,9 @@ services:
API_PORT: 3001
ports:
- 3001:3001
volumes:
- .:/var/app
- node_modules_volume:/var/app/node_modules/
depends_on:
- idvogados_firebase

Expand Down
11 changes: 10 additions & 1 deletion docs/orientacoes.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ O projeto conta com vários scripts que irão auxiliar no desenvolvimento e pode
### Comandos Make

- `make build`: Faz build das imagens docker
- `make up`: Inicializa a api localmente com docker, utilizando as configurações do arquivo [`docker-compose.yml`](https://github.com/idvogados/backend/blob/dev/docker-compose.yml)
- `make up`: Inicializa todos os serviços (é possível passar arugmentos extras utilizando `make up args='arg extra'`)
- `make up.detach`: Inicializa todos os serviços no modo detached e com outros parâmetros (é possível passar arugmentos extras utilizando `make up.detach args='arg extra'`)
- `make up.firebase`: Inicializa apenas o serviço do Firebase
- `make down`: Mata todos os serviços (é possível passar arugmentos extras utilizando `make down args='arg extra'`)
- `make down.volumes`: Mata todos os serviços e remove os volumes nomeados
- `make bash`: Inicia um bash/shell script no container do serviço Node
- `make cli`: Acessa a API em modo terminal na pasta raiz do projeto
- `make tests`: Executa todos os testes (Pasta `test/*`)
- `make coverage`: Executa os testes e gera o arquivo de coverage
- `make style.check`: Verifica se o código fonte segue os padrões de estilo definidos nos arquivos `.eslintrc` e `.prettierrc`

## Configurações do projeto

Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@
},
"scripts": {
"deps": "docker-compose -f docker-compose.test.yml up --force-recreate --renew-anon-volumes --remove-orphans",
"eslint": "./node_modules/.bin/eslint --fix .",
"eslint:check": "./node_modules/.bin/eslint .",
"eslint": "eslint --fix .",
"eslint:check": "eslint .",
"style:fix": "npm run prettier && npm run eslint",
"style:check": "npm run prettier:check && npm run eslint:check",
"prettier": "./node_modules/.bin/prettier --write \"**/{*.js,*.json,bin/**}\"",
"prettier:check": "./node_modules/.bin/prettier --check \"**/{*.js,*.json,bin/**}\"",
"prettier": "prettier --write \"**/{*.js,*.json,bin/**}\"",
"prettier:check": "prettier --check \"**/{*.js,*.json,bin/**}\"",
"start": "node ./bin/www",
"start:docker": "docker-compose up --force-recreate --renew-anon-volumes --remove-orphans",
"debug": "node --inspect-brk ./bin/www",
"cli": "node --experimental-repl-await",
"test": "./node_modules/.bin/nyc mocha --reporter spec",
"test": "nyc mocha --reporter spec",
"test:acceptance": "npm t test/acceptance/*",
"test:unit": "npm t test/unit/*"
"test:unit": "npm t test/unit/*",
"coverage": "nyc --reporter=json mocha --reporter spec"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 9b5642a

Please sign in to comment.