Skip to content

Commit

Permalink
Merge pull request #50 from dimagi/jls/tests-on-github-actions
Browse files Browse the repository at this point in the history
Move tests from travis to GitHub Actions, upgrade dependencies
  • Loading branch information
orangejenny authored Sep 17, 2024
2 parents acbf962 + 64f436f commit ad270e7
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 64 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see:
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: couchdb-cluster-admin tests

on:
push:
branches: [ master ]
pull_request:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10"] # dimagi-memoized does not yet support later versions of python

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r test-requirements.txt
- name: Make data directory if needed
run: |
mkdir -p /home/runner/work/couchdb-cluster-admin/couchdb-cluster-admin/data
- name: Set up docker clusters
run: |
docker build -t couchdb-cluster - < docker-couchdb-cluster/Dockerfile
docker run -d --name couchdb-cluster -v $(pwd)/data:/usr/src/couchdb/dev/lib/ -p 15984:15984 -p 15986:15986 -p 25984:25984 -p 25986:25986 -p 35984:35984 -p 35986:35986 -p 45984:45984 -p 45986:45986 -t couchdb-cluster --with-admin-party-please -n 4
- name: Run tests
run: |
pytest tests.py
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ ENV/

# IDE config
.idea

*.swp
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion couchdb_cluster_admin/describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
get_shard_allocation,
indent,
)
from six.moves import map


def print_shard_table(shard_allocation_docs):
Expand Down
16 changes: 7 additions & 9 deletions couchdb_cluster_admin/doc_models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import absolute_import
from collections import defaultdict
from jsonobject import JsonObject, ListProperty, DictProperty, StringProperty, IntegerProperty
from six.moves import map
import six


class ConfigInjectionMixin(object):
Expand All @@ -22,8 +20,8 @@ def set_config(self, config):
class MembershipDoc(ConfigInjectionMixin, JsonObject):
_allow_dynamic_properties = False

cluster_nodes = ListProperty(six.text_type, required=True)
all_nodes = ListProperty(six.text_type, required=True)
cluster_nodes = ListProperty(str, required=True)
all_nodes = ListProperty(str, required=True)

def get_printable(self):
return (
Expand All @@ -41,10 +39,10 @@ class ShardAllocationDoc(ConfigInjectionMixin, JsonObject):
_id = StringProperty()
_rev = StringProperty(exclude_if_none=True)

by_node = DictProperty(ListProperty(six.text_type))
changelog = ListProperty(ListProperty(six.text_type))
by_node = DictProperty(ListProperty(str))
changelog = ListProperty(ListProperty(str))
shard_suffix = ListProperty(int)
by_range = DictProperty(ListProperty(six.text_type))
by_range = DictProperty(ListProperty(str))

@property
def usable_shard_suffix(self):
Expand Down Expand Up @@ -126,6 +124,6 @@ def get_printable(self, include_shard_names=True, db_name_len=20):


class AllocationSpec(JsonObject):
databases = ListProperty(six.text_type)
nodes = ListProperty(six.text_type)
databases = ListProperty(str)
nodes = ListProperty(str)
copies = IntegerProperty()
1 change: 0 additions & 1 deletion couchdb_cluster_admin/suggest_shard_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .describe import print_shard_table
from .file_plan import read_plan_file
from .doc_models import ShardAllocationDoc, AllocationSpec
from six.moves import range


class _NodeAllocation(object):
Expand Down
5 changes: 1 addition & 4 deletions couchdb_cluster_admin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from requests import HTTPError

from .doc_models import MembershipDoc, ShardAllocationDoc
import six
from six.moves import range
from six.moves import input

NodeDetails = namedtuple('NodeDetails', 'ip port node_local_port couchdb_version username password socks_port')

Expand Down Expand Up @@ -133,7 +130,7 @@ class Config(JsonObject):
control_node_local_port = IntegerProperty()
couchdb_version = StringProperty()
username = StringProperty()
aliases = DictProperty(six.text_type)
aliases = DictProperty(str)

def set_password(self, password):
self._password = password
Expand Down
10 changes: 4 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@ charset-normalizer==2.0.12
# via requests
dimagi-memoized==1.1.1
# via couchdb-cluster-admin (setup.py)
gevent==1.4.0
gevent==24.2.1
# via couchdb-cluster-admin (setup.py)
greenlet==0.4.15
greenlet==3.1.0
# via gevent
idna==2.8
# via requests
jsonobject==2.0.0
jsonobject==2.2.0
# via couchdb-cluster-admin (setup.py)
pyyaml==5.4.1
pyyaml==6.0.2
# via couchdb-cluster-admin (setup.py)
requests==2.27.1
# via couchdb-cluster-admin (setup.py)
six==1.12.0
# via jsonobject
urllib3==1.26.5
# via requests

0 comments on commit ad270e7

Please sign in to comment.