tests: update tests; refactor async client fixture; exclude path fiel… #65
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: pytest | |
on: [ push, pull_request ] | |
jobs: | |
pytest: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 5s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: pip install poetry | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'poetry' | |
- run: poetry install --only main,test | |
- run: | | |
poetry run pytest \ | |
--junitxml=pytest.xml \ | |
--cov=src \ | |
--cov-report=term-missing:skip-covered \ | |
| tee pytest-coverage.txt | |
env: | |
ENVIRONMENT: 'testing' | |
SESSION_SECRET_KEY: 'this is secret key' | |
JWT_SECRET_KEY: 'this is another secret key' | |
DB_URL: 'postgresql+asyncpg://postgres:postgres@localhost:5432/postgres' | |
- uses: MishaKav/pytest-coverage-comment@main | |
id: coverageComment | |
with: | |
pytest-coverage-path: ./pytest-coverage.txt | |
junitxml-path: ./pytest.xml | |
- name: Check the output coverage | |
run: | | |
echo "Coverage Percentage - ${{ steps.coverageComment.outputs.coverage }}" | |
echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}" | |
echo "Coverage Warnings - ${{ steps.coverageComment.outputs.warnings }}" | |
echo "Coverage Errors - ${{ steps.coverageComment.outputs.errors }}" | |
echo "Coverage Failures - ${{ steps.coverageComment.outputs.failures }}" | |
echo "Coverage Skipped - ${{ steps.coverageComment.outputs.skipped }}" | |
echo "Coverage Tests - ${{ steps.coverageComment.outputs.tests }}" | |
echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}" | |
echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}" | |
- name: Create the Badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.COVERAGE_GIST_ACCESS_TOKEN }} | |
gistID: 075e30f7e4a7e9a28e40aa614db5445e | |
filename: pytest-coverage-comment__main.json | |
label: Coverage | |
message: ${{ steps.coverageComment.outputs.coverage }} | |
color: ${{ steps.coverageComment.outputs.color }} | |
- name: Job result | |
run: | | |
[[ ${{ steps.coverageComment.outputs.failures }} -eq 0 ]] || { echo >&2 "Some tests failed"; exit 1; } |