Skip to content

Commit

Permalink
Merge pull request #508 from ap-wtioit/master-fix_entrypointd_python_…
Browse files Browse the repository at this point in the history
…github

[FIX] direxec should not try to execute directories
  • Loading branch information
pedrobaeza authored Nov 29, 2023
2 parents 801f80c + 76e8ce3 commit 63861fa
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/direxec
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 2 additions & 0 deletions tests/scaffoldings/entrypoint/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ARG ODOO_VERSION
FROM tecnativa/doodba:${ODOO_VERSION}-onbuild
Original file line number Diff line number Diff line change
@@ -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")
Empty file.
30 changes: 30 additions & 0 deletions tests/scaffoldings/entrypoint/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit 63861fa

Please sign in to comment.