Skip to content

Commit

Permalink
fix: docker compose ps parsing for version >= 2.21 (#336)
Browse files Browse the repository at this point in the history
* fix: docker compose ps parsing for version >= 2.21

* simplify condition for parsing docker compose ps

* Use startswith

Co-authored-by: Adam Chidlow <[email protected]>

* remove "data = []"

* use splitlines

Co-authored-by: Al <[email protected]>

---------

Co-authored-by: Adam Chidlow <[email protected]>
Co-authored-by: Al <[email protected]>
  • Loading branch information
3 people authored Oct 20, 2023
1 parent 288b561 commit 06ba5e9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/algokit/core/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ def ps(self, service_name: str | None = None) -> list[dict[str, Any]]:
)
if run_results.exit_code != 0:
return []
data = json.loads(run_results.output)

# `docker compose ps --format json` on version < 2.21.0 outputs a JSON arary
if run_results.output.startswith("["):
data = json.loads(run_results.output)
# `docker compose ps --format json` on version >= 2.21.0 outputs seperate JSON objects, each on a new line
else:
data = [json.loads(line) for line in run_results.output.splitlines() if line]

assert isinstance(data, list)
return cast(list[dict[str, Any]], data)

Expand Down

1 comment on commit 06ba5e9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit
   __init__.py15753%6–13, 17–24, 32–34
   __main__.py220%1–3
src/algokit/cli
   completions.py105298%80, 95
   deploy.py56591%34–36, 78, 96
   dispenser.py116199%74
   doctor.py48394%142–144
   generate.py57198%116
   goal.py39197%57
   init.py1901692%272–273, 323, 326–328, 339, 383, 409, 449, 458–460, 463–468, 481
   localnet.py93397%162, 183–184
src/algokit/core
   bootstrap.py1612485%103–104, 126, 149, 214, 217, 223–237, 246–251
   conf.py54885%10, 24, 28, 36, 38, 71–73
   deploy.py691184%61–64, 73–75, 79, 84, 91–93
   dispenser.py2022687%88, 120–121, 138–146, 188–189, 195–197, 215–216, 256–257, 315, 329–331, 342–343, 353, 366, 381
   doctor.py65789%67–69, 92–94, 134
   generate.py41295%68, 86
   goal.py56395%27–28, 38
   log_handlers.py68790%50–51, 63, 112–116, 125
   proc.py45198%98
   sandbox.py1831592%100–107, 118, 285, 301, 316–318, 334
   typed_client_generation.py80594%55–57, 70, 75
   utils.py18289%27–28
   version_prompt.py73889%27–28, 40, 59–62, 80, 109
TOTAL199216092% 

Tests Skipped Failures Errors Time
285 0 💤 0 ❌ 0 🔥 32.377s ⏱️

Please sign in to comment.