From 865e9321079070b3a1350a492020ac68f63ba29f Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 2 Sep 2020 11:12:08 -0300 Subject: [PATCH 1/8] Initial commit --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..292efd6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: push + +jobs: + mypy: + name: 'MyPy' + timeout-minutes: 20 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python: '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 }}' + timeout-minutes: 20 + 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 }} --disable-vnet \ No newline at end of file From 3595317b007ab40426844aae3bbe6d6e8e032467 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 2 Sep 2020 11:16:05 -0300 Subject: [PATCH 2/8] Removed --disable-vnet parameter to pytest that was left after experimenting with this file in the multihost testing branch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 292efd6..116bff8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,4 +39,4 @@ jobs: - 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 }} --disable-vnet \ No newline at end of file + run: pytest tests/ --spawn-backend=${{ matrix.spawn_backend }} \ No newline at end of file From 406ded7311314cd21e13cfd406cfd97a256095cf Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 2 Sep 2020 11:18:12 -0300 Subject: [PATCH 3/8] Experimental mac testing --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 116bff8..a40fcb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macos-latest] python: ['3.7', '3.8'] spawn_backend: ['trio', 'mp'] steps: From 4d7a16b30419e4c274657d37db425310989cc464 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 2 Sep 2020 11:31:10 -0300 Subject: [PATCH 4/8] Lower timeout and added spawn_backend to name of jobs --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a40fcb6..afae0a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,6 @@ on: push jobs: mypy: name: 'MyPy' - timeout-minutes: 20 runs-on: ubuntu-latest steps: - name: Checkout @@ -20,8 +19,8 @@ jobs: run: mypy tractor/ --ignore-missing-imports testing: - name: '${{ matrix.os }} Python ${{ matrix.python }}' - timeout-minutes: 20 + name: '${{ matrix.os }} Python ${{ matrix.python }} - ${{ matrix.spawn_backend }}' + timeout-minutes: 10 runs-on: ${{ matrix.os }} strategy: fail-fast: false From 03e5852acf406488da0b34e9de4fe79d0c8dd9ae Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 2 Sep 2020 11:56:39 -0300 Subject: [PATCH 5/8] Added some missing CI integration pieces --- .github/workflows/ci.yml | 2 +- tests/conftest.py | 19 ++++++++++++++++--- tests/test_streaming.py | 21 +++++++++++++-------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afae0a5..cd06b9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index 24b0f92..a95165e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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') diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 00b07cb..243ac30 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -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. From c993e36e95f674fa9c851536d3824475c2c6dd01 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Thu, 3 Sep 2020 09:44:24 -0300 Subject: [PATCH 6/8] Simplified CI detection --- tests/conftest.py | 17 ++--------------- tests/test_streaming.py | 13 +++++-------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a95165e..6a9f938 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,9 +8,6 @@ import random import signal import platform import time -import enum - -from typing import Optional import pytest import tractor @@ -77,21 +74,11 @@ def spawn_backend(request): return request.config.option.spawn_backend -class CIEnvoirment(enum.Enum): - Travis = 'TRAVIS' - Github = 'GITHUB' - - @pytest.fixture(scope='session') -def ci_env() -> Optional[CIEnvoirment]: +def ci_env() -> bool: """Detect CI envoirment. """ - if os.environ.get('TRAVIS'): - return CIEnvoirment.Travis - elif os.environ.get('CI'): - return CIEnvoirment.Github - else: - return None + 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 243ac30..531352a 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -9,8 +9,6 @@ import trio import tractor import pytest -from conftest import CIEnvoirment - def test_must_define_ctx(): @@ -205,12 +203,11 @@ async def cancel_after(wait): @pytest.fixture(scope='module') 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") + 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() in ('Windows', 'Darwin') else 4 start = time.time() From ad68ff665f301b254014d8c8855d4d56e76a5306 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Thu, 3 Sep 2020 09:57:04 -0300 Subject: [PATCH 7/8] Missing a platform.system() check --- tests/test_streaming.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 531352a..8d06478 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -239,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: + system = platform.system() + if system in ('Windows', 'Darwin') and results is not None: # In Windows CI 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 From 5e3ce765dd6cb80881ee7234624c40d815ae6b49 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Thu, 3 Sep 2020 10:41:09 -0300 Subject: [PATCH 8/8] Drop mac support, will continue the experiment on another branch --- .github/workflows/ci.yml | 2 +- tests/test_streaming.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd06b9f..689e364 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest] python: ['3.7', '3.8'] spawn_backend: ['trio', 'mp'] steps: diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 8d06478..17ab9ea 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -241,7 +241,7 @@ def test_not_fast_enough_quad( results = tractor.run(cancel_after, delay, arbiter_addr=arb_addr) system = platform.system() if system in ('Windows', 'Darwin') and results is not None: - # In Windows CI it seems later runs are quicker then the first + # In CI envoirments it seems later runs are quicker then the first # so just ignore these print(f"Woa there {system} caught your breath eh?") else: