Skip to content

Commit

Permalink
Merge pull request #55 from alisaifee/github-actions
Browse files Browse the repository at this point in the history
 Switch CI from travis to github actions
  • Loading branch information
alisaifee committed May 18, 2020
2 parents f15ae4e + c696917 commit c19be4b
Show file tree
Hide file tree
Showing 21 changed files with 208 additions and 4,904 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Expand Up @@ -4,7 +4,7 @@ include =
omit =
/*/limits/_version*
/*/limits/backports/*
/*/google-cloud-sdk/*
/*/google_appengine/*
/*/tests/*
setup.py
versioneer.py
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
@@ -0,0 +1,43 @@
name: CI

on:
push:
branches: [ '*' ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, pypy2, 3.5, 3.7, 3.8, pypy3]
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/**') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements/ci.txt
- name: Start services
run: |
make setup-test-backends
- name: Tests
run: |
nosetests tests --with-cov -v --with-timer --timer-top-n 10
- name: Coverage
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
coveralls
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -12,5 +12,5 @@ htmlcov
redis-git
.python-version
# gae test files
google-cloud-sdk/
google_appengine
google
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

57 changes: 57 additions & 0 deletions Makefile
@@ -0,0 +1,57 @@
SHELL = bash
ifneq ("$(wildcard ./google_appengine/VERSION)","")
GAE_INSTALLED = 1
else
GAE_INSTALLED = 0
endif

HOST_OS = $(shell uname -s)
ifeq ("$(HOST_OS)", "Darwin")
HOST_IP = $(shell ipconfig getifaddr en0)
OS_HACKS = osx-hacks
else
HOST_IP = $(shell hostname -I | awk '{print $$1}')
endif

PY_VERSION =$(shell python -c "import sys;print('.'.join(str(k) for k in sys.version_info[0:2]))")

redis-uds-start:
redis-server --port 0 --unixsocket /tmp/limits.redis.sock --daemonize yes --pidfile /tmp/redis_unix-domain-socket.pid

redis-uds-stop:
[ -e /tmp/redis_unix-domain-socket.pid ] && kill -9 `cat /tmp/redis_unix-domain-socket.pid` || true


memcached-uds-start:
memcached -d -s /tmp/limits.memcached.sock -P /tmp/limits.memcached.uds.pid

memcached-uds-stop:
[ -e /tmp/limits.memcached.uds.pid ] && kill `cat /tmp/limits.memcached.uds.pid` || true
rm -rf /tmp/limits.memcached.*.pid

memcached-gae-install:
ifeq ($(PY_VERSION),2.7)
ifeq ($(GAE_INSTALLED),0)
wget https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.91.zip -P /var/tmp/
rm -rf google_appengine
unzip -qu /var/tmp/google_appengine_1.9.91.zip -d .
else
echo "GAE SDK already setup"
endif
ln -sf google_appengine/google google
endif

docker-down:
docker-compose down --remove-orphans

docker-up: docker-down
HOST_OS=$(HOST_OS) HOST_IP=$(HOST_IP) docker-compose up -d
docker exec -i limits_redis-cluster-5_1 bash -c "echo yes | redis-cli --cluster create --cluster-replicas 1 $(HOST_IP):{7000..7005}"

osx-hacks: redis-uds-stop memcached-uds-stop redis-uds-start memcached-uds-start

setup-test-backends: $(OS_HACKS) memcached-gae-install docker-up

tests: setup-test-backends
nosetests tests --with-cov -v --with-timer --timer-top-n 10
.PHONY: test
112 changes: 0 additions & 112 deletions Makefile.tests

This file was deleted.

6 changes: 3 additions & 3 deletions README.rst
@@ -1,5 +1,5 @@
.. |travis-ci| image:: https://img.shields.io/travis/alisaifee/limits/master.svg?style=flat-square
:target: https://travis-ci.org/#!/alisaifee/limits?branch=master
.. |ci| image:: https://github.com/alisaifee/limits/workflows/CI/badge.svg?branch=master
:target: https://github.com/alisaifee/limits/actions?query=branch%3Amaster+workflow%3ACI
.. |coveralls| image:: https://img.shields.io/coveralls/alisaifee/limits/master.svg?style=flat-square
:target: https://coveralls.io/r/alisaifee/limits?branch=master
.. |pypi| image:: https://img.shields.io/pypi/v/limits.svg?style=flat-square
Expand All @@ -13,7 +13,7 @@
*************
limits
*************
|travis-ci| |coveralls| |pypi| |gitter| |license|
|ci| |coveralls| |pypi| |gitter| |license|

*limits* provides utilities to implement rate limiting using
various strategies and storage backends such as redis & memcached.
Expand Down
12 changes: 7 additions & 5 deletions doc/source/index.rst
Expand Up @@ -69,14 +69,16 @@ Clear a limit::
Development
-----------
Since `limits` integrates with various backend storages, local development and running tests
can require some setup. Basic `redis` & `memcached` installations are expected to be available in your environment.
If you are working with :ref:`redis-cluster`, :ref:`redis-sentinel` or :ref:`gae-memcached` you can use the makefile
``Makefile.tests`` to help with setting up development dependencies::
can require some setup.

make -f Makefile.tests redis-start memcached-gae-install
You can use the provided Makefile to set up all the backends. This will require a working
docker installation. Additionally on OSX you will require the ``memcached`` and
``redis-server`` executables to be on the path::

make setup-test-backends
# hack hack hack
# run tests
make -f Makefile.tests redis-stop
nosetests tests

Projects using *limits*
-------------------------
Expand Down
96 changes: 96 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,96 @@
version: '3.2'

services:
# memcached
memcached-1:
image: memcached
command: -p 22122
ports:
- 22122:22122
memcached-2:
image: memcached
command: -p 22123
ports:
- 22123:22123
memcached-uds:
image: memcached
command: sh -c "test ${HOST_OS} == \"Darwin\" && exit || memcached -s /sockets/limits.memcached.sock -a 777"
volumes:
- type: bind
source: /tmp/
target: /sockets/
# redis sentinel
redis-sentinel-master:
image: redis
command: redis-server --port 6380
ports:
- '6380:6380'
redis-sentinel-slave:
image: redis
depends_on: [redis-sentinel-master]
command: redis-server --port 6381 --slaveof ${HOST_IP} 6380 --slave-announce-ip ${HOST_IP}
ports:
- '6381:6381'
redis-sentinel:
image: 'bitnami/redis-sentinel:latest'
depends_on: [redis-sentinel-slave]
environment:
- REDIS_MASTER_SET=localhost-redis-sentinel
- REDIS_MASTER_HOST=${HOST_IP}
- REDIS_MASTER_PORT_NUMBER=6380
ports:
- '26379:26379'
# cluster
redis-cluster-0:
image: redis
command: redis-server --port 7000 --protected-mode no --cluster-enabled yes --loglevel verbose --cluster-announce-ip ${HOST_IP}
ports:
- '7000:7000'
- '17000:17000'
redis-cluster-1:
image: redis
command: redis-server --port 7001 --protected-mode no --cluster-enabled yes --loglevel verbose --cluster-announce-ip ${HOST_IP}
ports:
- '7001:7001'
- '17001:17001'
redis-cluster-2:
image: redis
command: redis-server --port 7002 --protected-mode no --cluster-enabled yes --loglevel verbose --cluster-announce-ip ${HOST_IP}
ports:
- '7002:7002'
- '17002:17002'
redis-cluster-3:
image: redis
command: redis-server --port 7003 --protected-mode no --cluster-enabled yes --loglevel verbose --cluster-announce-ip ${HOST_IP}
ports:
- '7003:7003'
- '17003:17003'
redis-cluster-4:
image: redis
command: redis-server --port 7004 --protected-mode no --cluster-enabled yes --loglevel verbose --cluster-announce-ip ${HOST_IP}
ports:
- '7004:7004'
- '17004:17004'
redis-cluster-5:
image: redis
command: redis-server --port 7005 --protected-mode no --cluster-enabled yes --loglevel verbose --cluster-announce-ip ${HOST_IP}
ports:
- '7005:7005'
- '17005:17005'
redis-basic:
image: redis
command: redis-server --port 7379
ports:
- '7379:7379'
redis-auth:
image: redis
command: redis-server --port 7389 --requirepass sekret
ports:
- '7389:7389'
redis-uds:
image: redis
command: sh -c "test ${HOST_OS} = \"Darwin\" && exit || redis-server --port 0 --unixsocket /sockets/limits.redis.sock --unixsocketperm 777"
volumes:
- type: bind
source: /tmp/
target: /sockets/

0 comments on commit c19be4b

Please sign in to comment.