Skip to content

Commit

Permalink
Merge pull request #1545 from kclowes/add-release-test
Browse files Browse the repository at this point in the history
Add script to test packaging
  • Loading branch information
kclowes authored Apr 13, 2020
2 parents 79a661d + c09b417 commit a0a1763
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 6 deletions.
30 changes: 27 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ jobs:
environment:
TOXENV: py36-integration-ethtester
ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend
py36-wheel-cli:
<<: *common
docker:
- image: circleci/python:3.6
environment:
TOXENV: py36-wheel-cli
#
# Python 3.7
#
Expand Down Expand Up @@ -420,6 +426,12 @@ jobs:
environment:
TOXENV: py37-integration-ethtester
ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend
py37-wheel-cli:
<<: *common
docker:
- image: circleci/python:3.7
environment:
TOXENV: py37-wheel-cli
#
# Python 3.8
#
Expand Down Expand Up @@ -553,13 +565,24 @@ jobs:
TOXENV: py38-integration-ethtester
ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend

py38-wheel-cli:
<<: *common
docker:
- image: circleci/python:3.8
environment:
TOXENV: py38-wheel-cli

workflows:
version: 2
test:
jobs:
# These are the longest running tests, start them first
- py36-core
- py37-core
- py38-core

- lint
- docs
- py36-core
- py36-ens
- py36-ethpm
- py36-integration-goethereum-ipc-1.7.2
Expand All @@ -575,7 +598,7 @@ workflows:
- py36-integration-parity-http
- py36-integration-parity-ws
- py36-integration-ethtester-pyevm
- py37-core
- py36-wheel-cli
- py37-ens
- py37-ethpm
- py37-integration-goethereum-ipc-1.7.2
Expand All @@ -591,7 +614,7 @@ workflows:
- py37-integration-parity-http
- py37-integration-parity-ws
- py37-integration-ethtester-pyevm
- py38-core
- py37-wheel-cli
- py38-ens
- py38-ethpm
- py38-integration-goethereum-ipc-1.7.2
Expand All @@ -607,3 +630,4 @@ workflows:
- py38-integration-parity-http
- py38-integration-parity-ws
- py38-integration-ethtester-pyevm
- py38-wheel-cli
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ release: clean
dist: clean
python setup.py sdist bdist_wheel
ls -l dist

package: clean
python setup.py sdist bdist_wheel
python web3/scripts/release/test_package.py
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ To start up the test environment, run:
docker-compose up -d
```

This will build a Docker container set up with an environment to run the Python test code.
This will build a Docker container set up with an environment to run the Python test code.

**Note: This container does not have `go-ethereum` installed, so you cannot run the go-ethereum test suite.**

Expand Down Expand Up @@ -134,6 +134,33 @@ For Debian-like systems:
apt install pandoc
```

The final step before releasing is to build and test the code that will be released.
There is a test script that will build and install the wheel locally,
then generate a temporary virtualenv where you can do some smoke testing:

```
# Branch name could be either master or a version branch - ex. v5
$ git checkout <branch name> && git pull
$ make package
# in another shell, navigate to the virtualenv mentioned in output of ^
# load the virtualenv with the packaged trinity release
$ source package-smoke-test/bin/activate
# smoke test the release
$ pip install ipython
$ ipython
>>> from web3.auto import w3
>>> w3.isConnected()
>>> ...
# Preview the upcoming release notes
$ towncrier --draft
```

To release a new version:

