Skip to content

Commit

Permalink
fix(doctor): Docker compose version parsing, fixes #164
Browse files Browse the repository at this point in the history
  • Loading branch information
robdmoore committed Feb 9, 2023
1 parent 2a10d67 commit c3f4ef8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/algokit/core/sandbox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import enum
import json
import logging
import re
from pathlib import Path
from typing import Any, cast

Expand Down Expand Up @@ -215,4 +216,7 @@ def fetch_indexer_status_data(service_info: dict[str, Any]) -> dict[str, Any]:
def parse_docker_compose_version_output(output: str) -> str:
compose_version: dict[str, str] = json.loads(output)
compose_version_str = compose_version.get("version", "")
match = re.search(r"v?\d+\.\d+\.\d+", output)
if match:
return match.group(0).lstrip("v")
return compose_version_str.lstrip("v")
9 changes: 9 additions & 0 deletions tests/doctor/test_doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ def test_doctor_with_docker_compose_version_warning(proc_mock: ProcMock, mock_do
verify(result.output, scrubber=make_output_scrubber())


def test_doctor_with_docker_compose_version_gitpod(proc_mock: ProcMock, mock_doctor_dependencies: None):
proc_mock.set_output(DOCKER_COMPOSE_VERSION_COMMAND, ['{"version": "v2.10.0-gitpod.0"}'])

result = invoke("doctor")

assert result.exit_code == 0
verify(result.output, scrubber=make_output_scrubber())


def test_doctor_with_docker_compose_version_unparseable(proc_mock: ProcMock, mock_doctor_dependencies: None):
proc_mock.set_output(DOCKER_COMPOSE_VERSION_COMMAND, ['{"version": "TEAPOT"}'])

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
DEBUG: Running 'docker --version' in '{current_working_directory}'
DEBUG: docker: Docker version 20.10.21, build baeda1f
DEBUG: Running 'docker compose version --format json' in '{current_working_directory}'
DEBUG: docker: {"version": "v2.10.0-gitpod.0"}
DEBUG: Running 'git --version' in '{current_working_directory}'
DEBUG: git: git version 2.37.1 (Apple Git-137.1)
DEBUG: Running 'python --version' in '{current_working_directory}'
DEBUG: python: Python 3.10.0
DEBUG: Running 'python3 --version' in '{current_working_directory}'
DEBUG: python3: Python 3.11.0
DEBUG: Running 'pipx --version' in '{current_working_directory}'
DEBUG: pipx: 1.1.0
DEBUG: Running 'poetry --version' in '{current_working_directory}'
DEBUG: poetry: blah blah
DEBUG: poetry:
DEBUG: poetry: Poetry (version 1.2.2)
DEBUG: Running 'node --version' in '{current_working_directory}'
DEBUG: node: v18.12.1
DEBUG: Running 'npm --version' in '{current_working_directory}'
DEBUG: npm: 8.19.2
DEBUG: Running 'brew --version' in '{current_working_directory}'
DEBUG: brew: Homebrew 3.6.15
DEBUG: brew: Homebrew/homebrew-core (blah)
timestamp: 1990-12-31T10:09:08
AlgoKit: 1.2.3
AlgoKit Python: 3.6.2 (location: /home/me/.local/pipx/venvs/algokit)
OS: Darwin-other-system-info
docker: 20.10.21
docker compose: 2.10.0
git: 2.37.1
python: 3.10.0 (location: /usr/local/bin/python)
python3: 3.11.0 (location: /usr/local/bin/python3)
pipx: 1.1.0
poetry: 1.2.2
node: 18.12.1
npm: 8.19.2
brew: 3.6.15

If you are experiencing a problem with AlgoKit, feel free to submit an issue via:
https://github.com/algorandfoundation/algokit-cli/issues/new
Please include this output, if you want to populate this message in your clipboard, run `algokit doctor -c`

0 comments on commit c3f4ef8

Please sign in to comment.