Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAN-1808] upgrade python to 3.12 and switch to poetry #6

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/actions/install-deps/action.yml

This file was deleted.

75 changes: 0 additions & 75 deletions .github/workflows/ci-cd.yaml

This file was deleted.

71 changes: 4 additions & 67 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Format, Lint, and Test
name: CI

on:
push:
Expand All @@ -7,69 +7,6 @@ on:
pull_request:

jobs:
Format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/install-deps

- name: Format
run: make format-check

Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/install-deps

- name: Lint
run: make lint

Sort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/install-deps

- name: Sort
run: make sort-check

Bandit:
name: Bandit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/install-deps

- name: Bandit
run: make bandit

StaticCodeAnalysis:
name: Static Code Analysis
runs-on: ubuntu-latest
needs: [Format, Lint, Sort, Bandit]
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/install-deps

- name: StaticCodeAnalysis
run: |
make check

UnitTest:
name: Unit Test
runs-on: ubuntu-latest
needs: [Format, Lint, Sort, Bandit]
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/install-deps

- name: Unit Test
run: |
make coverage
shared:
uses: pantos-io/ci-workflows/.github/workflows/python-ci.yml@v1
secrets: inherit
22 changes: 2 additions & 20 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10
cache: 'pip'

- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
- uses: pantos-io/ci-workflows/.github/actions/install-poetry@v1

- name: Build package
run: |
source .venv/bin/activate
pip install build
python -m build
env:
PANTOS_COMMON_VERSION: ${{ github.event.release.tag_name }}
run: make wheel

