Skip to content

Commit

Permalink
Autocreate odoo/auto/addons
Browse files Browse the repository at this point in the history
If this directory is not pre-created by the host user, docker will create it owned by root and we'll have permissions problems.

Fixes #36.
  • Loading branch information
Jairo Llopis authored and github-actions[bot] committed Apr 20, 2020
1 parent 339d958 commit c91c59e
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 14 deletions.
6 changes: 6 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ _migrations:
- --search-root={{ _copier_conf.src_path }}
- --collection=migrations
- remove-odoo-auto-folder
- version: v1.5.3
after:
- - invoke
- --search-root={{ _copier_conf.src_path }}
- --collection=migrations
- remove-odoo-auto-folder

# Questions for the user
project_author:
Expand Down
2 changes: 1 addition & 1 deletion docs/scaffolding2copier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

source .env
copier $CUSTOM_COPIER_FLAGS \
-r "${TEMPLATE_VERSION-v1.5.1}" \
-r "${TEMPLATE_VERSION-v1.5.3}" \
-d project_name="${PROJECT_NAME-$(basename $PWD)}" \
-d project_license="${LICENSE-BSL-1.0}" \
-d gitlab_url="${GITLAB_PREFIX-https://gitlab.com/example}/${PROJECT_NAME-$(basename $PWD)}" \
Expand Down
2 changes: 1 addition & 1 deletion tasks_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +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)
Path(PROJECT_ROOT, "odoo", "auto", "addons").mkdir(parents=True, exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
2 changes: 1 addition & 1 deletion tests/default_settings/v10.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +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)
Path(PROJECT_ROOT, "odoo", "auto", "addons").mkdir(parents=True, exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
2 changes: 1 addition & 1 deletion tests/default_settings/v11.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +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)
Path(PROJECT_ROOT, "odoo", "auto", "addons").mkdir(parents=True, exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
2 changes: 1 addition & 1 deletion tests/default_settings/v12.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +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)
Path(PROJECT_ROOT, "odoo", "auto", "addons").mkdir(parents=True, exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
2 changes: 1 addition & 1 deletion tests/default_settings/v13.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +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)
Path(PROJECT_ROOT, "odoo", "auto", "addons").mkdir(parents=True, exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
2 changes: 1 addition & 1 deletion tests/default_settings/v7.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +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)
Path(PROJECT_ROOT, "odoo", "auto", "addons").mkdir(parents=True, exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
2 changes: 1 addition & 1 deletion tests/default_settings/v8.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +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)
Path(PROJECT_ROOT, "odoo", "auto", "addons").mkdir(parents=True, exist_ok=True)
with c.cd(str(PROJECT_ROOT)):
c.run("git init")
c.run("ln -sf devel.yaml docker-compose.yml")
Expand Down
2 changes: 1 addition & 1 deletion tests/default_settings/v9.0/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +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)
Path(PROJECT_ROOT, "odoo", "auto", "addons").mkdir(parents=True, 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", "addons").rmdir()
Path(dst, "odoo", "auto").rmdir()
git("add", ".")
git("commit", "-am", "Hello World", retcode=1) # pre-commit fails
Expand Down
31 changes: 26 additions & 5 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ def test_v1_5_2_migration(
"""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)
Expand All @@ -113,3 +108,29 @@ def test_v1_5_2_migration(
invoke("develop")
assert auto.exists()
assert not empty.exists()


def test_v1_5_3_migration(
tmp_path: Path, cloned_template: Path, supported_odoo_version: float
):
"""Test migration to v1.5.3."""
auto_addons = tmp_path / "odoo" / "auto" / "addons"
# This part makes sense only when v1.5.3 is not yet released
with local.cwd(cloned_template):
if "v1.5.3" not in git("tag").split():
git("tag", "-d", "test")
git("tag", "v1.5.3")
with local.cwd(tmp_path):
# Copy v1.5.2
copy(src_path=str(cloned_template), vcs_ref="v1.5.2", force=True)
assert not auto_addons.exists()
git("add", ".")
git("commit", "-am", "reformat", retcode=1)
git("commit", "-am", "copied from template in v1.5.2")
# Update to v1.5.3
copy(vcs_ref="v1.5.3", force=True)
assert not auto_addons.exists()
invoke("develop")
assert auto_addons.is_dir()
# odoo/auto/addons dir must be writable
(auto_addons / "sample").touch()

0 comments on commit c91c59e

Please sign in to comment.