```sh
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
'web3.middleware.rst',
'web3.providers.rst',
'web3.providers.eth_tester.rst',
'web3.scripts.*',
'web3.testing.rst',
'web3.tools.*',
]
Expand Down
1 change: 1 addition & 0 deletions newsfragments/1545.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add script to test release install
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"py-geth>=2.2.0,<3",
"py-solc>=0.4.0",
"pytest>=4.4.0,<5.0.0",
"sphinx",
"sphinx>=2.4.4,<3",
"sphinx_rtd_theme>=0.1.9",
"toposort>=1.4",
"towncrier>=19.2.0,<20",
Expand Down
32 changes: 31 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ envlist=
py{36,37,38}-integration-{goethereum,ethtester,parity}
lint
docs
py{36,37,38}-wheel-cli

[isort]
combine_as_imports=True
Expand All @@ -24,6 +25,7 @@ max-line-length= 100
exclude= venv*,.tox,docs,build
ignore=
[testenv]
whitelist_externals=/usr/bin/make
install_command=python -m pip install --no-use-pep517 {opts} {packages}
usedevelop=True
commands=
Expand All @@ -40,7 +42,6 @@ commands=
docs: make -C {toxinidir} validate-docs
deps =
.[dev]
docs: sphinx
passenv =
GETH_BINARY
GETH_VERSION
Expand All @@ -64,3 +65,32 @@ commands=
flake8 {toxinidir}/web3 {toxinidir}/ens {toxinidir}/ethpm {toxinidir}/tests
isort --recursive --check-only --diff {toxinidir}/web3/ {toxinidir}/ens/ {toxinidir}/ethpm/ {toxinidir}/tests/
mypy -p web3 -p ethpm -p ens --config-file {toxinidir}/mypy.ini

[common-wheel-cli]
deps=wheel
whitelist_externals=
/bin/rm
/bin/bash
commands=
/bin/rm -rf build dist
python setup.py sdist bdist_wheel
/bin/bash -c 'pip install --upgrade "$(ls dist/web3-*-py3-none-any.whl)" --progress-bar off'
python -c "from web3.auto import w3"

[testenv:py36-wheel-cli]
deps={[common-wheel-cli]deps}
whitelist_externals={[common-wheel-cli]whitelist_externals}
commands={[common-wheel-cli]commands}
skip_install=true

[testenv:py37-wheel-cli]
deps={[common-wheel-cli]deps}
whitelist_externals={[common-wheel-cli]whitelist_externals}
commands={[common-wheel-cli]commands}
skip_install=true

[testenv:py38-wheel-cli]
deps={[common-wheel-cli]deps}
whitelist_externals={[common-wheel-cli]whitelist_externals}
commands={[common-wheel-cli]commands}
skip_install=true
Empty file added web3/scripts/__init__.py
Empty file.
Empty file.
61 changes: 61 additions & 0 deletions web3/scripts/release/test_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from pathlib import (
Path,
)
import subprocess
from tempfile import (
TemporaryDirectory,
)
from typing import (
Tuple,
)
import venv


def create_venv(parent_path: Path) -> Path:
venv_path = parent_path / 'package-smoke-test'
venv.create(venv_path, with_pip=True)
subprocess.run([venv_path / 'bin' / 'pip', 'install', '-U', 'pip', 'setuptools'], check=True)
return venv_path


def find_wheel(project_path: Path) -> Path:
wheels = list(project_path.glob('dist/*.whl'))

if len(wheels) != 1:
raise Exception(
f"Expected one wheel. Instead found: {wheels} in project {project_path.absolute()}"
)

return wheels[0]


def install_wheel(
venv_path: Path, wheel_path: Path, extras: Tuple[str, ...] = ()
) -> None:
if extras:
extra_suffix = f"[{','.join(extras)}]"
else:
extra_suffix = ""

subprocess.run(
[
venv_path / 'bin' / 'pip',
'install',
f"{wheel_path}{extra_suffix}"
],
check=True,
)


def test_install_local_wheel() -> None:
with TemporaryDirectory() as tmpdir:
venv_path = create_venv(Path(tmpdir))
wheel_path = find_wheel(Path('.'))
install_wheel(venv_path, wheel_path)
print("Installed", wheel_path.absolute(), "to", venv_path)
print(f"Activate with `source {venv_path}/bin/activate`")
input("Press enter when the test has completed. The directory will be deleted.")


if __name__ == '__main__':
test_install_local_wheel()

0 comments on commit a0a1763

Please sign in to comment.