Skip to content

Commit

Permalink
chore(ci): Replace Travis with Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenSorriaux committed Aug 6, 2021
1 parent 6337fd6 commit 8eb462f
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 38 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,38 @@
name: Kazoo Awesome Release

on: [push]

jobs:
build-and-release:
name: Build and release Kazoo to Pypi
runs-on: ubuntu-latest
steps:
- name: Handle the code
uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish Kazoo to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
68 changes: 68 additions & 0 deletions .github/workflows/testing.yml
@@ -0,0 +1,68 @@
name: Kazoo Awesome Testing

on: [push]

jobs:
test:
name: >
Test Python ${{ matrix.python-version }},
ZK ${{ matrix.zk-version }}
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.7, 3.8, 3.9, pypy-3.7]
zk-version: [3.4.14, 3.5.8]
include:
- python-version: 3.7
tox-env: py37
- python-version: 3.8
tox-env: py38
- python-version: 3.9
tox-env: py39
- python-version: pypy-3.7
tox-env: pypy3
steps:
- name: Handle the code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Handle pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Handle ZK installation cache
uses: actions/cache@v2
with:
path: zookeeper
key: ${{ runner.os }}-zookeeper
restore-keys: |
${{ runner.os }}-zookeeper
- name: Install required dependencies
run: |
sudo apt-get -y install libevent-dev krb5-kdc krb5-admin-server libkrb5-dev
python -m pip install --upgrade pip
pip install tox
- name: Test with tox
run: tox -e ${TOX_VENV}
env:
TOX_VENV: ${{ format('{0}-{1}', matrix.tox-env, 'gevent-eventlet-sasl,codecov') }}
ZOOKEEPER_VERSION: ${{ matrix.zk-version }}
# TODO: can be removed once tests for ZK 3.4 are removed
ZOOKEEPER_PREFIX: "${{ !contains(matrix.zk-version, '3.4') && 'apache-' || '' }}"
ZOOKEEPER_SUFFIX: "${{ !contains(matrix.zk-version, '3.4') && '-bin' || '' }}"
ZOOKEEPER_LIB: "${{ !contains(matrix.zk-version, '3.4') && 'lib' || '' }}"

- name: Publish Codecov report
uses: codecov/codecov-action@v2
File renamed without changes.
8 changes: 4 additions & 4 deletions Makefile
Expand Up @@ -7,11 +7,11 @@ BUILD_DIRS = bin build include lib lib64 man share

PYTHON_EXE = $(shell [ -f $(PYTHON) ] && echo $(PYTHON) || echo python)
PYPY = $(shell $(PYTHON_EXE) -c "import sys; print(getattr(sys, 'pypy_version_info', False) and 'yes' or 'no')")
TRAVIS ?= false
TRAVIS_PYTHON_VERSION ?= $(shell $(PYTHON_EXE) -c "import sys; print('.'.join([str(s) for s in sys.version_info][:2]))")
CI ?= false
CI_PYTHON_VERSION ?= $(shell $(PYTHON_EXE) -c "import sys; print('.'.join([str(s) for s in sys.version_info][:2]))")

GREENLET_SUPPORTED = yes
ifeq ($(findstring 3.,$(TRAVIS_PYTHON_VERSION)), 3.)
ifeq ($(findstring 3.,$(CI_PYTHON_VERSION)), 3.)
GREENLET_SUPPORTED = no
VENV_CMD = $(PYTHON_EXE) -m venv .
else
Expand All @@ -33,7 +33,7 @@ ifeq ($(GREENLET_SUPPORTED),yes)
$(INSTALL) -U -r requirements_eventlet.txt
$(INSTALL) -U -r requirements_gevent.txt
endif
ifneq ($(TRAVIS), true)
ifneq ($(CI), true)
$(INSTALL) -U -r requirements_sphinx.txt
endif
$(INSTALL) -U -r requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions kazoo/tests/test_build.py
Expand Up @@ -8,8 +8,8 @@
class TestBuildEnvironment(KazooTestCase):
def setUp(self):
KazooTestCase.setUp(self)
if not os.environ.get('TRAVIS'):
pytest.skip('Only run build config tests on Travis.')
if not os.environ.get('CI'):
pytest.skip('Only run build config tests on CI.')