- name: Upload build artifact
uses: actions/upload-artifact@v4
Expand Down
9 changes: 1 addition & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
repos:
- repo: local
hooks:
- id: validate-commit-msg
name: Commit message is prefixed by Jira ticket number
entry: ^(?!PAN-\d*:.+)
language: pygrep
stages: [ commit-msg ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
name: Check that branch name follows our standard
description: Checks that a branch has a proper name
args: ['--branch', 'main','--pattern', '^(?!(feature|bugfix)\/PAN-[0-9]+-[a-z0-9._-]+).*']
args: ['--branch', 'main','--pattern', '^(PAN-[0-9]+-[a-z0-9._-]+).*']
stages: [ commit-msg ]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
Expand Down
43 changes: 23 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
PYTHON_FILES := pantos/common scripts tests ./*.py
PYTHON_FILES := pantos/common scripts tests

.PHONY: code
code: check format lint sort bandit test

.PHONY: check
check:
mypy $(PYTHON_FILES)
poetry run mypy $(PYTHON_FILES)

.PHONY: test
test:
python3 -m pytest tests
.PHONY: format
format:
poetry run yapf --in-place --recursive $(PYTHON_FILES)

.PHONY: coverage
coverage:
rm -rf .coverage
python3 -m pytest --cov-report term-missing --cov=pantos tests
.PHONY: format-check
format-check:
poetry run yapf --diff --recursive $(PYTHON_FILES)

.PHONY: lint
lint:
flake8 $(PYTHON_FILES)
poetry run flake8 $(PYTHON_FILES)

.PHONY: sort
sort:
isort --force-single-line-imports $(PYTHON_FILES)
poetry run isort --force-single-line-imports $(PYTHON_FILES)

.PHONY: sort-check
sort-check:
isort --force-single-line-imports $(PYTHON_FILES) --check-only
poetry run isort --force-single-line-imports $(PYTHON_FILES) --check-only

.PHONY: bandit
bandit:
bandit -r $(PYTHON_FILES) --quiet --configfile=.bandit
poetry run bandit -r $(PYTHON_FILES) --quiet --configfile=.bandit

.PHONY: bandit-check
bandit-check:
bandit -r $(PYTHON_FILES) --configfile=.bandit
poetry run bandit -r $(PYTHON_FILES) --configfile=.bandit

.PHONY: format
format:
yapf --in-place --recursive $(PYTHON_FILES)
.PHONY: test
test:
poetry run python3 -m pytest tests

.PHONY: format-check
format-check:
yapf --diff --recursive $(PYTHON_FILES)
.PHONY: coverage
coverage:
poetry run python3 -m pytest --cov-report term-missing --cov=pantos tests

.PHONY: wheel
wheel:
poetry build -f wheel

.PHONY: clean
clean:
Expand Down
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,34 @@ Please make sure that your environment meets the following requirements:

#### Python Version

The Pantos Client CLI requires **Python 3.10**. Ensure that you have the correct Python version installed before the installation steps. You can download the latest version of Python from the official [Python website](https://www.python.org/downloads/).
Pantos Common requires **Python 3.12**. Ensure that you have the correct Python version installed before the installation steps. You can download the latest version of Python from the official [Python website](https://www.python.org/downloads/).

#### Library Versions

The Pantos Common project has been tested with the library versions in **requirements.txt**.
The Pantos Common project has been tested with the library versions specified in **poetry.lock**.

### 2.2 Installation Steps
#### Poetry

#### Virtual environment
Poetry is our tool of choice for dependency management and packaging.

Create a virtual environment from the repository's root directory:
Installing:
https://python-poetry.org/docs/#installing-with-the-official-installer
or
https://python-poetry.org/docs/#installing-with-pipx

By default poetry creates the venv directory under under ```{cache-dir}/virtualenvs```. If you opt for creating the virtualenv inside the project’s root directory, execute the following command:
```bash
$ python -m venv .venv
poetry config virtualenvs.in-project true
```

Activate the virtual environment:
### 2.2 Installation Steps

```bash
$ source .venv/bin/activate
```
#### Libraries

Create the virtual environment and install the dependencies:

Install the required packages:
```bash
$ python -m pip install -r requirements.txt
$ poetry install --no-root
```

## 3. Usage
Expand All @@ -65,7 +68,3 @@ The Pantos Common project should be used as a utility library, for example as a
### 3.1 Examples

https://github.com/pantos-io/client-library/blob/main/pantos/client/library/blockchains/base.py

## 4. Contributing

At the moment, contributing to this project is not available.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type":"function","name":"getMinimumValidatorNodeSignatures","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getPantosHub","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getPantosToken","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getValidatorNodes","inputs":[],"outputs":[{"name":"","type":"address[]","internalType":"address[]"}],"stateMutability":"view"},{"type":"function","name":"isValidSenderNonce","inputs":[{"name":"sender","type":"address","internalType":"address"},{"name":"nonce","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"isValidValidatorNodeNonce","inputs":[{"name":"nonce","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"verifyAndForwardTransfer","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferRequest","components":[{"name":"sender","type":"address","internalType":"address"},{"name":"recipient","type":"address","internalType":"address"},{"name":"token","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"serviceNode","type":"address","internalType":"address"},{"name":"fee","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"validUntil","type":"uint256","internalType":"uint256"}]},{"name":"signature","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"verifyAndForwardTransferFrom","inputs":[{"name":"sourceBlockchainFactor","type":"uint256","internalType":"uint256"},{"name":"destinationBlockchainFactor","type":"uint256","internalType":"uint256"},{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferFromRequest","components":[{"name":"destinationBlockchainId","type":"uint256","internalType":"uint256"},{"name":"sender","type":"address","internalType":"address"},{"name":"recipient","type":"string","internalType":"string"},{"name":"sourceToken","type":"address","internalType":"address"},{"name":"destinationToken","type":"string","internalType":"string"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"serviceNode","type":"address","internalType":"address"},{"name":"fee","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"validUntil","type":"uint256","internalType":"uint256"}]},{"name":"signature","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"verifyAndForwardTransferTo","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferToRequest","components":[{"name":"sourceBlockchainId","type":"uint256","internalType":"uint256"},{"name":"sourceTransferId","type":"uint256","internalType":"uint256"},{"name":"sourceTransactionId","type":"string","internalType":"string"},{"name":"sender","type":"string","internalType":"string"},{"name":"recipient","type":"address","internalType":"address"},{"name":"sourceToken","type":"string","internalType":"string"},{"name":"destinationToken","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"}]},{"name":"signerAddresses","type":"address[]","internalType":"address[]"},{"name":"signatures","type":"bytes[]","internalType":"bytes[]"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"verifyTransfer","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferRequest","components":[{"name":"sender","type":"address","internalType":"address"},{"name":"recipient","type":"address","internalType":"address"},{"name":"token","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"serviceNode","type":"address","internalType":"address"},{"name":"fee","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"validUntil","type":"uint256","internalType":"uint256"}]},{"name":"signature","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"view"},{"type":"function","name":"verifyTransferFrom","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferFromRequest","components":[{"name":"destinationBlockchainId","type":"uint256","internalType":"uint256"},{"name":"sender","type":"address","internalType":"address"},{"name":"recipient","type":"string","internalType":"string"},{"name":"sourceToken","type":"address","internalType":"address"},{"name":"destinationToken","type":"string","internalType":"string"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"serviceNode","type":"address","internalType":"address"},{"name":"fee","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"validUntil","type":"uint256","internalType":"uint256"}]},{"name":"signature","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"view"},{"type":"function","name":"verifyTransferTo","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferToRequest","components":[{"name":"sourceBlockchainId","type":"uint256","internalType":"uint256"},{"name":"sourceTransferId","type":"uint256","internalType":"uint256"},{"name":"sourceTransactionId","type":"string","internalType":"string"},{"name":"sender","type":"string","internalType":"string"},{"name":"recipient","type":"address","internalType":"address"},{"name":"sourceToken","type":"string","internalType":"string"},{"name":"destinationToken","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"}]},{"name":"signerAddresses","type":"address[]","internalType":"address[]"},{"name":"signatures","type":"bytes[]","internalType":"bytes[]"}],"outputs":[],"stateMutability":"view"},{"type":"event","name":"MinimumValidatorNodeSignaturesUpdated","inputs":[{"name":"minimumValidatorNodeSignatures","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"PantosHubSet","inputs":[{"name":"pantosHub","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"PantosTokenSet","inputs":[{"name":"pantosToken","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"ValidatorNodeAdded","inputs":[{"name":"validatorNodeAddress","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"ValidatorNodeRemoved","inputs":[{"name":"validatorNodeAddress","type":"address","indexed":false,"internalType":"address"}],"anonymous":false}]

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Loading