From aa5af04447dfae24731557c6beead55bd8ff99a9 Mon Sep 17 00:00:00 2001 From: "F. Eugene Aumson" Date: Wed, 9 Jan 2019 09:58:29 -0500 Subject: Python contract demo, with lots of refactoring (#1485) * Refine Order for Web3 compat. & add conversions Changed some of the fields in the Order class so that it can be passed to our contracts via Web3. Added conversion utilities so that an Order can be easily converted to and from a JSON-compatible dict (specifically by encoding/decoding the `bytes` fields), to facilitate validation against the JSON schema. Also modified JSON order schema to accept integers in addition to stringified integers. * Fixes for json_schemas Has-types indicator file, py.typed, was not being included in package. Schemas were not being properly gathered into package installation. * Add test/demo of Exchange.getOrderInfo() * web3 bug workaround * Fix problem packaging contract artifacts * Move contract addresses to their own package * Move contract artifacts to their own package * Add scripts to install, test & lint all components * prettierignore files in local python dev env * Correct missing coverage analysis for sra_client * CI cache lint: don't save, re-use from test-python * tag hacks as hacks * correct merge mistake * remove local strip_0x() in favor of eth_utils * remove json schemas from old order_utils location * correct merge mistake * doctest json schemas via command-line, not code --- .circleci/config.yml | 87 ++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 53 deletions(-) (limited to '.circleci') diff --git a/.circleci/config.yml b/.circleci/config.yml index 0206c514e..650780024 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -200,46 +200,30 @@ jobs: key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} - run: command: | - cd python-packages/json_schemas + cd python-packages python -m ensurepip - python -m pip install .[dev] - # HACK! installing the package should do the following - # copy for us, but it's not working in CircleCI for some - # reason. Zendesk support ticket raised (#43979) with - # CircleCI. - mkdir /usr/local/lib/python3.7/site-packages/zero_ex/json_schemas/schemas - cp -R src/zero_ex/json_schemas/schemas/* /usr/local/lib/python3.7/site-packages/zero_ex/json_schemas/schemas - - run: - command: | - cd python-packages/order_utils - python -m ensurepip - python -m pip install .[dev] - - run: - command: | - cd python-packages/sra_client - python -m ensurepip - python -m pip install .[dev] + ./install - save_cache: key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} paths: - '/usr/local/bin' - '/usr/local/lib/python3.7/site-packages' - - '.eggs' - - '.mypy_cache' - - '.pytest_cache' - - '.tox' - run: command: | - cd python-packages/json_schemas - coverage run setup.py test - - run: - command: | - cd python-packages/order_utils - coverage run setup.py test - - run: - command: | - cd python-packages/sra_client - coverage run setup.py test + cd python-packages + ./cmd_pkgs_in_dep_order.py coverage run setup.py test + - save_cache: + key: coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ~/repo/python-packages/contract_addresses/.coverage + - save_cache: + key: coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ~/repo/python-packages/contract_artifacts/.coverage + - save_cache: + key: coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ~/repo/python-packages/contract_demo/.coverage - save_cache: key: coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }} paths: @@ -292,27 +276,10 @@ jobs: key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} - run: command: | - cd python-packages/json_schemas - python -m ensurepip - python -m pip install .[dev] - - run: - command: | - cd python-packages/order_utils python -m ensurepip - python -m pip install .[dev] - - save_cache: - key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} - paths: - - '/usr/local/bin' - - '/usr/local/lib/python3.7/site-packages' - - run: - command: | - cd python-packages/json_schemas - python setup.py lint - - run: - command: | - cd python-packages/order_utils - python setup.py lint + cd python-packages + ./install + ./lint static-tests: working_directory: ~/repo docker: @@ -384,6 +351,18 @@ jobs: - restore_cache: keys: - coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }} + - restore_cache: + keys: + - coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }} + - restore_cache: + keys: + - coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }} + - restore_cache: + keys: + - coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }} + - restore_cache: + keys: + - coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: - coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }} @@ -421,7 +400,9 @@ workflows: requires: - test-rest - test-python + - static-tests-python: + requires: + - test-python - test-python - - static-tests-python # skip python tox run for now, as we don't yet have multiple test environments to support. #- test-rest-python -- cgit v1.2.3