Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Setup CI #5

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
sudo: false
dist: xenial
addons:
apt:
packages:
- libevent-dev
cache:
pip: true
directories:
- zookeeper
language: python
python:
- '2.7'
matrix:
include:
- python: '2.7'
env: TOX_ENV=py27
# - python: '3.4'
# env: TOX_ENV=py34
# - python: '3.5'
# env: TOX_ENV=py35
# - python: '3.6'
# env: TOX_ENV=py36
# - python: '3.7'
# env: TOX_ENV=py37
# - python: '3.8'
# env: TOX_ENV=py38
# - python: pypy
# env: TOX_ENV=pypy
# - python: pypy3
# env: TOX_ENV=pypy3
notifications:
email: false
install:
- pip install tox codecov
- ZOOKEEPER_VERSION=3.4.9 bash -x ./tools/ci/ensure-zookeeper-env.sh
script: |
export ZOOKEEPER_VERSION=3.4.9
export ZOOKEEPER_PATH="$(pwd)/zookeeper/3.4.9"

tox -e $TOX_ENV

codecov
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Huskar SDK

[![Build Status](https://travis-ci.com/huskar-org/huskar-python.svg?branch=master)](https://travis-ci.com/huskar-org/huskar-python)
[![codecov](https://codecov.io/gh/huskar-org/huskar-python/branch/master/graph/badge.svg)](https://codecov.io/gh/huskar-org/huskar-python)

- [Documentation](https://github.com/huskar-org/huskar-python)

- [Toturial](https://github.com/huskar-org/huskar-python)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def run_tests(self):
"pytest-cov==2.5.1",
"pytest-xdist==1.20.0",
"pytest-mock==1.6.2",
"pytest-forked==0.2",
"mock==2.0.0"]

setup(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_kazoo_client/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _func(*args):

pool = [C(target=run(func, l), args=(i,)) for i, (l, r) in ps]
[c.start() for c in pool]
[c.join() for c in pool]
[c.join(timeout=3) for c in pool]
return [r.recv() for _, (l, r) in ps]
return pool_map

Expand Down
36 changes: 36 additions & 0 deletions tools/ci/ensure-zookeeper-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

# base on https://github.com/python-zk/kazoo/blob/master/ensure-zookeeper-env.sh

set -euo pipefail
set -x
IFS=$'\n\t'

HERE=$(pwd)
ZOO_BASE_DIR="$HERE/zookeeper"
ZOOKEEPER_VERSION=${ZOOKEEPER_VERSION:-3.4.9}
ZOOKEEPER_PATH="$ZOO_BASE_DIR/$ZOOKEEPER_VERSION"
ZOOKEEPER_PREFIX="${ZOOKEEPER_PREFIX:-}"
ZOOKEEPER_SUFFIX="${ZOOKEEPER_SUFFIX:-}"
ZOOKEEPER_LIB="${ZOOKEEPER_LIB:-}"
ZOO_MIRROR_URL="http://archive.apache.org/dist"


function download_zookeeper(){
mkdir -p "$ZOO_BASE_DIR"
cd "$ZOO_BASE_DIR"
curl --silent -C - "$ZOO_MIRROR_URL/zookeeper/zookeeper-$ZOOKEEPER_VERSION/${ZOOKEEPER_PREFIX}zookeeper-${ZOOKEEPER_VERSION}${ZOOKEEPER_SUFFIX}.tar.gz" | tar -zx
mv "${ZOOKEEPER_PREFIX}zookeeper-${ZOOKEEPER_VERSION}${ZOOKEEPER_SUFFIX}" "$ZOOKEEPER_VERSION"
chmod a+x "$ZOOKEEPER_PATH/bin/zkServer.sh"
}

if [ ! -d "$ZOOKEEPER_PATH" ]; then
download_zookeeper
echo "Downloaded zookeeper $ZOOKEEPER_VERSION to $ZOOKEEPER_PATH"
else
echo "Already downloaded zookeeper $ZOOKEEPER_VERSION to $ZOOKEEPER_PATH"
fi

# Used as install_path when starting ZK
export ZOOKEEPER_PATH="${ZOOKEEPER_PATH}/${ZOOKEEPER_LIB}"
echo "$ZOOKEEPER_PATH"
9 changes: 5 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
[tox]
minversion = 2.5
envlist = erase,py27,py34,py35
envlist = erase,py27,py34,py35,py36,py37,py38,pypy,pypy3

[testenv]
changedir = {toxinidir}/.tox
deps =
flake8
extras =
test
bootstrap
setenv =
passenv =
ZOOKEEPER_*
commands =
flake8 --exclude=.tox,.venv,docs,build {toxinidir}
py.test --cov={envsitepackagesdir}/huskar_sdk_v2 --cov-append --boxed {toxinidir} {posargs}
flake8 --exclude=.tox,.venv,docs,build,zookeeper huskar_sdk_v2
py.test -v --cov=huskar_sdk_v2 tests/

[testenv:erase]
basepython = python2.7
Expand Down