Skip to content

Commit 88ea80f

Browse files
authored
Add pytest to test the code (tomasvotava#48)
* chore: rename legacy dev-dependencies * chore: add test deps * chore: make work with latest pylint * remove outdated `requirements.txt` * add isort config * add poethepoet for common tasks - linting (pylint, mypy, isort, black) - formatting (isort, black) * use poe commands in workflow * feat(tests): implement basic testing functionality * feat: use coverage report comment in PRs * dev: upload coverage.json as a gist * fix: examples should use context manager * chore: rebuild docs * chore: paralelize tests * docs: add pytest to contributing * dev: setup pre-commit
1 parent 3ad759e commit 88ea80f

33 files changed

+1971
-625
lines changed

.github/workflows/lint.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pylint
1+
name: Code quality
22

33
on: [push, pull_request]
44

@@ -8,10 +8,10 @@ jobs:
88
strategy:
99
matrix:
1010
python-version:
11-
- "3.7"
1211
- "3.8"
1312
- "3.9"
1413
- "3.10"
14+
- "3.11"
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Set up Python ${{ matrix.python-version }}
@@ -25,11 +25,10 @@ jobs:
2525
run: |
2626
POETRY_VIRTUALENVS_CREATE=false ~/.local/bin/poetry install
2727
- name: Analysing the code with pylint
28-
run: |
29-
python -m pylint --disable fixme fastapi_sso
28+
run: ~/.local/bin/poetry run poe pylint
3029
- name: Static type-checking using mypy
31-
run: |
32-
python -m mypy fastapi_sso
30+
run: ~/.local/bin/poetry run poe mypy
3331
- name: Format checking using black
34-
run: |
35-
python -m black --check fastapi_sso
32+
run: ~/.local/bin/poetry run poe black-check
33+
- name: Format checking using isort
34+
run: ~/.local/bin/poetry run poe isort-check

.github/workflows/test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
env:
9+
POETRY_VIRTUALENVS_CREATE: "false"
10+
coverage_json: "{}"
11+
strategy:
12+
matrix:
13+
python-version:
14+
- "3.8"
15+
- "3.9"
16+
- "3.10"
17+
- "3.11"
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install poetry
25+
run: |
26+
curl -sSL https://install.python-poetry.org | python -
27+
- name: Install dependencies
28+
run: ~/.local/bin/poetry install
29+
- name: pytest
30+
run: ~/.local/bin/poetry run poe test --junitxml=pytest-results-${{ matrix.python-version }}.xml
31+
- name: coverage
32+
run: ~/.local/bin/poetry run poe coverage
33+
- name: Get Coverage Report Comment
34+
uses: orgoro/[email protected]
35+
with:
36+
coverageFile: coverage.xml
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
if: ${{ github.event_name == 'pull_request'}}
39+
- name: Upload coverage.json as a gist
40+
uses: exuanbo/actions-deploy-gist@v1
41+
with:
42+
token: ${{ secrets.GIST_TOKEN }}
43+
gist_id: 328acf6207500c2e836b1c68b5c910f7
44+
file_path: coverage.json
45+
file_type: text
46+
if: ${{ matrix.python-version == '3.11' && github.ref_name == 'master' }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ htmlcov/
4848
.cache
4949
nosetests.xml
5050
coverage.xml
51+
coverage.json
5152
*.cover
5253
*.py,cover
5354
.hypothesis/

.isort.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[settings]
2+
multi_line_output=3
3+
include_trailing_comma=True
4+
line_length=120

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: pylint
5+
name: pylint
6+
entry: poe pylint
7+
language: system
8+
types: [python]
9+
10+
- id: black
11+
name: black
12+
entry: poe black-check
13+
language: system
14+
types: [python]
15+
16+
- id: mypy
17+
name: mypy
18+
entry: poe mypy
19+
language: system
20+
types: [python]
21+
pass_filenames: false
22+
23+
- id: isort
24+
name: isort
25+
entry: poe isort-check
26+
language: system
27+
types: [python]
28+
pass_filenames: false

0 commit comments

Comments
 (0)