add unit test and coverage #1
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: Unit Test | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
branches: ['main'] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
pip install poetry | |
poetry install | |
- name: Run pytest with coverage | |
run: | | |
poetry run pytest --cov=secured tests/ | |
- name: Generate coverage report | |
run: | | |
poetry run pytest --cov=secured --cov-report=xml:coverage.xml tests/ | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v2 | |
with: | |
file: ./coverage.xml | |
fail_ci_if_error: true |