Skip to content

Commit

Permalink
Add Travis CI and AppVeyor configs
Browse files Browse the repository at this point in the history
  • Loading branch information
wbond committed Nov 9, 2015
1 parent 44e5b8a commit a0e2014
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 7 deletions.
75 changes: 75 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
sudo: false
language: c
matrix:
include:
- os: osx
python: "2.6"
env: TRAVIS_PYTHON_VERSION=2.6
- os: osx
python: "2.7"
env: TRAVIS_PYTHON_VERSION=2.7
- os: osx
python: "3.5"
env: TRAVIS_PYTHON_VERSION=3.5
- os: osx
python: "pypy"
env: TRAVIS_PYTHON_VERSION=pypy
- os: linux
language: python
python: "2.6"
- os: linux
language: python
python: "2.7"
- os: linux
language: python
python: "3.2"
- os: linux
language: python
python: "3.3"
- os: linux
language: python
python: "3.4"
- os: linux
language: python
python: "3.5"
- os: linux
language: python
python: "pypy"
- os: linux
language: python
python: "pypy3"
install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
if [ "$TRAVIS_PYTHON_VERSION" == "pypy" ]; then
brew install pypy;
/usr/local/bin/pip_pypy install flake8;
/usr/local/bin/pip_pypy install https://github.com/wbond/asn1crypto/archive/master.zip;
export PYTHON_BIN=/usr/local/bin/pypy;
else
if [ "$TRAVIS_PYTHON_VERSION" == "3.5" ]; then
brew install python3;
/usr/local/bin/pip3 install flake8;
/usr/local/bin/pip3 install https://github.com/wbond/asn1crypto/archive/master.zip;
export PYTHON_BIN=/usr/local/bin/python3;
else
if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then
curl --silent --show-error https://bootstrap.pypa.io/get-pip.py | sudo /usr/bin/python2.7;
sudo /usr/bin/python2.7 -W ignore -c "import pip; pip.main(['--disable-pip-version-check', '--quiet', 'install', 'flake8'])";
sudo /usr/bin/python2.7 -W ignore -c "import pip; pip.main(['--disable-pip-version-check', '--quiet', 'install', 'https://github.com/wbond/asn1crypto/archive/master.zip'])";
export PYTHON_BIN=/usr/bin/python2.7;
else
curl --silent --show-error https://bootstrap.pypa.io/get-pip.py | sudo /usr/bin/python2.6;
sudo /usr/bin/python2.6 -W ignore -c "import pip; pip.main(['--disable-pip-version-check', '--quiet', 'install', 'flake8'])";
sudo /usr/bin/python2.6 -W ignore -c "import pip; pip.main(['--disable-pip-version-check', '--quiet', 'install', 'https://github.com/wbond/asn1crypto/archive/master.zip'])";
export PYTHON_BIN=/usr/bin/python2.6;
fi
fi
fi
else
pip install --upgrade pip;
pip install flake8;
pip install https://github.com/wbond/asn1crypto/archive/master.zip;
export PYTHON_BIN=python;
fi
script:
- $PYTHON_BIN run.py ci
70 changes: 70 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: "{build}"
environment:
matrix:
- PYTHON: "C:\\Python26"
PYTHON_ID: "26"
PYTHON_EXE: python
- PYTHON: "C:\\Python26-x64"
PYTHON_ID: "26-x64"
PYTHON_EXE: python
- PYTHON: "C:\\Python27"
PYTHON_ID: "27"
PYTHON_EXE: python
- PYTHON: "C:\\Python27-x64"
PYTHON_ID: "27-x64"
PYTHON_EXE: python
- PYTHON: "C:\\Python33"
PYTHON_ID: "33"
PYTHON_EXE: python
- PYTHON: "C:\\Python33-x64"
PYTHON_ID: "33-x64"
PYTHON_EXE: python
- PYTHON: "C:\\pypy-4.0.0-win32"
PYTHON_ID: "pypy"
PYTHON_EXE: pypy
install:
- ps:
$env:PYTMP = "${env:TMP}\py";
if (!(Test-Path "$env:PYTMP")) {
New-Item -ItemType directory -Path "$env:PYTMP" | Out-Null;
}

