From 76e7d14f060bd199a0fa843b6515cab351557ca4 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 23 Jul 2024 09:58:14 -0400 Subject: [PATCH] Switch from `docker-compose` to `docker compose` --- .github/workflows/test.yml | 4 ++-- dandi/tests/fixtures.py | 31 ++++++++++++++++++++++++------- dandi/tests/skip.py | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d8089a536..9e940a6ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -115,14 +115,14 @@ jobs: - name: Dump Docker Compose logs if: failure() && startsWith(matrix.os, 'ubuntu') run: | - docker-compose \ + docker compose \ -f dandi/tests/data/dandiarchive-docker/docker-compose.yml \ logs --timestamps - name: Shut down Docker Compose if: startsWith(matrix.os, 'ubuntu') run: | - docker-compose \ + docker compose \ -f dandi/tests/data/dandiarchive-docker/docker-compose.yml \ down -v diff --git a/dandi/tests/fixtures.py b/dandi/tests/fixtures.py index f27e1dcea..9fe097154 100644 --- a/dandi/tests/fixtures.py +++ b/dandi/tests/fixtures.py @@ -395,16 +395,27 @@ def docker_compose_setup() -> Iterator[dict[str, str]]: try: if create: if os.environ.get("DANDI_TESTS_PULL_DOCKER_COMPOSE", "1") not in ("", "0"): - run(["docker-compose", "pull"], cwd=str(LOCAL_DOCKER_DIR), check=True) + run( + ["docker", "compose", "pull"], cwd=str(LOCAL_DOCKER_DIR), check=True + ) run( - ["docker-compose", "run", "--rm", "django", "./manage.py", "migrate"], + [ + "docker", + "compose", + "run", + "--rm", + "django", + "./manage.py", + "migrate", + ], cwd=str(LOCAL_DOCKER_DIR), env=env, check=True, ) run( [ - "docker-compose", + "docker", + "compose", "run", "--rm", "django", @@ -417,7 +428,8 @@ def docker_compose_setup() -> Iterator[dict[str, str]]: ) run( [ - "docker-compose", + "docker", + "compose", "run", "--rm", "-e", @@ -436,7 +448,8 @@ def docker_compose_setup() -> Iterator[dict[str, str]]: r = check_output( [ - "docker-compose", + "docker", + "compose", "run", "--rm", "-T", @@ -458,7 +471,7 @@ def docker_compose_setup() -> Iterator[dict[str, str]]: if create: run( - ["docker-compose", "up", "-d", "django", "celery"], + ["docker", "compose", "up", "-d", "django", "celery"], cwd=str(LOCAL_DOCKER_DIR), env=env, check=True, @@ -476,7 +489,11 @@ def docker_compose_setup() -> Iterator[dict[str, str]]: yield {"django_api_key": django_api_key} finally: if persist in (None, "0"): - run(["docker-compose", "down", "-v"], cwd=str(LOCAL_DOCKER_DIR), check=True) + run( + ["docker", "compose", "down", "-v"], + cwd=str(LOCAL_DOCKER_DIR), + check=True, + ) @dataclass diff --git a/dandi/tests/skip.py b/dandi/tests/skip.py index 0e08b5f99..54d864b76 100644 --- a/dandi/tests/skip.py +++ b/dandi/tests/skip.py @@ -101,7 +101,7 @@ def windows(): def no_docker_commands(): missing_cmds = [] - for cmd in ("docker", "docker-compose"): + for cmd in ("docker",): if shutil.which(cmd) is None: missing_cmds.append(cmd) msg = "missing Docker commands: {}".format(", ".join(missing_cmds))