Skip to content

Commit

Permalink
Fix odoo/auto folder created with wrong permissions
Browse files Browse the repository at this point in the history
In doodba-copier-template, the `odoo/auto` folder is not provided just like it was with `doodba-scaffolding`.

When docker-compose needs it, docker it autogenerates it, and since docker >= root, the folder is owned by root. Then, the inner odoo process runs with lower permissions (same UID as host dev) and cannot symlink addons.

Here I fix #36 by creating `odoo/auto` with proper UID when executing `invoke develop`. There's also a new migration script that autoremoves that from the git tree if present, since that wasn't done before and a scaffolding might be coming from `doodba-scaffolding` where it was a present, git-tracked file.

However, for users that already had it created as root, the only workaround is to fix that folder's permissions or remove it manually as root. Sorry for that...
  • Loading branch information
Jairo Llopis authored and github-actions[bot] committed Apr 17, 2020
1 parent 22355ed commit 6b5ccf6
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ _migrations:
- --search-root={{ _copier_conf.src_path }}
- --collection=migrations
- from-doodba-scaffolding-to-copier
- version: v1.5.2
after:
- - invoke
- --search-root={{ _copier_conf.src_path }}
- --collection=migrations
- remove-odoo-auto-folder

# Questions for the user
project_author:
Expand Down
12 changes: 12 additions & 0 deletions migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ def from_doodba_scaffolding_to_copier(c):
"[*.yml]", "[*.{code-snippets,code-workspace,json,md,yaml,yml}{,.jinja}]", 1
)
editorconfig_file.write_text(editorconfig_contents)


@task
def remove_odoo_auto_folder(c):
"""This folder makes no more sense for us.
The `invoke develop` task now handles its creation, which is done with
host user UID and GID to avoid problems.
There's no need to have it in our code tree anymore.
"""
shutil.rmtree(Path("odoo", "auto"), ignore_errors=True)
1 change: 1 addition & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def update_test_samples(c):
dst = default_settings_path / f"v{v}"
c.run(f"poetry run copier -fr test -d odoo_version={v} copy . {dst}")
shutil.rmtree(dst / ".git")
shutil.rmtree(dst / "odoo" / "auto")
finally:
c.run("git tag --delete test")
samples = Path("tests", "samples")
Expand Down
1 change: 1 addition & 0 deletions tasks_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def develop(c):
c.run("python3 -m pip install --user pipx")
c.run(f"pipx install {dep}")
# Prepare environment
Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
1 change: 1 addition & 0 deletions tests/default_settings/v10.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def develop(c):
c.run("python3 -m pip install --user pipx")
c.run(f"pipx install {dep}")
# Prepare environment
Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
1 change: 1 addition & 0 deletions tests/default_settings/v11.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def develop(c):
c.run("python3 -m pip install --user pipx")
c.run(f"pipx install {dep}")
# Prepare environment
Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
1 change: 1 addition & 0 deletions tests/default_settings/v12.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def develop(c):
c.run("python3 -m pip install --user pipx")
c.run(f"pipx install {dep}")
# Prepare environment
Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
1 change: 1 addition & 0 deletions tests/default_settings/v13.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def develop(c):
c.run("python3 -m pip install --user pipx")
c.run(f"pipx install {dep}")
# Prepare environment
Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
1 change: 1 addition & 0 deletions tests/default_settings/v7.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def develop(c):
c.run("python3 -m pip install --user pipx")
c.run(f"pipx install {dep}")
# Prepare environment
Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
1 change: 1 addition & 0 deletions tests/default_settings/v8.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def develop(c):
c.run("python3 -m pip install --user pipx")
c.run(f"pipx install {dep}")
# Prepare environment
Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
1 change: 1 addition & 0 deletions tests/default_settings/v9.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def develop(c):
c.run("python3 -m pip install --user pipx")
c.run(f"pipx install {dep}")
# Prepare environment
Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
1 change: 1 addition & 0 deletions tests/test_default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_default_settings(
with local.cwd(dst):
# TODO When copier runs pre-commit before extracting diff, make sure
# here that it works as expected
Path(dst, "odoo", "auto").rmdir()
git("add", ".")
git("commit", "-am", "Hello World", retcode=1) # pre-commit fails
git("commit", "-am", "Hello World")
Expand Down
30 changes: 30 additions & 0 deletions tests/test_transition_to_copier.py → tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,33 @@ def test_transtion_to_copier(
"migrations",
"from-doodba-scaffolding-to-copier",
)


def test_v1_5_2_migration(
tmp_path: Path, cloned_template: Path, supported_odoo_version: float
):
"""Test migration to v1.5.2."""
auto = tmp_path / "odoo" / "auto"
empty = auto / ".empty" # This file existed in doodba-scaffolding
# This part makes sense v1.5.2 is not yet released
with local.cwd(cloned_template):
if "v1.5.2" not in git("tag").split():
git("tag", "-d", "test")
git("tag", "v1.5.2")
with local.cwd(tmp_path):
# Copy v1.5.1
copy(src_path=str(cloned_template), vcs_ref="v1.5.1", force=True)
auto.mkdir()
empty.touch()
assert empty.exists()
git("add", ".")
git("add", "-f", empty)
git("commit", "-am", "reformat", retcode=1)
git("commit", "-am", "copied from template in v1.5.1")
# Update to v1.5.2
copy(vcs_ref="v1.5.2", force=True)
assert not empty.exists()
assert not auto.exists()
invoke("develop")
assert auto.exists()
assert not empty.exists()

0 comments on commit 6b5ccf6

Please sign in to comment.