if ("${env:PYTHON_ID}" -eq "26") {
if (!(Test-Path "${env:PYTMP}\python-2.6.6.msi")) {
(New-Object Net.WebClient).DownloadFile('https://www.python.org/ftp/python/2.6.6/python-2.6.6.msi', "${env:PYTMP}\python-2.6.6.msi");
}
Start-Process -FilePath msiexec.exe -ArgumentList ('/qn', '/i', "${env:PYTMP}\python-2.6.6.msi", "TARGETDIR=${env:PYTHON}") -Wait;
} elseif ("${env:PYTHON_ID}" -eq "26-x64") {
if (!(Test-Path "${env:PYTMP}\python-2.6.6.amd64.msi")) {
(New-Object Net.WebClient).DownloadFile('https://www.python.org/ftp/python/2.6.6/python-2.6.6.amd64.msi', "${env:PYTMP}\python-2.6.6.amd64.msi");
}
Start-Process -FilePath msiexec.exe -ArgumentList ('/qn', '/i', "${env:PYTMP}\python-2.6.6.amd64.msi", "TARGETDIR=${env:PYTHON}") -Wait;
} elseif ("${env:PYTHON_ID}" -eq "pypy") {
if (!(Test-Path "${env:PYTMP}\pypy-4.0.0-win32.zip")) {
(New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy-4.0.0-win32.zip', "${env:PYTMP}\pypy-4.0.0-win32.zip");
}
7z x -y "${env:PYTMP}\pypy-4.0.0-win32.zip" -oC:\ | Out-Null;
}

if (!(Test-Path "${env:PYTMP}\get-pip.py")) {
(New-Object Net.WebClient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', "${env:PYTMP}\get-pip.py");
}

if ("${env:PYTHON_ID}" -eq "pypy") {
& "${env:PYTHON}\pypy.exe" "${env:PYTMP}\get-pip.py";
& "${env:PYTHON}\bin\pip.exe" --disable-pip-version-check --quiet install flake8;
& "${env:PYTHON}\bin\pip.exe" --disable-pip-version-check --quiet install https://github.com/wbond/asn1crypto/archive/master.zip;
} elseif ("${env:PYTHON_ID}" -eq "26" -or "${env:PYTHON_ID}" -eq "26-x64") {
& "${env:PYTHON}\python.exe" -W ignore "${env:PYTMP}\get-pip.py";
& "${env:PYTHON}\python.exe" -W ignore -c "import pip; pip.main(['--disable-pip-version-check', '--quiet', 'install', 'flake8'])";
& "${env:PYTHON}\python.exe" -W ignore -c "import pip; pip.main(['--disable-pip-version-check', '--quiet', 'install', 'https://github.com/wbond/asn1crypto/archive/master.zip'])";
} else {
& "${env:PYTHON}\Scripts\pip.exe" --disable-pip-version-check --quiet install flake8;
& "${env:PYTHON}\Scripts\pip.exe" --disable-pip-version-check --quiet install https://github.com/wbond/asn1crypto/archive/master.zip;
}
- "SET PATH=%PYTHON%;%PATH%"
cache:
- '%TMP%\py\'
build: off
test_script:
- cmd: "%PYTHON_EXE% run.py ci"
25 changes: 25 additions & 0 deletions dev/ci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function

import sys

from .tests import run as run_tests
from .lint import run as run_lint


def run():
"""
Runs the linter and tests
:return:
A bool - if the linter and tests ran successfully
"""

print('Python ' + sys.version.replace('\n', ''))
print('')
lint_result = run_lint()
print('\nRunning tests')
sys.stdout.flush()
tests_result = run_tests()

return lint_result and tests_result
11 changes: 10 additions & 1 deletion dev/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@


def run():
"""
Runs the tests while measuring coverage
:return:
A bool - if the tests ran successfully
"""

cov = coverage.Coverage(include='oscrypto/*.py')
cov.start()

from .tests import run as run_tests
run_tests()
result = run_tests()
print()

cov.stop()
cov.save()

cov.report(show_missing=False)

return result
15 changes: 13 additions & 2 deletions dev/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@


def run():
print('Running flake8...')
"""
Runs flake8 lint
:return:
A bool - if flake8 did not find any errors
"""

print('Running flake8')

flake8_style = get_style_guide(config_file=config_file)

Expand All @@ -21,4 +28,8 @@ def run():
if not filename.endswith('.py'):
continue
paths.append(os.path.join(root, filename))
flake8_style.check_files(paths)
report = flake8_style.check_files(paths)
success = report.total_errors == 0
if success:
print('OK')
return success
20 changes: 19 additions & 1 deletion dev/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@


def run(matcher=None, repeat=1):
"""
Runs the tests
:param matcher:
A unicode string containing a regular expression to use to filter test
names by. A value of None will cause no filtering.
:param repeat:
An integer - the number of times to run the tests
:return:
A bool - if the tests succeeded
"""

loader = unittest.TestLoader()
# We have to manually track the list of applicable tests because for
# some reason with Python 3.4 on Windows, the tests in a suite are replaced
Expand All @@ -49,9 +63,13 @@ def run(matcher=None, repeat=1):
for test in test_list:
suite.addTest(test)
result = unittest.TextTestRunner(stream=stream, verbosity=verbosity).run(suite)

if len(result.errors) > 0:
if repeat > 1:
print(stream.getvalue())
break
return False

if repeat > 1:
stream.truncate(0)

return True
10 changes: 7 additions & 3 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def show_usage():
print('Usage: run.py (api_docs | lint | tests [regex] [repeat_count] | coverage)', file=sys.stderr)
print('Usage: run.py (api_docs | lint | tests [regex] [repeat_count] | coverage | ci)', file=sys.stderr)
sys.exit(1)


Expand All @@ -29,7 +29,7 @@ def get_arg(num):

task = get_arg(1)

if task not in set(['api_docs', 'lint', 'tests', 'coverage']):
if task not in set(['api_docs', 'lint', 'tests', 'coverage', 'ci']):
show_usage()

if task != 'tests' and len(sys.argv) > 2:
Expand Down Expand Up @@ -57,4 +57,8 @@ def get_arg(num):
elif task == 'coverage':
from dev.coverage import run

run(**kwargs)
elif task == 'ci':
from dev.ci import run

result = run(**kwargs)
sys.exit(int(not result))

0 comments on commit a0e2014

Please sign in to comment.