浏览代码

ci: remove python docker-compose

Nicolas Duchon 2 年之前
父节点
当前提交
b5cac06305
共有 6 个文件被更改,包括 17 次插入18 次删除
  1. 3 3
      README.md
  2. 3 3
      test/README.md
  3. 8 8
      test/conftest.py
  4. 2 2
      test/pytest.sh
  5. 0 1
      test/requirements/python-requirements.txt
  6. 1 1
      test/test_wildcard_host.yml

+ 3 - 3
README.md

@@ -73,7 +73,7 @@ services:
 ```
 ```
 
 
 ```console
 ```console
-docker-compose up
+docker compose up
 curl -H "Host: whoami.example" localhost
 curl -H "Host: whoami.example" localhost
 ```
 ```
 
 
@@ -259,10 +259,10 @@ nginx-proxy can also be run as two separate containers using the [nginxproxy/doc
 
 
 You may want to do this to prevent having the docker socket bound to a publicly exposed container service.
 You may want to do this to prevent having the docker socket bound to a publicly exposed container service.
 
 
-You can demo this pattern with docker-compose:
+You can demo this pattern with docker compose:
 
 
 ```console
 ```console
-docker-compose --file docker-compose-separate-containers.yml up
+docker compose --file docker-compose-separate-containers.yml up
 curl -H "Host: whoami.example" localhost
 curl -H "Host: whoami.example" localhost
 ```
 ```
 
 

+ 3 - 3
test/README.md

@@ -48,11 +48,11 @@ This test suite uses [pytest](http://doc.pytest.org/en/latest/). The [conftest.p
 
 
 When using the `docker_compose` fixture in a test, pytest will try to find a yml file named after your test module filename. For instance, if your test module is `test_example.py`, then the `docker_compose` fixture will try to load a `test_example.yml` [docker compose file](https://docs.docker.com/compose/compose-file/).
 When using the `docker_compose` fixture in a test, pytest will try to find a yml file named after your test module filename. For instance, if your test module is `test_example.py`, then the `docker_compose` fixture will try to load a `test_example.yml` [docker compose file](https://docs.docker.com/compose/compose-file/).
 
 
-Once the docker compose file found, the fixture will remove all containers, run `docker-compose up`, and finally your test will be executed.
+Once the docker compose file found, the fixture will remove all containers, run `docker compose up`, and finally your test will be executed.
 
 
-The fixture will run the _docker-compose_ command with the `-f` option to load the given compose file. So you can test your docker compose file syntax by running it yourself with:
+The fixture will run the _docker compose_ command with the `-f` option to load the given compose file. So you can test your docker compose file syntax by running it yourself with:
 
 
-    docker-compose -f test_example.yml up -d
+    docker compose -f test_example.yml up -d
 
 
 In the case you are running pytest from within a docker container, the `docker_compose` fixture will make sure the container running pytest is attached to all docker networks. That way, your test will be able to reach any of them.
 In the case you are running pytest from within a docker container, the `docker_compose` fixture will make sure the container running pytest is attached to all docker networks. That way, your test will be able to reach any of them.
 
 

+ 8 - 8
test/conftest.py

@@ -301,19 +301,19 @@ def get_nginx_conf_from_container(container):
 
 
 
 
 def docker_compose_up(compose_file='docker-compose.yml'):
 def docker_compose_up(compose_file='docker-compose.yml'):
-    logging.info(f'docker-compose -f {compose_file} up -d')
+    logging.info(f'docker compose -f {compose_file} up -d')
     try:
     try:
-        subprocess.check_output(shlex.split(f'docker-compose -f {compose_file} up -d'), stderr=subprocess.STDOUT)
+        subprocess.check_output(shlex.split(f'docker compose -f {compose_file} up -d'), stderr=subprocess.STDOUT)
     except subprocess.CalledProcessError as e:
     except subprocess.CalledProcessError as e:
-        pytest.fail(f"Error while runninng 'docker-compose -f {compose_file} up -d':\n{e.output}", pytrace=False)
+        pytest.fail(f"Error while runninng 'docker compose -f {compose_file} up -d':\n{e.output}", pytrace=False)
 
 
 
 
 def docker_compose_down(compose_file='docker-compose.yml'):
 def docker_compose_down(compose_file='docker-compose.yml'):
-    logging.info(f'docker-compose -f {compose_file} down -v')
+    logging.info(f'docker compose -f {compose_file} down -v')
     try:
     try:
-        subprocess.check_output(shlex.split(f'docker-compose -f {compose_file} down -v'), stderr=subprocess.STDOUT)
+        subprocess.check_output(shlex.split(f'docker compose -f {compose_file} down -v'), stderr=subprocess.STDOUT)
     except subprocess.CalledProcessError as e:
     except subprocess.CalledProcessError as e:
-        pytest.fail(f"Error while runninng 'docker-compose -f {compose_file} down -v':\n{e.output}", pytrace=False)
+        pytest.fail(f"Error while runninng 'docker compose -f {compose_file} down -v':\n{e.output}", pytrace=False)
 
 
 
 
 def wait_for_nginxproxy_to_be_ready():
 def wait_for_nginxproxy_to_be_ready():
@@ -333,7 +333,7 @@ def wait_for_nginxproxy_to_be_ready():
 
 
 @pytest.fixture
 @pytest.fixture
 def docker_compose_file(request):
 def docker_compose_file(request):
-    """Fixture naming the docker-compose file to consider.
+    """Fixture naming the docker compose file to consider.
 
 
     If a YAML file exists with the same name as the test module (with the `.py` extension replaced
     If a YAML file exists with the same name as the test module (with the `.py` extension replaced
     with `.yml` or `.yaml`), use that.  Otherwise, use `docker-compose.yml` in the same directory
     with `.yml` or `.yaml`), use that.  Otherwise, use `docker-compose.yml` in the same directory
@@ -354,7 +354,7 @@ def docker_compose_file(request):
         docker_compose_file = default_file
         docker_compose_file = default_file
 
 
     if not os.path.isfile(docker_compose_file):
     if not os.path.isfile(docker_compose_file):
-        logging.error("Could not find any docker-compose file named either '{0}.yml', '{0}.yaml' or 'docker-compose.yml'".format(request.module.__name__))
+        logging.error("Could not find any docker compose file named either '{0}.yml', '{0}.yaml' or 'docker-compose.yml'".format(request.module.__name__))
 
 
     logging.debug(f"using docker compose file {docker_compose_file}")
     logging.debug(f"using docker compose file {docker_compose_file}")
     return docker_compose_file
     return docker_compose_file

+ 2 - 2
test/pytest.sh

@@ -19,8 +19,8 @@ docker build --pull -t nginx-proxy-tester \
   "${TESTDIR}/requirements" \
   "${TESTDIR}/requirements" \
   || exit 1
   || exit 1
 
 
-# run the nginx-proxy-tester container setting the correct value for the working dir in order for
-# docker-compose to work properly when run from within that container.
+# run the nginx-proxy-tester container setting the correct value for the working dir 
+# in order for docker compose to work properly when run from within that container.
 exec docker run --rm -it --name "nginx-proxy-pytest" \
 exec docker run --rm -it --name "nginx-proxy-pytest" \
   --volume "/var/run/docker.sock:/var/run/docker.sock" \
   --volume "/var/run/docker.sock:/var/run/docker.sock" \
   --volume "${DIR}:${DIR}" \
   --volume "${DIR}:${DIR}" \

+ 0 - 1
test/requirements/python-requirements.txt

@@ -1,5 +1,4 @@
 backoff==2.2.1
 backoff==2.2.1
-docker-compose==1.29.2
 docker==6.1.3
 docker==6.1.3
 pytest==7.4.3
 pytest==7.4.3
 requests==2.31.0
 requests==2.31.0

+ 1 - 1
test/test_wildcard_host.yml

@@ -28,7 +28,7 @@ web4:
     - "84"
     - "84"
   environment:
   environment:
     WEB_PORTS: "84"
     WEB_PORTS: "84"
-    VIRTUAL_HOST: ~^web4\..*\.nginx-proxy\.regexp$$ # we need to double the `$` because of docker-compose variable interpolation
+    VIRTUAL_HOST: ~^web4\..*\.nginx-proxy\.regexp$$ # we need to double the `$` because of docker compose variable interpolation
 
 
 
 
 sut:
 sut: