Skip to content

Commit

Permalink
add travis and tox
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Jul 23, 2019
1 parent 2dfea24 commit 8008882
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 222 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Binaries
bin
solcx/temp

# C extensions
*.so
Expand Down Expand Up @@ -58,3 +59,6 @@ docs/_build

# npm
node_modules

# other
.vscode
223 changes: 37 additions & 186 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,189 +1,40 @@
language: python
python:
- "3.5"
os:
- linux
dist: trusty
sudo: required
env:
global:
- SOLC_BASE_INSTALL_PATH=$TRAVIS_BUILD_DIR
# Based on https://github.com/cclauss/Travis-CI-Python-on-three-OSes
matrix:
include:
# lint
- python: "3.5"
env: TOX_POSARGS="-e flake8"
# installation
- python: "3.4"
env: TOX_POSARGS="-e py34-installation"
- python: "3.5"
env: TOX_POSARGS="-e py35-installation"
- python: "3.6"
env: TOX_POSARGS="-e py36-installation"
# solc 0.4.1
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.1
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.1
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.1
# solc 0.4.2
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.2
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.2
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.2
# solc 0.4.6
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.6
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.6
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.6
# solc 0.4.7
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.7
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.7
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.7
# solc 0.4.8
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.8
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.8
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.8
# solc 0.4.9
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.9
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.9
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.9
# solc 0.4.11
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.11
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.11
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.11
# solc 0.4.12
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.12
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.12
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.12
# solc 0.4.13
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.13
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.13
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.13
# solc 0.4.14
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.14
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.14
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.14
# solc 0.4.15
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.15
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.15
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.15
# solc 0.4.16
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.16
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.16
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.16
# solc 0.4.17
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.17
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.17
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.17
# solc 0.4.18
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.18
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.18
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.18
# solc 0.4.19
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.19
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.19
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.19
# solc 0.4.20
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.20
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.20
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.20
# solc 0.4.21
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.21
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.21
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.21
# solc 0.4.22
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.22
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.22
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.22
# solc 0.4.23
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.23
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.23
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.23
# solc 0.4.24
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.24
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.24
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.24
# solc 0.4.25
- python: "3.4"
env: TOX_POSARGS="-e py34" SOLC_VERSION=v0.4.25
- python: "3.5"
env: TOX_POSARGS="-e py35" SOLC_VERSION=v0.4.25
- python: "3.6"
env: TOX_POSARGS="-e py36" SOLC_VERSION=v0.4.25
- name: "Python 3.7.1 on Xenial Linux"
language: python
python: 3.7 # this works for Linux but is ignored on macOS or Windows
dist: xenial # required for Python >= 3.7
sudo: true
install:
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo apt-get update
- sudo apt-get install -y solc
- pip install -r requirements-dev.txt
- pip install flake8
script: flake8 solcx/ tests/ --max-line-length=100
- name: "Python 3.6.8 on Xenial Linux"
language: python
python: 3.6
dist: xenial
sudo: true
install:
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo apt-get update
- sudo apt-get install -y solc
- pip install -r requirements-dev.txt
script: python -m pytest tests/ --cov=solcx/
- name: "Python 3.7.3 on Windows"
os: windows # Windows 10.0.17134 N/A Build 17134
language: shell # 'language: python' is an error on Travis CI Windows
# python: 3.7 # 'python:' is ignored on Travis CI Windows
install:
- choco install python # this install takes at least 1 min 30 sec
- python -m pip install --upgrade pip
- pip3 install -r requirements-dev.txt
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH

cache:
- pip: true
before_install:
install:
- travis_retry pip install setuptools --upgrade
- travis_retry pip install tox
- pip --version
- pip install -e . # install py-solc globally in order to use the solc installation scripts.
before_script:
- python --version
- if [ -n "$SOLC_VERSION" ]; then python -m solc.install $SOLC_VERSION; fi
- if [ -n "$SOLC_VERSION" ]; then export SOLC_BINARY="$SOLC_BASE_INSTALL_PATH/solc-$SOLC_VERSION/bin/solc"; fi
- if [ -n "$SOLC_VERSION" ]; then export LD_LIBRARY_PATH="$SOLC_BASE_INSTALL_PATH/solc-$SOLC_VERSION/bin"; fi
- env
- if [ -n "$SOLC_BINARY" ]; then $SOLC_BINARY --version; fi
script:
- tox $TOX_POSARGS
after_script:
- cat .tox/$TOX_POSARGS/log/*.log
script: python -m pytest tests --cov=solcx/
after_success: coveralls
notifications:
email: false
9 changes: 5 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pytest>=2.9.2
tox>=2.3.1
coveralls==1.7.0
pytest>=5.0.0
pytest-cov>=2.7.1
semantic_version>=2.6.0
bumpversion==0.5.3
twine==1.12.1
twine==1.13.0
requests>=2.19.0
4 changes: 2 additions & 2 deletions solcx/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ def set_solc_version_pragma(version, silent=False):
print("Using solc version {}".format(solc_version))


def get_available_solc_versions():
def get_available_solc_versions(headers={}):
versions = []
pattern = VERSION_REGEX[_get_platform()]
for release in requests.get(ALL_RELEASES).json():
for release in requests.get(ALL_RELEASES, headers=headers).json():
asset = next((i for i in release['assets'] if re.match(pattern, i['name'])), False)
if asset:
versions.append(release['tag_name'])
Expand Down
Binary file removed solcx/temp/solc-binary
Binary file not shown.
52 changes: 52 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from base64 import b64encode
import os
import pytest
import sys

import solcx

TEST_CONTRACT = '''pragma solidity >=0.4.11 <0.6.0;
contract Foo {
function return13() public returns (uint) {
return 13;
}
}
'''

if sys.platform == "darwin":
VERSIONS = solcx.get_installed_solc_versions()
else:
auth = b64encode(os.environ['GITAUTH'].encode()).decode('ascii')
headers = {'Authorization': f"Basic {auth}"}
VERSIONS = solcx.get_available_solc_versions(headers=headers)


def pytest_generate_tests(metafunc):
if 'all_versions' in metafunc.fixturenames:
metafunc.parametrize('all_versions', VERSIONS, indirect=True)


_installed = {}
@pytest.fixture()
def all_versions(request):
version = request.param
if version not in _installed:
try:
solcx.install_solc(version)
_installed[version] = True
except Exception:
_installed[version] = False
pytest.fail(f"Unable to install solc {version}")
if _installed[version]:
solcx.set_solc_version(version)
else:
request.applymarker('skip')


@pytest.fixture()
def contract_source(tmp_path):
source = tmp_path.joinpath('test.sol')
with source.open('w') as fp:
fp.write(TEST_CONTRACT)
return str(source)
12 changes: 12 additions & 0 deletions tests/test_compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest

import solcx


@pytest.fixture(autouse=True)
def setup(all_versions):
pass


def test_compile_files(contract_source):
solcx.compile_files([contract_source])
30 changes: 0 additions & 30 deletions tox.ini

This file was deleted.

0 comments on commit 8008882

Please sign in to comment.