Skip to content

Tests unitarios - Capa de servicio #8

Tests unitarios - Capa de servicio

Tests unitarios - Capa de servicio #8

Workflow file for this run

name: Tests
on:
push:
branches:
- main
- develop
pull_request:
branches:
- '**'
jobs:
test:
name: Tests microservice
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Create VirtualEnvs
run: python3 -m venv venv
- name: Run tests
run: |
source .venv/bin/activate
cd app
pytest
pytest --cov=./service ./ --cov-report=xml --cov-report=term-missing
env:
USERS_SERVICE_URL: "https://users-hanagotchi-13b50c95f2c8.herokuapp.com/"
DATABASE_URL: "postgres://pepe"
PLANT_SERVICE_URL: "https://plants-hanagotchi-512f2afd17a5.herokuapp.com"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
directory: ./coverage/reports/
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
path_to_write_report: ./coverage/codecov_report.txt
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Check coverage
run: |
source .venv/bin/activate
COVERAGE=$(coverage report | grep 'TOTAL' | awk '{print $4}' | sed 's/%//')
echo "Coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < 85" | bc -l) )); then
echo "Coverage is below 85%!"
exit 1
fi
env:
USERS_SERVICE_URL: dummy:5000