Tests unitarios - Capa de servicio #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Run tests | |
run: | | |
source venv/bin/activate | |
pytest app | |
pytest --cov=app/service app/ --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 |