Merge pull request #152 from guilledk/gh_actions

Add Github Actions CI support
matrix
goodboy 2020-09-03 12:22:27 -04:00 committed by GitHub
commit 196cf14211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 13 deletions

41
.github/workflows/ci.yml vendored 100644
View File

@ -0,0 +1,41 @@
name: CI
on: push
jobs:
mypy:
name: 'MyPy'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: pip install -U . --upgrade-strategy eager
- name: Run MyPy check
run: mypy tractor/ --ignore-missing-imports
testing:
name: '${{ matrix.os }} Python ${{ matrix.python }} - ${{ matrix.spawn_backend }}'
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python: ['3.7', '3.8']
spawn_backend: ['trio', 'mp']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.python }}'
- name: Install dependencies
run: pip install -U . -r requirements-test.txt -r requirements-docs.txt --upgrade-strategy eager
- name: Run tests
run: pytest tests/ --spawn-backend=${{ matrix.spawn_backend }}

View File

@ -75,10 +75,10 @@ def spawn_backend(request):
@pytest.fixture(scope='session') @pytest.fixture(scope='session')
def travis(): def ci_env() -> bool:
"""Bool determining whether running inside TravisCI. """Detect CI envoirment.
""" """
return os.environ.get('TRAVIS', False) return os.environ.get('TRAVIS', False) or os.environ.get('CI', False)
@pytest.fixture(scope='session') @pytest.fixture(scope='session')

View File

@ -202,12 +202,14 @@ 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 and spawn_backend == 'mp' and (platform.system() != 'Windows'):
# no idea, but the travis, mp, linux runs are flaking out here often """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") 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 +217,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 +231,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.
@ -237,10 +239,11 @@ def test_not_fast_enough_quad(
results, diff = time_quad_ex results, diff = time_quad_ex
delay = max(diff - cancel_delay, 0) delay = max(diff - cancel_delay, 0)
results = tractor.run(cancel_after, delay, arbiter_addr=arb_addr) results = tractor.run(cancel_after, delay, arbiter_addr=arb_addr)
if platform.system() == 'Windows' and results is not None: system = platform.system()
# In Windows CI it seems later runs are quicker then the first if system in ('Windows', 'Darwin') and results is not None:
# In CI envoirments it seems later runs are quicker then the first
# so just ignore these # so just ignore these
print("Woa there windows caught your breath eh?") print(f"Woa there {system} caught your breath eh?")
else: else:
# should be cancelled mid-streaming # should be cancelled mid-streaming
assert results is None assert results is None