Skip to content

Commit

Permalink
CI integration (#192)
Browse files Browse the repository at this point in the history
Enable CI, fix #189
  • Loading branch information
fernandezcuesta authored Sep 25, 2020
1 parent 1e61e87 commit e0ce1bb
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 140 deletions.
234 changes: 169 additions & 65 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,202 @@
version: 2
params: &params
parameters:
version:
description: Python docker image version
default: latest
type: string

job_defaults: &job_defaults
<<: *params
executor:
name: python
version: << parameters.version >>

version: 2.1

executors:
python:
<<: *params
docker:
- image: circleci/python:<< parameters.version >>

jobs:
build:
docker: &docker
- image: circleci/python:latest
steps: &steps
- run: sudo chmod -R a+r /tmp
tests:
description: Run test suite for a specific python version
<<: *job_defaults
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v2-deps-{{ .Environment.CIRCLE_JOB }}-{{ checksum "sshtunnel.py" }}
- run: &install_sshtunnel
name: Install sshtunnel
command: sudo python setup.py install
- run: sudo pip install mock pytest{,-cov,-xdist} coveralls
- run: pip list
- sshtunnel-py<< parameters.version >>-{{ checksum "sshtunnel.py" }}
- run: &install
name: Install sshtunnel and build&test dependencies
command: |
pipenv install --python $PYTHON_VERSION -e .
pipenv install --dev -r tests/requirements.txt
environment:
- PIPENV_VENV_IN_PROJECT: 1
- save_cache: &save_cache
key: sshtunnel-py<< parameters.version >>-{{ checksum "sshtunnel.py" }}
paths:
- ~/.cache/pip
key: v2-deps-{{ .Environment.CIRCLE_JOB }}-{{ checksum "sshtunnel.py" }}
- run: py.test --showlocals --cov sshtunnel --durations=10 -n4 tests
-W ignore::DeprecationWarning
- run: coveralls

python_2.7:
docker:
- image: circleci/python:2.7
steps: *steps

python_3.4:
docker:
- image: circleci/python:3.4
steps: *steps

python_3.5:
docker:
- image: circleci/python:3.5
steps: *steps

python_3.6:
docker:
- image: circleci/python:3.6
steps: *steps

python_3.7:
docker:
- image: circleci/python:3.7
steps: *steps
- .venv/
- run:
name: Run test suite
command: >-
pipenv run py.test tests
--showlocals
--durations=10
-n4
-W ignore::DeprecationWarning
--cov sshtunnel
--cov-report=html:test_results/coverage.html
--cov-report=term
--junit-xml=test_results/report.xml
- run:
name: Coveralls
command: pipenv run coveralls
- store_test_results:
path: test_results
- store_artifacts:
path: test_results

docs:
docker: *docker
description: Produce documentation from source
<<: *job_defaults
steps:
- checkout
- run: *install_sshtunnel
- restore_cache: *restore_cache
- run: sudo pip install -r docs/requirements-docs.txt
- run: sphinx-build -WavE -b html docs _build/html
- run: *install
- save_cache: *save_cache
- run:
name: Installing documentation dependencies
command: pipenv install --dev -r docs/requirements.txt
- run:
name: Build documentation
command: pipenv run sphinx-build -WavE -b html docs _build/html
- store_artifacts:
path: _build/html
destination: sshtunnel-docs

syntax:
docker: *docker
description: Run syntax validation tests
<<: *job_defaults
steps:
- checkout
- run: *install_sshtunnel
- restore_cache: *restore_cache
- run: *install
- save_cache: *save_cache
- run:
name: installing testing dependencies
command: sudo pip install bashtest check-manifest docutils flake8
mccabe pygments readme twine
name: Installing syntax checks dependencies
command: pipenv install --dev -r tests/requirements-syntax.txt
- run:
name: checking MANIFEST.in
command: sudo check-manifest --ignore "tox.ini,tests*,*.yml"
command: pipenv run check-manifest --ignore tox.ini,tests*,*.yml
- run:
name: checking RST syntax
command: sudo python setup.py sdist ; twine check dist/*
command: |
pipenv run python setup.py sdist
pipenv run twine check dist/*
- run:
name: checking PEP8 compliancy
command: flake8 --ignore=W504 .
command: pipenv run flake8 --exclude .venv,build,docs --max-complexity 10 --ignore=W504
- run:
name: checking CLI help
command: bashtest README.rst
- save_cache: *save_cache
command: pipenv run bashtest README.rst

testdeploy:
description: Build and upload artifacts to Test PyPI
<<: *job_defaults
steps:
- checkout
- restore_cache: *restore_cache
- run:
name: Build artifact
command: |
formats=( 'bdist_egg' )
[[ << parameters.version >> == 'latest' ]] && formats+=( 'bdist_wheel' 'sdist' )
pipenv run python setup.py ${formats[@]}
- run:
name: Check artifacts
command: pipenv run twine check dist/*
- store_artifacts:
path: dist/
- run:
name: Upload to TestPyPI
command: >-
pipenv run twine upload
--repository testpypi
--username __token__
--password $TESTPYPI_TOKEN
--skip-existing
dist/*
deploy:
description: Build and upload artifacts to PyPI
<<: *job_defaults
steps:
- checkout
- restore_cache: *restore_cache
- run:
name: Build artifact
command: |
formats=( 'bdist_egg' )
(( << parameters.version >> == 'latest' )) && formats+=( 'bdist_wheel' )
pipenv run python setup.py ${formats[@]}
- run:
name: Upload to PyPI
command: >-
pipenv run twine upload
--username __token__
--password $PYPI_TOKEN
--skip-existing
dist/*
workflows:
version: 2
tests:
jobs:
- build # python3.7
- python_2.7
- python_3.4
- python_3.5
- python_3.6
- python_3.7
syntax_and_docs:
jobs:
- syntax
- docs

test_and_deploy:
jobs:
- tests:
matrix:
parameters:
version:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- testdeploy:
requires:
- tests
matrix:
parameters:
version:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "latest"

- hold:
type: approval
requires:
- testdeploy

- deploy:
requires:
- hold
matrix:
parameters:
version:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "latest"

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ pytestdebug.log

# due to sphinx
docs/_build/

# Pipfile
Pipfile*
6 changes: 4 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ include docs/Makefile
include docs/*.rst
include docs/*.txt
include tests/*
include .circleci/*

exclude .circleci/*
exclude *.pyc
exclude __pycache__
exclude Pipfile*
24 changes: 0 additions & 24 deletions circle.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _warn_node(self, msg, node):

# General information about the project.
project = 'sshtunnel'
copyright = '2014-2019, Pahaz Blinov and contributors'
copyright = '2014-2020, Pahaz Blinov and contributors'
author = 'Pahaz Blinov'

# The version info for the project you're documenting, acts as replacement for
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
22 changes: 2 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
"""

import re
import sys
from os import path
from codecs import open # To use a consistent encoding

from setuptools import setup # Always prefer setuptools over distutils
from setuptools.command.test import test as TestCommand

here = path.abspath(path.dirname(__file__))
name = 'sshtunnel'
Expand All @@ -32,21 +29,6 @@
version = eval(re.search("__version__[ ]*=[ ]*([^\r\n]+)", data).group(1))


class Tox(TestCommand):
""" Integration with tox """

def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = ['--recreate', '-v']
self.test_suite = True

def run_tests(self):
# import here, otherwise eggs aren't loaded
import tox
errcode = tox.cmdline(self.test_args)
sys.exit(errcode)


setup(
name=name,

Expand All @@ -57,6 +39,7 @@ def run_tests(self):

description=description,
long_description='\n'.join((long_description, documentation, changelog)),
long_description_content_type='text/x-rst',

# The project's main homepage.
url=url,
Expand Down Expand Up @@ -93,6 +76,7 @@ def run_tests(self):
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],

platforms=['unix', 'macos', 'windows'],
Expand Down Expand Up @@ -150,6 +134,4 @@ def run_tests(self):
]
},

# Integrate tox with setuptools
cmdclass={'test': Tox},
)
4 changes: 2 additions & 2 deletions sshtunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import SocketServer as socketserver
string_types = basestring, # noqa
input_ = raw_input # noqa
else:
else: # pragma: no cover
import queue
import socketserver
string_types = str
Expand Down Expand Up @@ -1532,7 +1532,7 @@ def __str__(self):
self.ssh_proxy.cmd[1] if self.ssh_proxy else 'no',
self.ssh_username,
credentials,
self.ssh_host_key if self.ssh_host_key else'not checked',
self.ssh_host_key if self.ssh_host_key else 'not checked',
'' if self.is_alive else 'not ',
'disabled' if not self.set_keepalive else
'every {0} sec'.format(self.set_keepalive),
Expand Down
Loading

0 comments on commit e0ce1bb

Please sign in to comment.