Skip to content

Commit

Permalink
Setup CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg committed Nov 1, 2019
1 parent f62a2d3 commit 3d2bec7
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 4 deletions.
40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
sudo: false
dist: xenial
addons:
apt:
packages:
- libevent-dev
cache:
pip: true
directories:
- zookeeper
language: python
python:
- '3.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_PATH="$(pwd)/zookeeper/3.4.9/lib"
- 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
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:-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"
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
[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 =
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 --cov=huskar_sdk_v2 tests/

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

0 comments on commit 3d2bec7

Please sign in to comment.