Migrate to Github Action CI (#507)

* Some small refactors

* Initial test script

* Fixes django matrix

* Trying to set up Disque

* Disque as a docker service

* lowercase action name

* Remove Travis

* Replaces Travis badge with Github actions badge

* Show django version in step

* Typo
This commit is contained in:
Ilan Steemers
2021-02-14 18:59:04 +01:00
committed by GitHub
parent e2580051bc
commit 7d03536e89
12 changed files with 78 additions and 75 deletions
+1 -2
View File
@@ -4,7 +4,6 @@ from botocore.client import ClientError
from django_q.brokers import Broker
from django_q.conf import Conf
QUEUE_DOES_NOT_EXIST = "AWS.SimpleQueueService.NonExistentQueue"
@@ -77,7 +76,7 @@ class Sqs(Broker):
# exist try to create it.
return self.sqs.get_queue_by_name(QueueName=self.list_key)
except ClientError as exp:
if not exp.response["Error"]["Code"] == QUEUE_DOES_NOT_EXIST:
if exp.response["Error"]["Code"] != QUEUE_DOES_NOT_EXIST:
raise exp
return self.sqs.create_queue(QueueName=self.list_key)
+6 -5
View File
@@ -595,7 +595,7 @@ def scheduler(broker: Broker = None):
if s.hook:
q_options["hook"] = s.hook
# set up the next run time
if not s.schedule_type == s.ONCE:
if s.schedule_type != s.ONCE:
next_run = arrow.get(s.next_run)
while True:
if s.schedule_type == s.MINUTES:
@@ -722,8 +722,9 @@ def set_cpu_affinity(n: int, process_ids: list, actual: bool = not Conf.TESTING)
def rss_check():
if Conf.MAX_RSS and resource:
return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss >= Conf.MAX_RSS
elif Conf.MAX_RSS and psutil:
return psutil.Process().memory_info().rss >= Conf.MAX_RSS * 1024
if Conf.MAX_RSS:
if resource:
return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss >= Conf.MAX_RSS
elif psutil:
return psutil.Process().memory_info().rss >= Conf.MAX_RSS * 1024
return False
+1 -1
View File
@@ -196,7 +196,7 @@ def info(broker=None):
tasks_per_day = last_tasks.count()
if tasks_per_day > 0:
# average execution time over the last 24 hours
if not connection.vendor == "sqlite":
if connection.vendor != "sqlite":
exec_time = last_tasks.aggregate(
time_taken=Sum(F("stopped") - F("started"))
)
+1 -2
View File
@@ -260,7 +260,7 @@ def fetch_cached(task_id, wait=0, broker=None):
r = broker.cache.get(f"{broker.list_key}:{task_id}")
if r:
task = SignedPackage.loads(r)
t = Task(
return Task(
id=task["id"],
name=task["name"],
func=task["func"],
@@ -272,7 +272,6 @@ def fetch_cached(task_id, wait=0, broker=None):
result=task["result"],
success=task["success"],
)
return t
if (time() - start) * 1000 >= wait >= 0:
break
sleep(0.01)
+6 -8
View File
@@ -95,7 +95,7 @@ def test_disque(monkeypatch):
task_id = broker.enqueue("test")
broker.fail(task_id)
# bulk test
for i in range(5):
for _ in range(5):
broker.enqueue("test")
monkeypatch.setattr(Conf, "BULK", 5)
monkeypatch.setattr(Conf, "DISQUE_FASTACK", True)
@@ -166,7 +166,7 @@ def test_ironmq(monkeypatch):
task_id = broker.enqueue("test")
broker.fail(task_id)
# bulk test
for i in range(5):
for _ in range(5):
broker.enqueue("test")
monkeypatch.setattr(Conf, "BULK", 5)
tasks = broker.dequeue()
@@ -236,7 +236,7 @@ def canceled_sqs(monkeypatch):
task = broker.dequeue()[0]
broker.fail(task[0])
# bulk test
for i in range(10):
for _ in range(10):
broker.enqueue("test")
monkeypatch.setattr(Conf, "BULK", 12)
tasks = broker.dequeue()
@@ -290,7 +290,7 @@ def test_orm(monkeypatch):
task_id = broker.enqueue("test")
broker.fail(task_id)
# bulk test
for i in range(5):
for _ in range(5):
broker.enqueue("test")
monkeypatch.setattr(Conf, "BULK", 5)
tasks = broker.dequeue()
@@ -347,11 +347,9 @@ def test_mongo(monkeypatch):
task_id = broker.enqueue("test")
broker.fail(task_id)
# bulk test
for i in range(5):
for _ in range(5):
broker.enqueue("test")
tasks = []
for i in range(5):
tasks.append(broker.dequeue()[0])
tasks = [broker.dequeue()[0] for _ in range(5)]
assert broker.lock_size() == 5
for task in tasks:
assert task is not None
+4 -4
View File
@@ -152,9 +152,9 @@ def test_asynctask_class(broker, monkeypatch):
a.args = (1, -1)
assert a.started is False
a.cached = True
assert a.cached is True
assert a.cached
a.sync = True
assert a.sync is True
assert a.sync
a.broker = broker
assert a.broker == broker
a.run()
@@ -166,7 +166,7 @@ def test_asynctask_class(broker, monkeypatch):
assert a.result() == -1
# with q_options
a = AsyncTask('math.copysign', 1, -1, q_options={'cached': True, 'sync': False, 'broker': broker})
assert a.sync is False
assert not a.sync
a.sync = True
assert a.kwargs['q_options']['sync'] is True
a.run()
@@ -174,7 +174,7 @@ def test_asynctask_class(broker, monkeypatch):
a.group = 'async_class_test'
assert a.group == 'async_class_test'
a.save = False
assert a.save is False
assert not a.save
a.hook = 'djq.tests.tasks.hello'
assert a.hook == 'djq.tests.tasks.hello'
assert a.started is False
+1 -1
View File
@@ -162,7 +162,7 @@ def test_enqueue(broker, admin_user):
stop_event = Event()
stop_event.set()
# push the tasks
for i in range(task_count):
for _ in range(task_count):
pusher(task_queue, stop_event, broker=broker)
assert broker.queue_size() == 0
assert task_queue.qsize() == task_count
+1 -1
View File
@@ -26,7 +26,7 @@ def test_monitor(monkeypatch):
assert stat.uptime() > 0
assert stat.empty_queues() is True
break
assert found_c is True
assert found_c
# test lock size
monkeypatch.setattr(Conf, 'ORM', 'default')
b = get_broker('monitor_test')