diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 7ab47b5..93b93eb 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,10 +1,6 @@ name: checks -on: - push: - branches: [main] - pull_request: - branches: [main] +on: [push, pull_request] jobs: formatting: @@ -12,41 +8,43 @@ jobs: strategy: matrix: python-version: ["3.9"] - poetry-version: ["1.3.1"] + poetry-version: ["1.5.1"] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - name: Set up Poetry ${{ matrix.poetry-version }} uses: abatilo/actions-poetry@v2 with: poetry-version: ${{ matrix.poetry-version }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: "poetry" - name: Install packages - run: poetry install --with dev + run: poetry install - name: Check black - run: poetry run black --check . + run: make black-check - name: Check isort - run: poetry run isort --profile black --check-only . + run: make isort-check linting: runs-on: ubuntu-latest strategy: matrix: python-version: ["3.9"] - poetry-version: ["1.3.1"] + poetry-version: ["1.5.1"] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - name: Set up Poetry ${{ matrix.poetry-version }} uses: abatilo/actions-poetry@v2 with: poetry-version: ${{ matrix.poetry-version }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: "poetry" - name: Install packages - run: poetry install --with dev + run: poetry install - name: Setup mypy run: yes | poetry run mypy cashu --install-types || true - name: Run mypy diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8760b60..ecea613 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,32 +9,33 @@ jobs: matrix: os: [ubuntu-latest] python-version: ["3.9.13"] - poetry-version: ["1.4.2"] + poetry-version: ["1.5.1"] steps: - name: Checkout repository and submodules uses: actions/checkout@v2 with: submodules: recursive - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - name: Set up Poetry ${{ matrix.poetry-version }} uses: abatilo/actions-poetry@v2 with: poetry-version: ${{ matrix.poetry-version }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: "poetry" - name: Install dependencies run: | - poetry install --with dev + poetry install shell: bash - name: Run tests env: - LIGHTNING: False + LIGHTNING: false WALLET_NAME: test_wallet MINT_HOST: localhost MINT_PORT: 3337 - TOR: False + TOR: false run: | - poetry run pytest tests --cov-report xml --cov cashu + make test - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 diff --git a/Makefile b/Makefile index a7de3d7..268d022 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,15 @@ isort: poetry run isort --profile black . --skip cashu/nostr +isort-check: + poetry run isort --profile black --check-only . --skip cashu/nostr + black: poetry run black . --exclude cashu/nostr +black-check: + poetry run black --check . --exclude cashu/nostr + format: make isort make black @@ -17,19 +23,21 @@ clean: find . -name ".DS_Store" -exec rm -f {} \; || true rm -rf dist || true rm -rf build || true - + package: poetry export -f requirements.txt --without-hashes --output requirements.txt make clean python setup.py sdist bdist_wheel - + test: - pytest tests/ - + LIGHTNING=false \ + TOR=false \ + poetry run pytest tests --cov-report xml --cov cashu + install: make clean python setup.py sdist bdist_wheel - pip install --upgrade dist/* + pip install --upgrade dist/* upload: make clean diff --git a/poetry.lock b/poetry.lock index b5e162c..841eed4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -471,7 +471,7 @@ tests = ["dj-database-url", "dj-email-url", "django-cache-url", "pytest"] name = "exceptiongroup" version = "1.1.0" description = "Backport of PEP 654 (exception groups)" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -599,7 +599,7 @@ testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packag name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -783,7 +783,7 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2.1)", "pytes name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1002,18 +1002,17 @@ files = [ [[package]] name = "pytest" -version = "7.2.2" +version = "7.4.0" description = "pytest: simple powerful testing with Python" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "pytest-7.2.2-py3-none-any.whl", hash = "sha256:130328f552dcfac0b1cec75c12e3f005619dc5f874f0a06e8ff7263f0ee6225e"}, - {file = "pytest-7.2.2.tar.gz", hash = "sha256:c99ab0c73aceb050f68929bc93af19ab6db0558791c6a0715723abe9d0ade9d4"}, + {file = "pytest-7.4.0-py3-none-any.whl", hash = "sha256:78bf16451a2eb8c7a2ea98e32dc119fd2aa758f1d5d66dbf0a59d69a3969df32"}, + {file = "pytest-7.4.0.tar.gz", hash = "sha256:b4bf8c45bd59934ed84001ad51e11b4ee40d40a1229d2c79f9c592b0a3f6bd8a"}, ] [package.dependencies] -attrs = ">=19.2.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} @@ -1023,13 +1022,13 @@ pluggy = ">=0.12,<2.0" tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-asyncio" version = "0.19.0" description = "Pytest support for asyncio" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1326,7 +1325,7 @@ full = ["itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests"] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1486,4 +1485,4 @@ pgsql = ["psycopg2-binary"] [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "8ac516f63a6f6538a7cc1ed4b1db8a34b1fe1eaa174ae50b5979ce1ef42ec705" +content-hash = "b33d82f1d4b58a39ab9fe6c887cf88a3246e9c99dc7bfe5df93923ad00d79814" diff --git a/pyproject.toml b/pyproject.toml index 2ca160b..8c01a45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,6 @@ license = "MIT" [tool.poetry.dependencies] python = "^3.7" requests = "^2.27.1" -pytest-asyncio = "^0.19.0" SQLAlchemy = "^1.3.24" click = "^8.0.4" pydantic = "^1.10.2" @@ -36,15 +35,13 @@ httpx = "0.23.0" [tool.poetry.extras] pgsql = ["psycopg2-binary"] -[tool.poetry.dev-dependencies] -black = {version = "^22.8.0", allow-prereleases = true} -isort = "^5.10.1" - [tool.poetry.group.dev.dependencies] mypy = "^0.971" black = {version = "^22.8.0", allow-prereleases = true} isort = "^5.10.1" +pytest-asyncio = "^0.19.0" pytest-cov = "^4.0.0" +pytest = "^7.4.0" [build-system] requires = ["poetry-core>=1.0.0"] @@ -53,4 +50,4 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] mint = "cashu.mint.main:main" cashu = "cashu.wallet.cli.cli:cli" -wallet-test = "tests.test_wallet:test" \ No newline at end of file +wallet-test = "tests.test_wallet:test"