Skip to content

Commit

Permalink
Circleci setup (andelf#72)
Browse files Browse the repository at this point in the history
* Circleci setup

* bump

* bump

* bump

* Bump

* Install test requirements

* Add tests

* More improvements

* Fix linting issues

* Disable mypy for now
  • Loading branch information
MrNaif2018 authored Feb 2, 2023
1 parent 8761f36 commit 02af96d
Show file tree
Hide file tree
Showing 21 changed files with 434 additions and 276 deletions.
92 changes: 92 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
version: 2.1

orbs:
bitcartcc: bitcartcc/bitcartcc-shared@1

executors:
main-executor:
parameters:
v:
type: string
default: "3.8"

docker:
- image: cimg/python:<< parameters.v >>

environment:
TEST_ARGS: "--junitxml test-results/pytest/coverage.xml --cov-report html:coverage"

commands:
install_dependencies:
steps:
- restore_cache:
keys:
- v1-dependencies-{{ .Branch }}-{{ checksum "~/.pyenv/version" }}-{{ checksum "setup.py" }}-{{ checksum "test-requirements.txt" }}

- run:
name: install library
command: |
virtualenv ~/venv
echo ". ~/venv/bin/activate" >> $BASH_ENV
source $BASH_ENV
pip install -U .
pip install -U -r test-requirements.txt
- save_cache:
paths:
- ~/venv
key: v1-dependencies-{{ .Branch }}-{{ checksum "~/.pyenv/version" }}-{{ checksum "setup.py" }}-{{ checksum "test-requirements.txt" }}

upload-results:
steps:
- store_test_results:
path: test-results

- store_artifacts:
path: coverage

- store_artifacts:
path: test-results

jobs:
test:
parameters:
v:
type: string

executor:
name: main-executor
v: << parameters.v >>

environment:
PYTHON: << parameters.v >>

working_directory: ~/repo

steps:
- checkout

- install_dependencies

- run:
name: run fast tests
command: |
make lint
make test
- upload-results

workflows:
version: 2
test_and_deploy:
jobs:
- test:
name: test-<< matrix.v >>
matrix:
parameters:
v:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-complexity=11
max-line-length=127
ignore=E266, E203, W503
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
all: ci

lint:
flake8
# mypy tronpy

checkformat:
black --check .
isort --check .

format:
black .
isort .

test:
pytest tests/ ${TEST_ARGS}

ci: checkformat lint test
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'classic' #'alabaster'
html_theme = 'classic' # 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
3 changes: 2 additions & 1 deletion examples/check_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

client = Tron()


def check_balance(address):
try:
balance=client.get_account_balance(address)
balance = client.get_account_balance(address)
return balance
except AddressNotFound:
return 'Adress not found..!'
Expand Down
3 changes: 2 additions & 1 deletion examples/justswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
def timestamp():
return int(time.time())


swap_abi = []
with open(os.path.join(__dir__, "JustSwapExchange.abi")) as fp:
with open(os.path.join(__dir__, "JustSwapExchange.abi")) as fp:
swap_abi = json.load(fp)


Expand Down
29 changes: 21 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,27 @@ requests = "*"
httpx = "*"

[tool.poetry.dev-dependencies]
pytest = "^7"
pytest-cov = "^3"
flake8 = "^4"
black = ">=21"
isort = "^5"
mypy = "^0.931"
sphinx = "^4"
pytest-asyncio = "^0.16"
pytest = "*"
pytest-cov = "*"
flake8 = "*"
black = "*"
isort = "*"
mypy = "*"
sphinx = "*"
pytest-asyncio = "*"
codecov = "*"
pre-commit = "*"

[tool.pytest.ini_options]
addopts = [
"--cov=.",
"--cov-report",
"term-missing"
]
filterwarnings = [
"error::DeprecationWarning",
"error::PendingDeprecationWarning",
]

[tool.black]
line-length = 100
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
'name': 'tronpy',
'version': '0.2.6',
'description': 'TRON Python client library',
'long_description': '# tronpy\n\nTRON Python Client Library.\n\n## How to use\n\n```python\nfrom tronpy import Tron\n\nclient = Tron(network=\'nile\')\n# Private key of TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3\npriv_key = PrivateKey(bytes.fromhex("8888888888888888888888888888888888888888888888888888888888888888"))\n\ntxn = (\n client.trx.transfer("TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3", "TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA", 1_000)\n .memo("test memo")\n .fee_limit(100_000_000)\n .build()\n .inspect()\n .sign(priv_key)\n .broadcast()\n)\n\nprint(txn)\n# > {\'result\': True, \'txid\': \'5182b96bc0d74f416d6ba8e22380e5920d8627f8fb5ef5a6a11d4df030459132\'}\nprint(txn.wait())\n# > {\'id\': \'5182b96bc0d74f416d6ba8e22380e5920d8627f8fb5ef5a6a11d4df030459132\', \'blockNumber\': 6415370, \'blockTimeStamp\': 1591951155000, \'contractResult\': [\'\'], \'receipt\': {\'net_usage\': 283}}\n```\n',
'long_description': open("README.md").read(),
'long_description_content_type': "text/markdown",
'author': 'andelf',
'author_email': '[email protected]',
'maintainer': None,
Expand Down
9 changes: 9 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
black
codecov
flake8
isort
mypy
pre-commit
pytest
pytest-asyncio
pytest-cov
Empty file added tests/__init__.py
Empty file.
Loading

0 comments on commit 02af96d

Please sign in to comment.