Skip to content

Commit

Permalink
ci: update GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Sep 18, 2019
1 parent 8b1e5df commit 78d8420
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 110 deletions.
9 changes: 0 additions & 9 deletions .github/actions/lint/lint.sh

This file was deleted.

33 changes: 0 additions & 33 deletions .github/actions/test/test.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .github/actions/test35/Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions .github/actions/test36/Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions .github/actions/test37/Dockerfile

This file was deleted.

78 changes: 45 additions & 33 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
on: push
name: Lint and Test
jobs:
test37:
name: test37
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Test 3.7
uses: ./.github/actions/test37
with:
entrypoint: /github/workspace/.github/actions/test/test.sh
test36:
name: test36
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Test 3.6
uses: ./.github/actions/test36
with:
entrypoint: /github/workspace/.github/actions/test/test.sh
test35:
name: test35
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Test 3.5
uses: ./.github/actions/test35
with:
entrypoint: /github/workspace/.github/actions/test/test.sh
lint:
runs-on: ubuntu-18.04
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Lint
uses: docker://python:3.7-slim
with:
entrypoint: /github/workspace/.github/actions/lint/lint.sh
- uses: actions/checkout@master
- uses: actions/setup-python@v1
with:
python-version: "3.7"
- run: pip install tox
- run: tox -e lint

build:
strategy:
matrix:
os: ["ubuntu-18.04"]
python: ["3.5", "3.6", "3.7"]

runs-on: ${{ matrix.os }}
name: test on ${{ matrix.python }} (${{ matrix.os }})

services:
memcached:
image: memcached:latest
ports:
- 11211:11211
rabbitmq:
image: bitnami/rabbitmq:latest
env:
RABBITMQ_USERNAME: "dramatiq"
RABBITMQ_PASSWORD: "dramatiq"
ports:
- 5672:5672
options: '--hostname "rmq" --health-cmd "rabbitmqctl status" --health-interval 10s --health-timeout 10s --health-retries 3 --health-start-period 60s'
redis:
image: redis:latest
ports:
- 6379:6379

steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- run: pip install -e '.[dev]'
- run: py.test --benchmark-skip
env:
RABBITMQ_USERNAME: "dramatiq"
RABBITMQ_PASSWORD: "dramatiq"
10 changes: 5 additions & 5 deletions tests/benchmarks/test_rabbitmq_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import dramatiq
from dramatiq.brokers.rabbitmq import RabbitmqBroker

from ..common import skip_on_travis
from ..common import RABBITMQ_CREDENTIALS

broker = RabbitmqBroker(host="127.0.0.1")
broker = RabbitmqBroker(
host="127.0.0.1",
credentials=RABBITMQ_CREDENTIALS,
)


@dramatiq.actor(queue_name="benchmark-throughput", broker=broker)
Expand Down Expand Up @@ -41,7 +44,6 @@ def latency():
time.sleep(duration)


@skip_on_travis
@pytest.mark.benchmark(group="rabbitmq-100k-throughput")
def test_rabbitmq_process_100k_messages_with_cli(benchmark, info_logging, start_cli):
# Given that I've loaded 100k messages into RabbitMQ
Expand All @@ -61,7 +63,6 @@ def setup():
benchmark.pedantic(broker.join, args=(throughput.queue_name,), setup=setup)


@skip_on_travis
@pytest.mark.benchmark(group="rabbitmq-10k-fib")
def test_rabbitmq_process_10k_fib_with_cli(benchmark, info_logging, start_cli):
# Given that I've loaded 10k messages into RabbitMQ
Expand All @@ -81,7 +82,6 @@ def setup():
benchmark.pedantic(broker.join, args=(fib.queue_name,), setup=setup)