def test_zookeeper_version(self):
server_version = self.client.server_version()
Expand Down
18 changes: 9 additions & 9 deletions kazoo/tests/test_client.py
Expand Up @@ -26,7 +26,7 @@
)
from kazoo.protocol.connection import _CONNECTION_DROP
from kazoo.protocol.states import KeeperState, KazooState
from kazoo.tests.util import TRAVIS_ZK_VERSION
from kazoo.tests.util import CI_ZK_VERSION


if sys.version_info > (3, ): # pragma: nocover
Expand Down Expand Up @@ -605,8 +605,8 @@ def test_create_acl_duplicate(self):
client.create("/1", acl=[single_acl, single_acl])
acls, stat = client.get_acls("/1")
# ZK >3.4 removes duplicate ACL entries
if TRAVIS_ZK_VERSION:
version = TRAVIS_ZK_VERSION
if CI_ZK_VERSION:
version = CI_ZK_VERSION
else:
version = client.server_version()
assert len(acls) == 1 if version > (3, 4) else 2
Expand Down Expand Up @@ -718,8 +718,8 @@ def test_create_exists(self):
client.create(path)

def test_create_stat(self):
if TRAVIS_ZK_VERSION:
version = TRAVIS_ZK_VERSION
if CI_ZK_VERSION:
version = CI_ZK_VERSION
else:
version = self.client.server_version()
if not version or version < (3, 5):
Expand Down Expand Up @@ -1176,9 +1176,9 @@ class TestClientTransactions(KazooTestCase):
def setUp(self):
KazooTestCase.setUp(self)
skip = False
if TRAVIS_ZK_VERSION and TRAVIS_ZK_VERSION < (3, 4):
if CI_ZK_VERSION and CI_ZK_VERSION < (3, 4):
skip = True
elif TRAVIS_ZK_VERSION and TRAVIS_ZK_VERSION >= (3, 4):
elif CI_ZK_VERSION and CI_ZK_VERSION >= (3, 4):
skip = False
else:
ver = self.client.server_version()
Expand Down Expand Up @@ -1378,8 +1378,8 @@ class TestReconfig(KazooTestCase):
def setUp(self):
KazooTestCase.setUp(self)

if TRAVIS_ZK_VERSION:
version = TRAVIS_ZK_VERSION
if CI_ZK_VERSION:
version = CI_ZK_VERSION
else:
version = self.client.server_version()
if not version or version < (3, 5):
Expand Down
6 changes: 3 additions & 3 deletions kazoo/tests/test_connection.py
Expand Up @@ -19,7 +19,7 @@
from kazoo.protocol.connection import _CONNECTION_DROP
from kazoo.testing import KazooTestCase
from kazoo.tests.util import wait
from kazoo.tests.util import TRAVIS_ZK_VERSION
from kazoo.tests.util import CI_ZK_VERSION


class Delete(namedtuple('Delete', 'path version')):
Expand Down Expand Up @@ -259,9 +259,9 @@ class TestReadOnlyMode(KazooTestCase):
def setUp(self):
self.setup_zookeeper(read_only=True)
skip = False
if TRAVIS_ZK_VERSION and TRAVIS_ZK_VERSION < (3, 4):
if CI_ZK_VERSION and CI_ZK_VERSION < (3, 4):
skip = True
elif TRAVIS_ZK_VERSION and TRAVIS_ZK_VERSION >= (3, 4):
elif CI_ZK_VERSION and CI_ZK_VERSION >= (3, 4):
skip = False
else:
ver = self.client.server_version()
Expand Down
6 changes: 3 additions & 3 deletions kazoo/tests/test_queue.py
Expand Up @@ -3,7 +3,7 @@
import pytest

from kazoo.testing import KazooTestCase
from kazoo.tests.util import TRAVIS_ZK_VERSION
from kazoo.tests.util import CI_ZK_VERSION


