Added some missing CI integration pieces

matrix
Guillermo Rodriguez 2020-09-02 11:56:39 -03:00
parent 4d7a16b304
commit 03e5852acf
No known key found for this signature in database
GPG Key ID: 3F61096EC7DF75A8
3 changed files with 30 additions and 12 deletions

View File

@ -12,7 +12,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2
with:
python: '3.8'
python-version: '3.8'
- name: Install dependencies
run: pip install -U . --upgrade-strategy eager
- name: Run MyPy check

View File

@ -8,6 +8,9 @@ import random
import signal
import platform
import time
import enum
from typing import Optional
import pytest
import tractor
@ -74,11 +77,21 @@ def spawn_backend(request):
return request.config.option.spawn_backend
class CIEnvoirment(enum.Enum):
Travis = 'TRAVIS'
Github = 'GITHUB'
@pytest.fixture(scope='session')
def travis():
"""Bool determining whether running inside TravisCI.
def ci_env() -> Optional[CIEnvoirment]:
"""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')

View File

@ -9,6 +9,8 @@ import trio
import tractor
import pytest
from conftest import CIEnvoirment
def test_must_define_ctx():
@ -202,12 +204,15 @@ async def cancel_after(wait):
@pytest.fixture(scope='module')
def time_quad_ex(arb_addr, travis, spawn_backend):
if travis and spawn_backend == 'mp' and (platform.system() != 'Windows'):
# no idea, but the travis, mp, linux runs are flaking out here often
pytest.skip("Test is too flaky on mp in CI")
def time_quad_ex(arb_addr, ci_env, spawn_backend):
if ci_env in (CIEnvoirment.Github, CIEnvoirment.Travis):
if spawn_backend == 'mp' and (platform.system() != 'Windows'):
"""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()
results = tractor.run(cancel_after, timeout, arbiter_addr=arb_addr)
diff = time.time() - start
@ -215,12 +220,12 @@ def time_quad_ex(arb_addr, travis, spawn_backend):
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"."""
results, diff = time_quad_ex
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
@ -229,7 +234,7 @@ def test_a_quadruple_example(time_quad_ex, travis, spawn_backend):
list(map(lambda i: i/10, range(3, 9)))
)
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
cancel gracefully.