1- # pylint: disable=unused-argument
2- # pylint: disable=bare-except
31# pylint: disable=redefined-outer-name
2+ # pylint: disable=unused-argument
3+ # pylint: disable=unused-variable
4+ # pylint: disable=too-many-arguments
45
56import re
67import shutil
@@ -110,7 +111,7 @@ def docker_compose_config_bash(osparc_simcore_scripts_dir: Path) -> Path:
110111def test_validate_compose_file (
111112 compose_path : Path ,
112113 env_devel_file : Path ,
113- ensure_env_file ,
114+ ensure_env_file : Path ,
114115 docker_compose_config_bash : Path ,
115116):
116117 assert compose_path .exists ()
@@ -119,7 +120,7 @@ def test_validate_compose_file(
119120
120121 # NOTE: with docker stack config, the .env file MUST be alongside the docker-compose file
121122
122- subprocess .run (
123+ subprocess .run ( # noqa: S602
123124 " " .join (
124125 [
125126 f"{ docker_compose_config_bash } " ,
@@ -135,3 +136,30 @@ def test_validate_compose_file(
135136
136137 # About versioning https://docs.docker.com/compose/compose-file/compose-file-v3/
137138 assert "version" not in compose
139+
140+
141+ @pytest .mark .parametrize (
142+ "compose_path" , compose_paths , ids = lambda p : str (p .relative_to (repo_dir ))
143+ )
144+ def test_network_names_contain_only_letters_and_underscores (
145+ compose_path : Path ,
146+ ):
147+ """Ensure all network names only contain letters and underscores (no hyphens or other symbols).
148+
149+
150+ NOTE: Our docker compose cannot resolve network names with hyphens
151+
152+ e.g. `make .stack-simcore-development.yml` produces a compose file that do not include these networks which
153+ results in an error when the stack starts that prints something like
154+
155+ ERROR: failed to create service master-simcore_docker-api-proxy: Error response from daemon: network master-simcore_docker-api-network not found
156+ """
157+ assert compose_path .exists ()
158+ compose = yaml .safe_load (compose_path .read_text ())
159+
160+ networks = compose .get ("networks" , {})
161+
162+ for network_name in networks :
163+ assert re .match (
164+ r"^[a-zA-Z_]+$" , network_name
165+ ), f"Network name '{ network_name } ' in { compose_path .relative_to (repo_dir )} contains invalid characters. Only letters and underscores are allowed."
0 commit comments