Skip to content

Commit 094efe7

Browse files
committed
Use public httpbin for mac runner in github actions.
1 parent 963fb98 commit 094efe7

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

.github/workflows/ci.yml

-8
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,6 @@ jobs:
139139
node-version: ${{ matrix.node-version }}
140140
- name: Install build tools
141141
run: python3 -m pip install --upgrade pip setuptools wheel tox~=3.0
142-
- name: Install and Start Colima
143-
run: |
144-
if [[ "${{ matrix.os }}" == *"macos"* ]]
145-
then
146-
brew install docker docker-compose
147-
colima start
148-
fi
149-
shell: bash
150142
- name: Install mbtest ${{ matrix.mbtest-version }}
151143
env:
152144
MBTEST_VERSION: ${{ matrix.mbtest-version }}

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"pyhamcrest>=2.0",
2525
"Deprecated>=1.2",
2626
"brunns-matchers>=2.4",
27-
"imurl>=0.2",
27+
"yarl>=1.9",
2828
]
2929
test_dependencies = [
3030
"pytest>=6.0",

tests/integration/conftest.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# encoding=utf-8
2-
import sys
2+
import os
3+
import platform
34

45
import pytest
5-
from imurl.url import URL
6+
from yarl import URL
67

78
from mbtest import server
89

9-
WINDOWS = sys.platform.startswith("win")
10+
LOCAL = os.getenv("GITHUB_ACTIONS") != "true"
11+
LINUX = platform.system() == "Linux"
12+
HTTPBIN_CONTAINERISED = LINUX or LOCAL
1013

1114

1215
@pytest.fixture(scope="session")
@@ -16,10 +19,9 @@ def mock_server(request):
1619

1720
@pytest.fixture(scope="session")
1821
def httpbin(docker_ip, docker_services) -> URL:
19-
if WINDOWS:
20-
# We can't run docker inside a Windows VM in GitHub Actions, so run tests against the public instance.
21-
return URL("https://httpbin.org")
22-
else:
22+
if HTTPBIN_CONTAINERISED:
2323
docker_services.start("httpbin")
2424
port = docker_services.wait_for_service("httpbin", 80)
2525
return URL(f"http://{docker_ip}:{port}")
26+
else:
27+
return URL("https://httpbin.org")

tests/integration/test_proxy.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# encoding=utf-8
22
import logging
3+
import os
34
import platform
45

56
import pytest
@@ -19,9 +20,12 @@
1920
logger = logging.getLogger(__name__)
2021

2122
INTERNET_CONNECTED = internet_connection()
23+
LOCAL = os.getenv("GITHUB_ACTIONS") != "true"
24+
LINUX = platform.system() == "Linux"
25+
HTTPBIN_CONTAINERISED = LINUX or LOCAL
2226

2327

24-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
28+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
2529
def test_proxy(mock_server, httpbin):
2630
imposter = Imposter(Stub(responses=Proxy(to=httpbin)))
2731

@@ -34,7 +38,7 @@ def test_proxy(mock_server, httpbin):
3438
assert_that(imposter, had_request().with_path("/").and_method("GET"))
3539

3640

37-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
41+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
3842
def test_stub_with_proxy_fallback(mock_server, httpbin):
3943
imposter = Imposter(
4044
stubs=[
@@ -54,7 +58,7 @@ def test_stub_with_proxy_fallback(mock_server, httpbin):
5458
assert_that(imposter, had_request().with_path("/").and_method("GET"))
5559

5660

57-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
61+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
5862
def test_proxy_playback(mock_server, httpbin):
5963
proxy_imposter = Imposter(Stub(responses=Proxy(to=httpbin, mode=Proxy.Mode.ONCE)))
6064

@@ -78,7 +82,7 @@ def test_proxy_playback(mock_server, httpbin):
7882
)
7983

8084

81-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
85+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
8286
def test_proxy_uses_path_predicate_generator(mock_server, httpbin):
8387
proxy_imposter = Imposter(
8488
Stub(
@@ -110,7 +114,7 @@ def test_proxy_uses_path_predicate_generator(mock_server, httpbin):
110114
assert_that(response, is_response().with_status_code(200))
111115

112116

113-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
117+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
114118
def test_proxy_uses_query_predicate_generator(mock_server, httpbin):
115119
proxy_imposter = Imposter(
116120
Stub(
@@ -150,7 +154,7 @@ def test_proxy_uses_query_predicate_generator(mock_server, httpbin):
150154
)
151155

152156

153-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
157+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
154158
def test_proxy_uses_query_predicate_generator_with_key(mock_server, httpbin):
155159
proxy_imposter = Imposter(
156160
Stub(
@@ -200,7 +204,7 @@ def test_proxy_uses_query_predicate_generator_with_key(mock_server, httpbin):
200204
)
201205

202206

203-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
207+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
204208
def test_proxy_without_stub(mock_server, httpbin):
205209
imposter = Imposter(Stub(responses=Proxy(to=httpbin)))
206210

@@ -212,7 +216,7 @@ def test_proxy_without_stub(mock_server, httpbin):
212216
)
213217

214218

215-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
219+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
216220
def test_proxy_delay(mock_server):
217221
target_imposter = Imposter(Stub(Predicate(path="/test")))
218222
with mock_server(target_imposter) as server:
@@ -225,7 +229,7 @@ def test_proxy_delay(mock_server):
225229
assert_that(timer.elapsed, between(0.1, 0.5))
226230

227231

228-
@pytest.mark.xfail(platform.system() == "Windows", reason="Public httpbin horribly flaky.")
232+
@pytest.mark.xfail(not HTTPBIN_CONTAINERISED, reason="Public httpbin horribly flaky.")
229233
def test_inject_headers(mock_server):
230234
target_imposter = Imposter(Stub(Predicate(path="/test")))
231235
with mock_server(target_imposter) as server:

tox.ini

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ allowlist_externals =
1212
extras =
1313
test
1414
commands =
15-
{posargs:py.test} tests/unit/ tests/integration/
16-
passenv = *
15+
{posargs:py.test} tests/unit/ tests/integration/ -o log_cli=true --keepalive
16+
passenv =
17+
GITHUB_*
18+
MBTEST_*
1719
usedevelop=True
1820

1921
[testenv:coverage]

0 commit comments

Comments
 (0)