class KazooQueueTests(KazooTestCase):
Expand Down Expand Up @@ -59,9 +59,9 @@ class KazooLockingQueueTests(KazooTestCase):
def setUp(self):
KazooTestCase.setUp(self)
skip = False
if TRAVIS_ZK_VERSION and TRAVIS_ZK_VERSION < (3, 4):
if CI_ZK_VERSION and CI_ZK_VERSION < (3, 4):
skip = True
elif TRAVIS_ZK_VERSION and TRAVIS_ZK_VERSION >= (3, 4):
elif CI_ZK_VERSION and CI_ZK_VERSION >= (3, 4):
skip = False
else:
ver = self.client.server_version()
Expand Down
14 changes: 7 additions & 7 deletions kazoo/tests/test_sasl.py
Expand Up @@ -9,7 +9,7 @@
AuthFailedError,
NoAuthError,
)
from kazoo.tests.util import TRAVIS_ZK_VERSION
from kazoo.tests.util import CI_ZK_VERSION


class TestLegacySASLDigestAuthentication(KazooTestHarness):
Expand All @@ -22,8 +22,8 @@ def setUp(self):
os.environ["ZOOKEEPER_JAAS_AUTH"] = "digest"
self.setup_zookeeper()

if TRAVIS_ZK_VERSION:
version = TRAVIS_ZK_VERSION
if CI_ZK_VERSION:
version = CI_ZK_VERSION
else:
version = self.client.server_version()
if not version or version < (3, 4):
Expand Down Expand Up @@ -71,8 +71,8 @@ def setUp(self):
os.environ["ZOOKEEPER_JAAS_AUTH"] = "digest"
self.setup_zookeeper()

if TRAVIS_ZK_VERSION:
version = TRAVIS_ZK_VERSION
if CI_ZK_VERSION:
version = CI_ZK_VERSION
else:
version = self.client.server_version()
if not version or version < (3, 4):
Expand Down Expand Up @@ -136,8 +136,8 @@ def setUp(self):
os.environ["ZOOKEEPER_JAAS_AUTH"] = "gssapi"
self.setup_zookeeper()

if TRAVIS_ZK_VERSION:
version = TRAVIS_ZK_VERSION
if CI_ZK_VERSION:
version = CI_ZK_VERSION
else:
version = self.client.server_version()
if not version or version < (3, 4):
Expand Down
12 changes: 6 additions & 6 deletions kazoo/tests/util.py
Expand Up @@ -16,13 +16,13 @@
import os
import time

TRAVIS = os.environ.get('TRAVIS', False)
TRAVIS_ZK_VERSION = TRAVIS and os.environ.get('ZOOKEEPER_VERSION', None)
if TRAVIS_ZK_VERSION:
if '-' in TRAVIS_ZK_VERSION:
CI = os.environ.get('CI', False)
CI_ZK_VERSION = CI and os.environ.get('ZOOKEEPER_VERSION', None)
if CI_ZK_VERSION:
if '-' in CI_ZK_VERSION:
# Ignore pre-release markers like -alpha
TRAVIS_ZK_VERSION = TRAVIS_ZK_VERSION.split('-')[0]
TRAVIS_ZK_VERSION = tuple([int(n) for n in TRAVIS_ZK_VERSION.split('.')])
CI_ZK_VERSION = CI_ZK_VERSION.split('-')[0]
CI_ZK_VERSION = tuple([int(n) for n in CI_ZK_VERSION.split('.')])


class Handler(logging.Handler):
Expand Down
7 changes: 3 additions & 4 deletions tox.ini
@@ -1,9 +1,9 @@
[tox]
minversion = 3.6
minversion = 3.7
skipsdist = True
envlist =
pep8,
{py27,py34,py35,py36,py37,py38,pypy3}
{py37,py38,py39,pypy3}
{gevent,eventlet,sasl,docs},
pypy3

Expand All @@ -13,8 +13,7 @@ install_command = pip install {opts} {packages}
passenv =
CI
TOX_*
TRAVIS
TRAVIS_*
CI_*
ZOOKEEPER_*
setenv =
VIRTUAL_ENV={envdir}
Expand Down

0 comments on commit 8eb462f

Please sign in to comment.