Skip to content

Commit

Permalink
Use pytest-docker rather than lovely-pytest-docker since GHA is now o…
Browse files Browse the repository at this point in the history
…nly running docker compose V2.
  • Loading branch information
brunns committed Aug 6, 2024
1 parent 262a5d1 commit 8417447
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
npm --version
docker --version
docker compose version
docker-compose --version
- name: Run Tests
env:
MBTEST_VERSION: ${{ matrix.mbtest-version }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ update the version number in `setup.py`, then:
version="n.n.n" # Needs to match new version number in setup.py.
git checkout -b "release-$version"
make precommit && git commit -am"Release $version" && git push --set-upstream origin "release-$version" # If not already all pushed, which it should be.
gh release create "V$version" --target "release-$version" --generate-notes
gh release create "v$version" --target "release-$version" --generate-notes
python setup.py sdist bdist_wheel && twine upload dist/*$version*
git checkout master && git merge "release-$version"
git push
Expand Down
21 changes: 18 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# encoding=utf-8
import os
import platform
from urllib.error import HTTPError

import pytest
import requests
from requests.exceptions import ConnectionError as RequestsConnectionError
from yarl import URL

from mbtest import server
Expand All @@ -20,8 +23,20 @@ def mock_server(request):
@pytest.fixture(scope="session")
def httpbin(docker_ip, docker_services) -> URL:
if HTTPBIN_CONTAINERISED:
docker_services.start("httpbin")
port = docker_services.wait_for_service("httpbin", 80)
return URL(f"http://{docker_ip}:{port}")
port = docker_services.port_for("httpbin", 80)
url = URL(f"http://{docker_ip}:{port}")
docker_services.wait_until_responsive(
timeout=30.0, pause=0.1, check=lambda: is_responsive(url)
)
return url
else:
return URL("https://httpbin.org")


def is_responsive(url: URL) -> bool:
try:
response = requests.get(url)
response.raise_for_status()
return True
except (RequestsConnectionError, HTTPError):
return False
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ envlist = py38,py39,py310,py311,py312,pypy3.10

[testenv]
deps =
lovely-pytest-docker>=0.3.1
pytest-docker~=3.1

allowlist_externals =
find
Expand All @@ -12,7 +12,7 @@ allowlist_externals =
extras =
test
commands =
{posargs:py.test} tests/unit/ tests/integration/ -o log_cli=true --keepalive
{posargs:py.test} tests/unit/ tests/integration/ -o log_cli=true
passenv =
GITHUB_*
MBTEST_*
Expand Down

0 comments on commit 8417447

Please sign in to comment.