@skip_on_travis
@pytest.mark.benchmark(group="rabbitmq-1k-latency")
def test_rabbitmq_process_1k_latency_with_cli(benchmark, info_logging, start_cli):
# Given that I've loaded 1k messages into RabbitMQ
Expand Down
5 changes: 0 additions & 5 deletions tests/benchmarks/test_redis_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import dramatiq
from dramatiq.brokers.redis import RedisBroker

from ..common import skip_on_travis

broker = RedisBroker()


Expand Down Expand Up @@ -41,7 +39,6 @@ def latency():
time.sleep(duration)


@skip_on_travis
@pytest.mark.benchmark(group="redis-100k-throughput")
def test_redis_process_100k_messages_with_cli(benchmark, info_logging, start_cli):
# Given that I've loaded 100k messages into Redis
Expand All @@ -55,7 +52,6 @@ def setup():
benchmark.pedantic(broker.join, args=(throughput.queue_name,), setup=setup)


@skip_on_travis
@pytest.mark.benchmark(group="redis-10k-fib")
def test_redis_process_10k_fib_with_cli(benchmark, info_logging, start_cli):
# Given that I've loaded 1k messages into Redis
Expand All @@ -69,7 +65,6 @@ def setup():
benchmark.pedantic(broker.join, args=(fib.queue_name,), setup=setup)


@skip_on_travis
@pytest.mark.benchmark(group="redis-1k-latency")
def test_redis_process_1k_latency_with_cli(benchmark, info_logging, start_cli):
# Given that I've loaded 1k messages into Redis
Expand Down
6 changes: 5 additions & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import platform
from contextlib import contextmanager

import pika
import pytest

from dramatiq import Worker
Expand All @@ -17,6 +18,9 @@ def worker(*args, **kwargs):
worker.stop()


skip_on_travis = pytest.mark.skipif(os.getenv("TRAVIS") == "1", reason="test skipped on Travis")
skip_on_windows = pytest.mark.skipif(platform.system() == "Windows", reason="test skipped on Windows")
skip_on_pypy = pytest.mark.skipif(platform.python_implementation() == "PyPy", reason="Time limits are not supported under PyPy.")

RABBITMQ_USERNAME = os.getenv("RABBITMQ_USERNAME", "guest")
RABBITMQ_PASSWORD = os.getenv("RABBITMQ_PASSWORD", "guest")
RABBITMQ_CREDENTIALS = pika.credentials.PlainCredentials(RABBITMQ_USERNAME, RABBITMQ_PASSWORD)
9 changes: 7 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
from dramatiq.rate_limits import backends as rl_backends
from dramatiq.results import backends as res_backends

from .common import RABBITMQ_CREDENTIALS

logfmt = "[%(asctime)s] [%(threadName)s] [%(name)s] [%(levelname)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=logfmt)
logging.getLogger("pika").setLevel(logging.WARN)

random.seed(1337)

CI = os.getenv("GITHUB_ACTION") or \
os.getenv("TRAVIS") == "true" or \
os.getenv("APPVEYOR") == "true"


Expand Down Expand Up @@ -60,7 +61,11 @@ def stub_broker():

@pytest.fixture()
def rabbitmq_broker():
broker = RabbitmqBroker(host="127.0.0.1", max_priority=10)
broker = RabbitmqBroker(
host="127.0.0.1",
max_priority=10,
credentials=RABBITMQ_CREDENTIALS,
)
check_rabbitmq(broker)
broker.emit_after("process_boot")
dramatiq.set_broker(broker)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dramatiq.brokers.rabbitmq import RabbitmqBroker
from dramatiq.middleware import Middleware

from .common import skip_on_windows
from .common import RABBITMQ_CREDENTIALS, skip_on_windows


class EmptyMiddleware(Middleware):
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_broker_middleware_cannot_be_addwed_both_before_and_after(stub_broker):
def test_can_instantiate_brokers_without_middleware():
# Given that I have an empty list of middleware
# When I pass that to the RMQ Broker
broker = RabbitmqBroker(middleware=[])
broker = RabbitmqBroker(middleware=[], credentials=RABBITMQ_CREDENTIALS)

