Skip to content

Commit

Permalink
(feat) Added GitHub workflow to run tests and calculate coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
abel committed Sep 19, 2023
1 parent 05f3bdf commit a30481c
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: pre-commit

on:
pull_request:
push:
Expand All @@ -12,7 +11,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4

- name: Install poetry
run: python -m pip install poetry
- name: Cache the virtualenv
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: run-tests
on:
pull_request:
push:
branches: [master, dev]

jobs:
run-tests:
strategy:
matrix:
python: ["3.9", "3.10", "3.11"]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install poetry
run: python -m pip install poetry
- name: Cache the virtualenv
id: cache-venv
uses: actions/cache@v3
with:
path: ./.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: python -m poetry install

- name: Run tests and Generate coverage
run: |
poetry run pytest --cov --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
env_vars: OS,PYTHON
verbose: true
87 changes: 86 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pytest = "*"
pytest-asyncio = "*"
pytest-grpc = "*"
requests-mock = "*"
pytest-cov = "^4.1.0"


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

[tool.coverage.run]
branch = true
source_pkgs = ["pyinjective"]
omit = ["pyinjective/proto/*"]

[tool.coverage.report]
skip_empty = true


[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit a30481c

Please sign in to comment.