forked from goodboy/tractor
Added some missing CI integration pieces
parent
4d7a16b304
commit
03e5852acf
|
@ -12,7 +12,7 @@ jobs:
|
||||||
- name: Setup python
|
- name: Setup python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python: '3.8'
|
python-version: '3.8'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pip install -U . --upgrade-strategy eager
|
run: pip install -U . --upgrade-strategy eager
|
||||||
- name: Run MyPy check
|
- name: Run MyPy check
|
||||||
|
|
|
@ -8,6 +8,9 @@ import random
|
||||||
import signal
|
import signal
|
||||||
import platform
|
import platform
|
||||||
import time
|
import time
|
||||||
|
import enum
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import tractor
|
import tractor
|
||||||
|
@ -74,11 +77,21 @@ def spawn_backend(request):
|
||||||
return request.config.option.spawn_backend
|
return request.config.option.spawn_backend
|
||||||
|
|
||||||
|
|
||||||
|
class CIEnvoirment(enum.Enum):
|
||||||
|
Travis = 'TRAVIS'
|
||||||
|
Github = 'GITHUB'
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def travis():
|
def ci_env() -> Optional[CIEnvoirment]:
|
||||||
"""Bool determining whether running inside TravisCI.
|
"""Detect CI envoirment.
|
||||||
"""
|
"""
|
||||||
return os.environ.get('TRAVIS', False)
|
if os.environ.get('TRAVIS'):
|
||||||
|
return CIEnvoirment.Travis
|
||||||
|
elif os.environ.get('CI'):
|
||||||
|
return CIEnvoirment.Github
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
|
|
|
@ -9,6 +9,8 @@ import trio
|
||||||
import tractor
|
import tractor
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from conftest import CIEnvoirment
|
||||||
|
|
||||||
|
|
||||||
def test_must_define_ctx():
|
def test_must_define_ctx():
|
||||||
|
|
||||||
|
@ -202,12 +204,15 @@ async def cancel_after(wait):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module')
|
@pytest.fixture(scope='module')
|
||||||
def time_quad_ex(arb_addr, travis, spawn_backend):
|
def time_quad_ex(arb_addr, ci_env, spawn_backend):
|
||||||
if travis and spawn_backend == 'mp' and (platform.system() != 'Windows'):
|
if ci_env in (CIEnvoirment.Github, CIEnvoirment.Travis):
|
||||||
# no idea, but the travis, mp, linux runs are flaking out here often
|
if spawn_backend == 'mp' and (platform.system() != 'Windows'):
|
||||||
pytest.skip("Test is too flaky on mp in CI")
|
"""no idea, but the travis and github actions, mp *nix runs are
|
||||||
|
flaking out here often
|
||||||
|
"""
|
||||||
|
pytest.skip("Test is too flaky on mp in CI")
|
||||||
|
|
||||||
timeout = 7 if platform.system() == 'Windows' else 4
|
timeout = 7 if platform.system() in ('Windows', 'Darwin') else 4
|
||||||
start = time.time()
|
start = time.time()
|
||||||
results = tractor.run(cancel_after, timeout, arbiter_addr=arb_addr)
|
results = tractor.run(cancel_after, timeout, arbiter_addr=arb_addr)
|
||||||
diff = time.time() - start
|
diff = time.time() - start
|
||||||
|
@ -215,12 +220,12 @@ def time_quad_ex(arb_addr, travis, spawn_backend):
|
||||||
return results, diff
|
return results, diff
|
||||||
|
|
||||||
|
|
||||||
def test_a_quadruple_example(time_quad_ex, travis, spawn_backend):
|
def test_a_quadruple_example(time_quad_ex, ci_env, spawn_backend):
|
||||||
"""This also serves as a kind of "we'd like to be this fast test"."""
|
"""This also serves as a kind of "we'd like to be this fast test"."""
|
||||||
|
|
||||||
results, diff = time_quad_ex
|
results, diff = time_quad_ex
|
||||||
assert results
|
assert results
|
||||||
this_fast = 6 if platform.system() == 'Windows' else 2.5
|
this_fast = 6 if platform.system() in ('Windows', 'Darwin') else 2.5
|
||||||
assert diff < this_fast
|
assert diff < this_fast
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,7 +234,7 @@ def test_a_quadruple_example(time_quad_ex, travis, spawn_backend):
|
||||||
list(map(lambda i: i/10, range(3, 9)))
|
list(map(lambda i: i/10, range(3, 9)))
|
||||||
)
|
)
|
||||||
def test_not_fast_enough_quad(
|
def test_not_fast_enough_quad(
|
||||||
arb_addr, time_quad_ex, cancel_delay, travis, spawn_backend
|
arb_addr, time_quad_ex, cancel_delay, ci_env, spawn_backend
|
||||||
):
|
):
|
||||||
"""Verify we can cancel midway through the quad example and all actors
|
"""Verify we can cancel midway through the quad example and all actors
|
||||||
cancel gracefully.
|
cancel gracefully.
|
||||||
|
|
Loading…
Reference in New Issue