diff --git a/bin/direxec b/bin/direxec index adecba7b..ca84efdd 100755 --- a/bin/direxec +++ b/bin/direxec @@ -25,7 +25,7 @@ except OSError: # Run scripts for executable, folder in sorted(files): command = os.path.join(folder, executable) - if os.access(command, os.X_OK): + if os.access(command, os.X_OK) and not os.path.isdir(command): logger.debug("Executing %s", command) subprocess.check_call(command) diff --git a/tests/__init__.py b/tests/__init__.py index 4f0f8dc7..541054bb 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -755,6 +755,20 @@ def test_aggregate_permissions(self): ("autoaggregate",), ) + def test_entrypoint_python(self): + symlink_dir = join(SCAFFOLDINGS_DIR, "entrypoint") + for sub_env in matrix(): + self.compose_test( + symlink_dir, + dict(sub_env, UID=str(os.getuid()), GID=str(os.getgid())), + # we verify that customizing entrypoint with python files work by writing to + # /tmp/customize_entrypoint.mark.txt with 60-customize_entrypoint.py + ( + "cat", + "/tmp/customize_entrypoint.mark.txt", + ), + ) + if __name__ == "__main__": unittest.main() diff --git a/tests/scaffoldings/entrypoint/Dockerfile b/tests/scaffoldings/entrypoint/Dockerfile new file mode 100644 index 00000000..4916c47a --- /dev/null +++ b/tests/scaffoldings/entrypoint/Dockerfile @@ -0,0 +1,2 @@ +ARG ODOO_VERSION +FROM tecnativa/doodba:${ODOO_VERSION}-onbuild diff --git a/tests/scaffoldings/entrypoint/custom/entrypoint.d/60-customize_entrypoint.py b/tests/scaffoldings/entrypoint/custom/entrypoint.d/60-customize_entrypoint.py new file mode 100755 index 00000000..c2054ffa --- /dev/null +++ b/tests/scaffoldings/entrypoint/custom/entrypoint.d/60-customize_entrypoint.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import doodbalib + +doodbalib.logger.info("custom entrypoint running") +with open("/tmp/customize_entrypoint.mark.txt", "w") as fp: + fp.write("ok\n") +doodbalib.logger.info("custom created /tmp/customize_entrypoint.mark.txt") diff --git a/tests/scaffoldings/entrypoint/custom/src/addons.yaml b/tests/scaffoldings/entrypoint/custom/src/addons.yaml new file mode 100644 index 00000000..e69de29b diff --git a/tests/scaffoldings/entrypoint/docker-compose.yaml b/tests/scaffoldings/entrypoint/docker-compose.yaml new file mode 100644 index 00000000..cf15da4b --- /dev/null +++ b/tests/scaffoldings/entrypoint/docker-compose.yaml @@ -0,0 +1,30 @@ +version: "2.1" +services: + odoo: + build: + context: ./ + args: + # compile causes the creation of __pycache__ in entrypoint.d for this test + COMPILE: "true" + ODOO_VERSION: $ODOO_MINOR + WITHOUT_DEMO: "false" + tty: true + depends_on: + - db + environment: + PYTHONOPTIMIZE: "" + UNACCENT: "false" + volumes: + - filestore:/var/lib/odoo:z + + db: + image: postgres:${DB_VERSION}-alpine + environment: + POSTGRES_USER: odoo + POSTGRES_PASSWORD: odoopassword + volumes: + - db:/var/lib/postgresql/data:z + +volumes: + db: + filestore: