Skip to content

Commit

Permalink
Add CI pipeline (#21)
Browse files Browse the repository at this point in the history
* Make sure pyproject.toml has all required dependencies

* Add tests

* Add github actions to run test suite

* Fix CI (#1)

---------

Co-authored-by: Peter Volnov <41264338+pvolnov@users.noreply.github.com>
  • Loading branch information
hieuh25 and pvolnov authored Nov 27, 2024
1 parent 6cdb603 commit 70e7127
Show file tree
Hide file tree
Showing 7 changed files with 1,524 additions and 9 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: [master]
tags: [v*]
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
- name: Install dependencies
run: poetry install
- name: Run tests
run: poetry run pytest
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
venv
*.pyc
.DS_Store
build
dist
.idea
tests
py_near.egg-info
poetry.lock
env
.env
1,436 changes: 1,436 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ authors = ["pvolnov <petr@herewallet.app>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
base58 = "^2.1.1"
python = ">=3.8,<3.12"
aiohttp = "^3.7.4"
py-near-primitives = "0.2.3"
frozenlist = "^1.4.1"
pynacl = "^1.5.0"
loguru = "^0.7.2"
pydantic = "^2.6.2"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
black = "^21.12b0"
mypy = "^0.930"
pytest = "^6.2.5"
pytest = ">=7.0,<8.0"
flake8 = "^4.0.1"
Sphinx = "^4.3.2"
sphinx-rtd-theme = "^1.0.0"
base58 = "^2.1.1"
pytest-asyncio = "^0.23.5"

[project]
name = "py-near"
version = "1.1.50"
description = "Pretty simple and fully asynchronous framework for working with NEAR blockchaink"
authors = [ {name = "pvolnov", email = "petr@herewallet.app"} ]
requires-python = ">=3.10"
license = {file = "LICENSE"}
dependencies=["base58", "httpx", "py-near-primitives", "pydantic"]

keywords = ["python", "near", "async"]
classifiers = [
"Programming Language :: Python :: 3",
Expand All @@ -56,4 +56,11 @@ documentation = "https://py-near.readthedocs.io/en/latest"
repository = "https://github.com/pvolnov/py-near"
changelog = "https://github.com/pvolnov/py-near/blob/main/CHANGELOG.md"
funding = "https://opencollective.com/py-near"
twitter = "https://twitter.com/p_volnov"
twitter = "https://twitter.com/p_volnov"

[tool.pytest.ini_options]
addopts = "--capture=no --tb=native"
testpaths = [
"tests",
]
asyncio_mode = "auto"
24 changes: 24 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest

from py_near.account import Account
from py_near.dapps.fts import FtModel


@pytest.fixture(scope="session")
async def rpc_url() -> Account:
return "https://rpc.testnet.near.org"


@pytest.fixture(scope="session")
async def account(rpc_url) -> Account:
acc = Account(
account_id="py-near.testnet",
rpc_addr=rpc_url,
)

await acc.startup()

# quick check that the account started up correctly
assert acc.chain_id == "testnet"

return acc
2 changes: 2 additions & 0 deletions tests/test_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
async def test_account_get_balance(account):
assert await account.get_balance() > 0
12 changes: 12 additions & 0 deletions tests/test_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest

from py_near.dapps.fts import FtModel


@pytest.fixture
async def usdc():
return FtModel("usdc.orderly-qa.testnet", 6)


async def test_ft_balance(account, usdc):
assert await account.ft.get_ft_balance(usdc) == 0

0 comments on commit 70e7127

Please sign in to comment.