diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..689e364 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 }} \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 24b0f92..6a9f938 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -75,10 +75,10 @@ def spawn_backend(request): @pytest.fixture(scope='session') -def travis(): - """Bool determining whether running inside TravisCI. +def ci_env() -> bool: + """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') diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 00b07cb..17ab9ea 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -202,12 +202,14 @@ 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 +def time_quad_ex(arb_addr, ci_env, spawn_backend): + if ci_env and 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 +217,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 +231,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. @@ -237,10 +239,11 @@ def test_not_fast_enough_quad( results, diff = time_quad_ex delay = max(diff - cancel_delay, 0) results = tractor.run(cancel_after, delay, arbiter_addr=arb_addr) - if platform.system() == 'Windows' and results is not None: - # In Windows CI it seems later runs are quicker then the first + system = platform.system() + 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 - print("Woa there windows caught your breath eh?") + print(f"Woa there {system} caught your breath eh?") else: # should be cancelled mid-streaming assert results is None