# Then I should get back a broker with not middleware
# Then I should get back a broker with no middleware
assert not broker.middleware
12 changes: 7 additions & 5 deletions tests/test_rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
from dramatiq.brokers.rabbitmq import RabbitmqBroker, URLRabbitmqBroker, _IgnoreScaryLogs
from dramatiq.common import current_millis

from .common import RABBITMQ_CREDENTIALS, RABBITMQ_PASSWORD, RABBITMQ_USERNAME


def test_urlrabbitmq_creates_instances_of_rabbitmq_broker():
# Given a URL connection string
url = "amqp://127.0.0.1:5672"
url = "amqp://%s:%s@127.0.0.1:5672" % (RABBITMQ_USERNAME, RABBITMQ_PASSWORD)

# When I pass that to URLRabbitmqBroker
broker = URLRabbitmqBroker(url)
Expand All @@ -27,7 +29,7 @@ def test_rabbitmq_broker_can_be_passed_a_semicolon_separated_list_of_uris():
# Given a string with a list of RabbitMQ connection URIs, including an invalid one
# When I pass those URIs to RabbitMQ broker as a ;-separated string
broker = RabbitmqBroker(
url="amqp://127.0.0.1:55672;amqp://127.0.0.1")
url="amqp://127.0.0.1:55672;amqp://%s:%s@127.0.0.1" % (RABBITMQ_USERNAME, RABBITMQ_PASSWORD))

# The the broker should connect to the host that is up
assert broker.connection
Expand All @@ -37,7 +39,7 @@ def test_rabbitmq_broker_can_be_passed_a_list_of_uri_for_failover():
# Given a string with a list of RabbitMQ connection URIs, including an invalid one
# When I pass those URIs to RabbitMQ broker as a list
broker = RabbitmqBroker(
url=["amqp://127.0.0.1:55672", "amqp://127.0.0.1"])
url=["amqp://127.0.0.1:55672", "amqp://%s:%s@127.0.0.1" % (RABBITMQ_USERNAME, RABBITMQ_PASSWORD)])

# The the broker should connect to the host that is up
assert broker.connection
Expand All @@ -48,7 +50,7 @@ def test_rabbitmq_broker_raises_an_error_if_given_invalid_parameter_combinations
# When I try to give it both a connection URL and a list of connection parameters
# Then a RuntimeError should be raised
with pytest.raises(RuntimeError):
RabbitmqBroker(url="amqp://127.0.0.1:5672", parameters=[dict(host="127.0.0.1")])
RabbitmqBroker(url="amqp://127.0.0.1:5672", parameters=[dict(host="127.0.0.1", credentials=RABBITMQ_CREDENTIALS)])

# When I try to give it both a connection URL and pika connection parameters
# Then a RuntimeError should be raised
Expand All @@ -65,7 +67,7 @@ def test_rabbitmq_broker_can_be_passed_a_list_of_parameters_for_failover():
# Given a list of pika connection parameters including an invalid one
parameters = [
dict(host="127.0.0.1", port=55672), # this will fail
dict(host="127.0.0.1"),
dict(host="127.0.0.1", credentials=RABBITMQ_CREDENTIALS),
]

# When I pass those parameters to RabbitmqBroker
Expand Down
3 changes: 1 addition & 2 deletions tests/test_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dramatiq.brokers.redis import RedisBroker
from dramatiq.common import current_millis

from .common import skip_on_pypy, skip_on_travis, skip_on_windows
from .common import skip_on_pypy, skip_on_windows

broker = RedisBroker()
loaded_at = current_millis()
Expand All @@ -19,7 +19,6 @@ def write_loaded_at(filename):
f.write(str(loaded_at))


@skip_on_travis
@skip_on_windows
@skip_on_pypy
@pytest.mark.parametrize("extra_args", [
Expand Down

0 comments on commit 78d8420

Please sign in to comment.