Skip to content

Commit a30481c

Browse files
author
abel
committed
(feat) Added GitHub workflow to run tests and calculate coverage
1 parent 05f3bdf commit a30481c

File tree

4 files changed

+144
-3
lines changed

4 files changed

+144
-3
lines changed

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: pre-commit
2-
32
on:
43
pull_request:
54
push:
@@ -12,7 +11,8 @@ jobs:
1211
- name: Checkout
1312
uses: actions/checkout@v3
1413
- name: Install Python
15-
uses: actions/setup-python@v3
14+
uses: actions/setup-python@v4
15+
1616
- name: Install poetry
1717
run: python -m pip install poetry
1818
- name: Cache the virtualenv

.github/workflows/run-tests.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: run-tests
2+
on:
3+
pull_request:
4+
push:
5+
branches: [master, dev]
6+
7+
jobs:
8+
run-tests:
9+
strategy:
10+
matrix:
11+
python: ["3.9", "3.10", "3.11"]
12+
os: [ubuntu-18.04, macos-latest, windows-latest]
13+
runs-on: ${{ matrix.os }}
14+
env:
15+
OS: ${{ matrix.os }}
16+
PYTHON: ${{ matrix.python }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- name: Install Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python }}
24+
25+
- name: Install poetry
26+
run: python -m pip install poetry
27+
- name: Cache the virtualenv
28+
id: cache-venv
29+
uses: actions/cache@v3
30+
with:
31+
path: ./.venv
32+
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
33+
34+
- name: Install dependencies
35+
if: steps.cache-venv.outputs.cache-hit != 'true'
36+
run: python -m poetry install
37+
38+
- name: Run tests and Generate coverage
39+
run: |
40+
poetry run pytest --cov --cov-report=xml
41+
42+
- name: Upload coverage to Codecov
43+
uses: codecov/codecov-action@v3
44+
with:
45+
env_vars: OS,PYTHON
46+
verbose: true

poetry.lock

Lines changed: 86 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pytest = "*"
3939
pytest-asyncio = "*"
4040
pytest-grpc = "*"
4141
requests-mock = "*"
42+
pytest-cov = "^4.1.0"
4243

4344

4445
[tool.poetry.group.dev.dependencies]
@@ -71,6 +72,7 @@ skip_glob = ["pyinjective/proto/*", ".idea/*"]
7172
[tool.black]
7273
line-length = 120
7374
target-version = ["py39", "py310", "py311"]
75+
include = '\.pyi?$'
7476
# 'extend-exclude' excludes files or directories in addition to the defaults
7577
extend-exclude = '''
7678
# A regex preceded with ^/ will apply only to files and directories
@@ -81,6 +83,14 @@ extend-exclude = '''
8183
)
8284
'''
8385

86+
[tool.coverage.run]
87+
branch = true
88+
source_pkgs = ["pyinjective"]
89+
omit = ["pyinjective/proto/*"]
90+
91+
[tool.coverage.report]
92+
skip_empty = true
93+
8494

8595
[build-system]
8696
requires = ["poetry-core"]

0 commit comments

Comments
 (0)