odoo-devops-tools 1.27.3__tar.gz → 1.27.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/PKG-INFO +67 -20
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/README.md +66 -19
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools/odoo_compose.py +61 -25
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools.egg-info/PKG-INFO +67 -20
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/pyproject.toml +1 -1
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/common.py +21 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_bundle.py +44 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_git.py +114 -1
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_ini.py +66 -1
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/LICENSE +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools/__init__.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools.egg-info/SOURCES.txt +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools.egg-info/dependency_links.txt +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools.egg-info/entry_points.txt +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools.egg-info/top_level.txt +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/setup.cfg +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/__init__.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/conftest.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/integration_support.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_cli.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_completion.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_docker.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_docker_source.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_git_progress.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_lifecycle.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_refactoring.py +0 -0
- {odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/tests/test_venv.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: odoo-devops-tools
|
|
3
|
-
Version: 1.27.
|
|
3
|
+
Version: 1.27.4
|
|
4
4
|
Summary: Build reproducible Odoo workspaces from a single project definition.
|
|
5
5
|
Author: Roman Lacko
|
|
6
6
|
License-Expression: MIT
|
|
@@ -208,7 +208,7 @@ odoo-compose docker setup --sync
|
|
|
208
208
|
odoo-compose docker up --build
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
The repositories are cloned into `ROOT/odoo-addons/` and bind-mounted into the Odoo container. Python dependencies from
|
|
211
|
+
The repositories are cloned into `ROOT/odoo-addons/` and bind-mounted into the Odoo container. Python dependencies from the selected addon directories' `requirements.txt` files are included when rebuilding the Docker image.
|
|
212
212
|
|
|
213
213
|
Install the new modules:
|
|
214
214
|
|
|
@@ -414,7 +414,7 @@ Sync the addon repositories and recreate the Python environment to include their
|
|
|
414
414
|
odoo-compose venv setup --sync --create-venv
|
|
415
415
|
```
|
|
416
416
|
|
|
417
|
-
The repositories are cloned into `ROOT/odoo-addons/` and automatically added to the generated `addons_path`. Python dependencies from
|
|
417
|
+
The repositories are cloned into `ROOT/odoo-addons/` and automatically added to the generated `addons_path`. Python dependencies from the selected addon directories' `requirements.txt` files are included in the virtual environment.
|
|
418
418
|
|
|
419
419
|
Install the new modules:
|
|
420
420
|
|
|
@@ -467,7 +467,7 @@ This recreates the virtual environment at `ROOT/venv` using the system Python.
|
|
|
467
467
|
|
|
468
468
|
The `[virtualenv]` section controls additional Python dependencies used when provisioning both the native virtual environment and generated Docker images.
|
|
469
469
|
|
|
470
|
-
Use it to add new packages, pin specific versions, and override packages collected from Odoo or addon
|
|
470
|
+
Use it to add new packages, pin specific versions, and override packages collected from Odoo or addon directory `requirements.txt` files.
|
|
471
471
|
|
|
472
472
|
Use:
|
|
473
473
|
|
|
@@ -1576,33 +1576,80 @@ path = ../odoo
|
|
|
1576
1576
|
|
|
1577
1577
|
Addon sections are optional. You can define as many as needed.
|
|
1578
1578
|
|
|
1579
|
+
- `path` — local directory containing Odoo addons. Relative paths are resolved relative to `ROOT/`.
|
|
1580
|
+
- `repo` — Git repository URL. Required for Git-managed addons.
|
|
1581
|
+
- `branch` — Git branch to check out. Required for Git-managed addons.
|
|
1582
|
+
- `commit` — optional Git commit. When set, the repository is pinned to that exact revision.
|
|
1583
|
+
- `shallow` — whether to use a shallow clone. Default: `true`. Ignored when `commit` is set.
|
|
1584
|
+
- `subdirectory` — optional directory containing Odoo addons, relative to the Git repository root. Default: `.` (repository root). Use `/` separators on every platform. The directory must exist when used. Absolute paths, parent traversal and paths resolving outside the repository are not allowed.
|
|
1585
|
+
|
|
1579
1586
|
Each addon must use exactly one of these source types:
|
|
1580
1587
|
|
|
1581
1588
|
- local addon path: `path`
|
|
1582
|
-
- Git repository: `repo` + `branch` (+ optional `commit` and `
|
|
1589
|
+
- Git repository: `repo` + `branch` (+ optional `commit`, `shallow` and `subdirectory`)
|
|
1583
1590
|
|
|
1584
|
-
|
|
1591
|
+
Git repositories are cloned into `ROOT/odoo-addons/<name>/`, and the selected addon directory is added to the generated `addons_path`.
|
|
1585
1592
|
|
|
1586
|
-
|
|
1587
|
-
- For a Git addon, `repo` and `branch` are required.
|
|
1588
|
-
- `commit` is optional for a Git addon. When set, the repository is pinned to that exact revision.
|
|
1589
|
-
- `shallow` is optional for Git addons and defaults to `true`. It is ignored when `commit` is set.
|
|
1590
|
-
- Relative local paths are resolved relative to `ROOT/`.
|
|
1591
|
-
- Git-based addons are cloned into `ROOT/odoo-addons/<name>/`.
|
|
1592
|
-
- All configured addon directories are automatically appended to the generated `addons_path`.
|
|
1593
|
-
|
|
1594
|
-
Examples:
|
|
1593
|
+
Example of Git-managed addons in subdirectories:
|
|
1595
1594
|
|
|
1596
1595
|
```ini
|
|
1597
|
-
[addons.
|
|
1598
|
-
|
|
1596
|
+
[addons.custom]
|
|
1597
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1598
|
+
branch = ${odoo:version}
|
|
1599
|
+
subdirectory = addons
|
|
1599
1600
|
|
|
1600
|
-
[addons.oca-web]
|
|
1601
|
-
repo = https://github.com/
|
|
1601
|
+
[addons.3rd-party-oca-web]
|
|
1602
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1603
|
+
branch = ${odoo:version}
|
|
1604
|
+
subdirectory = 3rd-party/oca-web
|
|
1605
|
+
|
|
1606
|
+
[addons.3rd-party-muk-it]
|
|
1607
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1602
1608
|
branch = ${odoo:version}
|
|
1603
|
-
|
|
1609
|
+
subdirectory = 3rd-party/muk-it
|
|
1604
1610
|
```
|
|
1605
1611
|
|
|
1612
|
+
Expected directory layout (relevant subdirectories only):
|
|
1613
|
+
|
|
1614
|
+
```text
|
|
1615
|
+
ROOT/odoo-addons/
|
|
1616
|
+
├── custom/
|
|
1617
|
+
│ └── addons/
|
|
1618
|
+
│ ├── requirements.txt
|
|
1619
|
+
│ ├── custom_sale/
|
|
1620
|
+
│ │ └── __manifest__.py
|
|
1621
|
+
│ └── custom_stock/
|
|
1622
|
+
│ └── __manifest__.py
|
|
1623
|
+
├── 3rd-party-oca-web/
|
|
1624
|
+
│ └── 3rd-party/
|
|
1625
|
+
│ └── oca-web/
|
|
1626
|
+
│ ├── requirements.txt
|
|
1627
|
+
│ ├── web_environment_ribbon/
|
|
1628
|
+
│ │ └── __manifest__.py
|
|
1629
|
+
│ └── web_responsive/
|
|
1630
|
+
│ └── __manifest__.py
|
|
1631
|
+
└── 3rd-party-muk-it/
|
|
1632
|
+
└── 3rd-party/
|
|
1633
|
+
└── muk-it/
|
|
1634
|
+
├── muk_ai/
|
|
1635
|
+
│ └── __manifest__.py
|
|
1636
|
+
├── muk_ai_automation/
|
|
1637
|
+
│ └── __manifest__.py
|
|
1638
|
+
└── muk_mcp/
|
|
1639
|
+
└── __manifest__.py
|
|
1640
|
+
```
|
|
1641
|
+
|
|
1642
|
+
Generated addon paths (excluding standard Odoo paths):
|
|
1643
|
+
|
|
1644
|
+
```text
|
|
1645
|
+
ROOT/odoo-addons/custom/addons
|
|
1646
|
+
ROOT/odoo-addons/3rd-party-oca-web/3rd-party/oca-web
|
|
1647
|
+
ROOT/odoo-addons/3rd-party-muk-it/3rd-party/muk-it
|
|
1648
|
+
```
|
|
1649
|
+
|
|
1650
|
+
The same Git repository can be configured multiple times using distinct
|
|
1651
|
+
addon source names, branches, and subdirectories.
|
|
1652
|
+
|
|
1606
1653
|
### `[docker]`
|
|
1607
1654
|
|
|
1608
1655
|
This section is optional.
|
|
@@ -180,7 +180,7 @@ odoo-compose docker setup --sync
|
|
|
180
180
|
odoo-compose docker up --build
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
-
The repositories are cloned into `ROOT/odoo-addons/` and bind-mounted into the Odoo container. Python dependencies from
|
|
183
|
+
The repositories are cloned into `ROOT/odoo-addons/` and bind-mounted into the Odoo container. Python dependencies from the selected addon directories' `requirements.txt` files are included when rebuilding the Docker image.
|
|
184
184
|
|
|
185
185
|
Install the new modules:
|
|
186
186
|
|
|
@@ -386,7 +386,7 @@ Sync the addon repositories and recreate the Python environment to include their
|
|
|
386
386
|
odoo-compose venv setup --sync --create-venv
|
|
387
387
|
```
|
|
388
388
|
|
|
389
|
-
The repositories are cloned into `ROOT/odoo-addons/` and automatically added to the generated `addons_path`. Python dependencies from
|
|
389
|
+
The repositories are cloned into `ROOT/odoo-addons/` and automatically added to the generated `addons_path`. Python dependencies from the selected addon directories' `requirements.txt` files are included in the virtual environment.
|
|
390
390
|
|
|
391
391
|
Install the new modules:
|
|
392
392
|
|
|
@@ -439,7 +439,7 @@ This recreates the virtual environment at `ROOT/venv` using the system Python.
|
|
|
439
439
|
|
|
440
440
|
The `[virtualenv]` section controls additional Python dependencies used when provisioning both the native virtual environment and generated Docker images.
|
|
441
441
|
|
|
442
|
-
Use it to add new packages, pin specific versions, and override packages collected from Odoo or addon
|
|
442
|
+
Use it to add new packages, pin specific versions, and override packages collected from Odoo or addon directory `requirements.txt` files.
|
|
443
443
|
|
|
444
444
|
Use:
|
|
445
445
|
|
|
@@ -1548,33 +1548,80 @@ path = ../odoo
|
|
|
1548
1548
|
|
|
1549
1549
|
Addon sections are optional. You can define as many as needed.
|
|
1550
1550
|
|
|
1551
|
+
- `path` — local directory containing Odoo addons. Relative paths are resolved relative to `ROOT/`.
|
|
1552
|
+
- `repo` — Git repository URL. Required for Git-managed addons.
|
|
1553
|
+
- `branch` — Git branch to check out. Required for Git-managed addons.
|
|
1554
|
+
- `commit` — optional Git commit. When set, the repository is pinned to that exact revision.
|
|
1555
|
+
- `shallow` — whether to use a shallow clone. Default: `true`. Ignored when `commit` is set.
|
|
1556
|
+
- `subdirectory` — optional directory containing Odoo addons, relative to the Git repository root. Default: `.` (repository root). Use `/` separators on every platform. The directory must exist when used. Absolute paths, parent traversal and paths resolving outside the repository are not allowed.
|
|
1557
|
+
|
|
1551
1558
|
Each addon must use exactly one of these source types:
|
|
1552
1559
|
|
|
1553
1560
|
- local addon path: `path`
|
|
1554
|
-
- Git repository: `repo` + `branch` (+ optional `commit` and `
|
|
1561
|
+
- Git repository: `repo` + `branch` (+ optional `commit`, `shallow` and `subdirectory`)
|
|
1555
1562
|
|
|
1556
|
-
|
|
1563
|
+
Git repositories are cloned into `ROOT/odoo-addons/<name>/`, and the selected addon directory is added to the generated `addons_path`.
|
|
1557
1564
|
|
|
1558
|
-
|
|
1559
|
-
- For a Git addon, `repo` and `branch` are required.
|
|
1560
|
-
- `commit` is optional for a Git addon. When set, the repository is pinned to that exact revision.
|
|
1561
|
-
- `shallow` is optional for Git addons and defaults to `true`. It is ignored when `commit` is set.
|
|
1562
|
-
- Relative local paths are resolved relative to `ROOT/`.
|
|
1563
|
-
- Git-based addons are cloned into `ROOT/odoo-addons/<name>/`.
|
|
1564
|
-
- All configured addon directories are automatically appended to the generated `addons_path`.
|
|
1565
|
-
|
|
1566
|
-
Examples:
|
|
1565
|
+
Example of Git-managed addons in subdirectories:
|
|
1567
1566
|
|
|
1568
1567
|
```ini
|
|
1569
|
-
[addons.
|
|
1570
|
-
|
|
1568
|
+
[addons.custom]
|
|
1569
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1570
|
+
branch = ${odoo:version}
|
|
1571
|
+
subdirectory = addons
|
|
1571
1572
|
|
|
1572
|
-
[addons.oca-web]
|
|
1573
|
-
repo = https://github.com/
|
|
1573
|
+
[addons.3rd-party-oca-web]
|
|
1574
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1575
|
+
branch = ${odoo:version}
|
|
1576
|
+
subdirectory = 3rd-party/oca-web
|
|
1577
|
+
|
|
1578
|
+
[addons.3rd-party-muk-it]
|
|
1579
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1574
1580
|
branch = ${odoo:version}
|
|
1575
|
-
|
|
1581
|
+
subdirectory = 3rd-party/muk-it
|
|
1576
1582
|
```
|
|
1577
1583
|
|
|
1584
|
+
Expected directory layout (relevant subdirectories only):
|
|
1585
|
+
|
|
1586
|
+
```text
|
|
1587
|
+
ROOT/odoo-addons/
|
|
1588
|
+
├── custom/
|
|
1589
|
+
│ └── addons/
|
|
1590
|
+
│ ├── requirements.txt
|
|
1591
|
+
│ ├── custom_sale/
|
|
1592
|
+
│ │ └── __manifest__.py
|
|
1593
|
+
│ └── custom_stock/
|
|
1594
|
+
│ └── __manifest__.py
|
|
1595
|
+
├── 3rd-party-oca-web/
|
|
1596
|
+
│ └── 3rd-party/
|
|
1597
|
+
│ └── oca-web/
|
|
1598
|
+
│ ├── requirements.txt
|
|
1599
|
+
│ ├── web_environment_ribbon/
|
|
1600
|
+
│ │ └── __manifest__.py
|
|
1601
|
+
│ └── web_responsive/
|
|
1602
|
+
│ └── __manifest__.py
|
|
1603
|
+
└── 3rd-party-muk-it/
|
|
1604
|
+
└── 3rd-party/
|
|
1605
|
+
└── muk-it/
|
|
1606
|
+
├── muk_ai/
|
|
1607
|
+
│ └── __manifest__.py
|
|
1608
|
+
├── muk_ai_automation/
|
|
1609
|
+
│ └── __manifest__.py
|
|
1610
|
+
└── muk_mcp/
|
|
1611
|
+
└── __manifest__.py
|
|
1612
|
+
```
|
|
1613
|
+
|
|
1614
|
+
Generated addon paths (excluding standard Odoo paths):
|
|
1615
|
+
|
|
1616
|
+
```text
|
|
1617
|
+
ROOT/odoo-addons/custom/addons
|
|
1618
|
+
ROOT/odoo-addons/3rd-party-oca-web/3rd-party/oca-web
|
|
1619
|
+
ROOT/odoo-addons/3rd-party-muk-it/3rd-party/muk-it
|
|
1620
|
+
```
|
|
1621
|
+
|
|
1622
|
+
The same Git repository can be configured multiple times using distinct
|
|
1623
|
+
addon source names, branches, and subdirectories.
|
|
1624
|
+
|
|
1578
1625
|
### `[docker]`
|
|
1579
1626
|
|
|
1580
1627
|
This section is optional.
|
|
@@ -41,7 +41,7 @@ from urllib.error import HTTPError, URLError
|
|
|
41
41
|
from urllib.parse import parse_qs, unquote, urlparse, urlunparse
|
|
42
42
|
from urllib.request import Request, urlopen
|
|
43
43
|
|
|
44
|
-
__version__ = "1.27.
|
|
44
|
+
__version__ = "1.27.4"
|
|
45
45
|
|
|
46
46
|
_logger = logging.getLogger("odoo-compose")
|
|
47
47
|
|
|
@@ -187,6 +187,7 @@ _INI_SET_SUPPORTED_OPTIONS = {
|
|
|
187
187
|
},
|
|
188
188
|
}
|
|
189
189
|
_INI_SET_ADDON_SUPPORTED_OPTIONS = {
|
|
190
|
+
"subdirectory",
|
|
190
191
|
"repo",
|
|
191
192
|
"branch",
|
|
192
193
|
"commit",
|
|
@@ -266,6 +267,7 @@ class AddonSpec:
|
|
|
266
267
|
commit: Optional[str] = None
|
|
267
268
|
path: Optional[str] = None
|
|
268
269
|
shallow: bool = True
|
|
270
|
+
subdirectory: str = "."
|
|
269
271
|
|
|
270
272
|
@property
|
|
271
273
|
def is_local(self) -> bool:
|
|
@@ -1559,6 +1561,23 @@ def _parse_odoo_spec(cp: configparser.ConfigParser, odoo_version: str) -> OdooSp
|
|
|
1559
1561
|
return odoo
|
|
1560
1562
|
|
|
1561
1563
|
|
|
1564
|
+
def _parse_addon_subdirectory(cp: configparser.ConfigParser, section: str) -> str:
|
|
1565
|
+
value = cp.get(section, "subdirectory", fallback=".").strip() or "."
|
|
1566
|
+
path = PurePosixPath(value)
|
|
1567
|
+
# Reject host-specific separators, drive paths and traversal on every platform.
|
|
1568
|
+
if (
|
|
1569
|
+
path.is_absolute()
|
|
1570
|
+
or ".." in path.parts
|
|
1571
|
+
or any(part.endswith((".", " ")) for part in path.parts)
|
|
1572
|
+
or re.search(r'[\\:<>"|?*\x00-\x1f]', value)
|
|
1573
|
+
):
|
|
1574
|
+
raise Exception(
|
|
1575
|
+
f"Invalid option 'subdirectory' in section [{section}]: "
|
|
1576
|
+
"expected a relative directory inside the addon source, using '/' separators."
|
|
1577
|
+
)
|
|
1578
|
+
return path.as_posix()
|
|
1579
|
+
|
|
1580
|
+
|
|
1562
1581
|
def _parse_addon_specs(cp: configparser.ConfigParser) -> dict[str, AddonSpec]:
|
|
1563
1582
|
# Addons are optional. If there are no [addons.<name>] sections, keep addons empty.
|
|
1564
1583
|
addons: dict[str, AddonSpec] = {}
|
|
@@ -1578,6 +1597,8 @@ def _parse_addon_specs(cp: configparser.ConfigParser) -> dict[str, AddonSpec]:
|
|
|
1578
1597
|
has_branch = cp.has_option(sec, "branch")
|
|
1579
1598
|
has_commit = cp.has_option(sec, "commit")
|
|
1580
1599
|
has_shallow = cp.has_option(sec, "shallow")
|
|
1600
|
+
if cp.has_option(sec, "subdirectory") and (has_path or not has_repo):
|
|
1601
|
+
raise Exception(f"[{sec}]: 'subdirectory' can only be used with 'repo'.")
|
|
1581
1602
|
|
|
1582
1603
|
path_value = cp.get(sec, "path", fallback="").strip() if has_path else ""
|
|
1583
1604
|
if has_path:
|
|
@@ -1589,7 +1610,7 @@ def _parse_addon_specs(cp: configparser.ConfigParser) -> dict[str, AddonSpec]:
|
|
|
1589
1610
|
raise Exception(
|
|
1590
1611
|
f"Invalid addon source in section [{sec}]: "
|
|
1591
1612
|
"use either 'path' only for a local addon, or 'repo' + 'branch' "
|
|
1592
|
-
"(+ optional 'commit' and '
|
|
1613
|
+
"(+ optional 'commit', 'shallow' and 'subdirectory') for a git addon."
|
|
1593
1614
|
)
|
|
1594
1615
|
addons[name] = AddonSpec(path=path_value)
|
|
1595
1616
|
continue
|
|
@@ -1599,6 +1620,7 @@ def _parse_addon_specs(cp: configparser.ConfigParser) -> dict[str, AddonSpec]:
|
|
|
1599
1620
|
branch=_require_ini_option(cp, sec, "branch"),
|
|
1600
1621
|
commit=cp.get(sec, "commit", fallback="").strip() or None,
|
|
1601
1622
|
shallow=_get_ini_bool(cp, sec, "shallow", default=True),
|
|
1623
|
+
subdirectory=_parse_addon_subdirectory(cp, sec),
|
|
1602
1624
|
)
|
|
1603
1625
|
|
|
1604
1626
|
return addons
|
|
@@ -2618,6 +2640,20 @@ def _validate_local_addon_path(layout: Layout, addon_name: str, spec: AddonSpec)
|
|
|
2618
2640
|
return _validate_existing_dir(addon_path, f"Local addon path for [addons.{addon_name}]")
|
|
2619
2641
|
|
|
2620
2642
|
|
|
2643
|
+
def _resolve_addon_modules_path(layout: Layout, addon_name: str, spec: AddonSpec) -> Path:
|
|
2644
|
+
source_root = _validate_local_addon_path(layout, addon_name, spec)
|
|
2645
|
+
if spec.is_local or spec.subdirectory == ".":
|
|
2646
|
+
return source_root
|
|
2647
|
+
|
|
2648
|
+
modules_path = source_root / spec.subdirectory
|
|
2649
|
+
if not _is_path_within(modules_path, source_root):
|
|
2650
|
+
raise Exception(
|
|
2651
|
+
f"Unsafe subdirectory for [addons.{addon_name}]: {modules_path} "
|
|
2652
|
+
f"must resolve inside {source_root}."
|
|
2653
|
+
)
|
|
2654
|
+
return _validate_existing_dir(modules_path, f"Addon subdirectory for [addons.{addon_name}]")
|
|
2655
|
+
|
|
2656
|
+
|
|
2621
2657
|
def render_odoo_conf(cfg: dict[str, Any], layout: Layout, addon_paths: list[Path]) -> str:
|
|
2622
2658
|
odoo_addons_candidates = [
|
|
2623
2659
|
layout.odoo_dir / "addons",
|
|
@@ -2850,7 +2886,7 @@ def stage_docker_addons(layout: Layout, cfg: ProjectConfig, docker_context_dir:
|
|
|
2850
2886
|
staged_modules: dict[str, Path] = {}
|
|
2851
2887
|
|
|
2852
2888
|
for addon_name, spec in cfg.addons.items():
|
|
2853
|
-
source_root =
|
|
2889
|
+
source_root = _resolve_addon_modules_path(layout, addon_name, spec)
|
|
2854
2890
|
if not source_root.exists():
|
|
2855
2891
|
raise Exception(
|
|
2856
2892
|
f"Addon source for [addons.{addon_name}] does not exist: {source_root}. "
|
|
@@ -3073,7 +3109,7 @@ def _render_docker_local_addon_volumes(layout: Layout, cfg: ProjectConfig) -> li
|
|
|
3073
3109
|
volumes: list[str] = []
|
|
3074
3110
|
|
|
3075
3111
|
for addon_name, spec in cfg.addons.items():
|
|
3076
|
-
source_root =
|
|
3112
|
+
source_root = _resolve_addon_modules_path(layout, addon_name, spec)
|
|
3077
3113
|
if not source_root.exists():
|
|
3078
3114
|
raise Exception(
|
|
3079
3115
|
f"Addon source for [addons.{addon_name}] does not exist: {source_root}. "
|
|
@@ -3779,11 +3815,13 @@ def _portable_project_ini(
|
|
|
3779
3815
|
portable.set("odoo", "version", cfg.odoo.version)
|
|
3780
3816
|
portable.set("odoo", "path", "odoo")
|
|
3781
3817
|
|
|
3782
|
-
for addon_name in cfg.addons:
|
|
3818
|
+
for addon_name, spec in cfg.addons.items():
|
|
3783
3819
|
safe_name = _safe_bundle_addon_name(addon_name)
|
|
3784
3820
|
section = f"addons.{safe_name}"
|
|
3785
3821
|
portable.add_section(section)
|
|
3786
|
-
|
|
3822
|
+
# Bundled sources become local paths; select the addon directory directly.
|
|
3823
|
+
addon_path = PurePosixPath("odoo-addons") / safe_name / spec.subdirectory
|
|
3824
|
+
portable.set(section, "path", addon_path.as_posix())
|
|
3787
3825
|
|
|
3788
3826
|
buf = io.StringIO()
|
|
3789
3827
|
portable.write(buf)
|
|
@@ -3847,6 +3885,7 @@ def create_workspace_bundle(
|
|
|
3847
3885
|
addon_sources: dict[str, Path] = {}
|
|
3848
3886
|
for addon_name, spec in cfg.addons.items():
|
|
3849
3887
|
safe_name = _safe_bundle_addon_name(addon_name)
|
|
3888
|
+
_resolve_addon_modules_path(layout, addon_name, spec)
|
|
3850
3889
|
addon_sources[safe_name] = _validate_local_addon_path(layout, addon_name, spec)
|
|
3851
3890
|
|
|
3852
3891
|
wheelhouse = _validate_existing_dir(layout.wheelhouse_dir, "Wheelhouse directory")
|
|
@@ -4360,6 +4399,7 @@ def _sync_odoo_source(layout: Layout, cfg: ProjectConfig, sync_odoo: bool, venv_
|
|
|
4360
4399
|
odoo_req = odoo_dest / "requirements.txt"
|
|
4361
4400
|
if not odoo_req.exists():
|
|
4362
4401
|
raise Exception(f"Odoo requirements file not found: {odoo_req}")
|
|
4402
|
+
_logger.info("Using requirements.txt for Odoo: %s", odoo_req)
|
|
4363
4403
|
req_files.append(odoo_req)
|
|
4364
4404
|
else:
|
|
4365
4405
|
# If we're provisioning python but not syncing repos, use whatever is already present in the workspace.
|
|
@@ -4367,6 +4407,7 @@ def _sync_odoo_source(layout: Layout, cfg: ProjectConfig, sync_odoo: bool, venv_
|
|
|
4367
4407
|
odoo_dest = _validate_local_odoo_path(layout, cfg.odoo)
|
|
4368
4408
|
odoo_req = odoo_dest / "requirements.txt"
|
|
4369
4409
|
if odoo_req.exists():
|
|
4410
|
+
_logger.info("Using requirements.txt for Odoo: %s", odoo_req)
|
|
4370
4411
|
req_files.append(odoo_req)
|
|
4371
4412
|
|
|
4372
4413
|
return req_files
|
|
@@ -4381,12 +4422,14 @@ def _sync_addon_sources(
|
|
|
4381
4422
|
) -> tuple[list[Path], list[Path]]:
|
|
4382
4423
|
req_files: list[Path] = []
|
|
4383
4424
|
addon_req_files: list[Path] = []
|
|
4384
|
-
if sync_addons:
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
dest = _validate_local_addon_path(layout, addon_name, spec)
|
|
4425
|
+
if sync_addons and not cfg.addons:
|
|
4426
|
+
_logger.info("No [addons.*] sections configured; skipping addons sync.")
|
|
4427
|
+
if not (sync_addons or venv_py is not None or docker_requested):
|
|
4428
|
+
return req_files, addon_req_files
|
|
4389
4429
|
|
|
4430
|
+
for addon_name, spec in cfg.addons.items():
|
|
4431
|
+
dest = _validate_local_addon_path(layout, addon_name, spec)
|
|
4432
|
+
if sync_addons:
|
|
4390
4433
|
if spec.is_local:
|
|
4391
4434
|
_logger.info(
|
|
4392
4435
|
"Using local addon path for [%s]: %s (skipping git sync)",
|
|
@@ -4403,20 +4446,13 @@ def _sync_addon_sources(
|
|
|
4403
4446
|
)
|
|
4404
4447
|
_sync_git_source(dest, spec)
|
|
4405
4448
|
|
|
4406
|
-
|
|
4407
|
-
|
|
4449
|
+
modules_path = _resolve_addon_modules_path(layout, addon_name, spec)
|
|
4450
|
+
addon_req = modules_path / "requirements.txt"
|
|
4451
|
+
if addon_req.exists():
|
|
4452
|
+
_logger.info("Using requirements.txt for [addons.%s]: %s", addon_name, addon_req)
|
|
4453
|
+
if sync_addons or venv_py is not None:
|
|
4408
4454
|
req_files.append(addon_req)
|
|
4409
|
-
|
|
4410
|
-
else:
|
|
4411
|
-
# If we're provisioning Python or generating Docker artifacts, use existing addon requirements (if present).
|
|
4412
|
-
if (venv_py is not None or docker_requested) and cfg.addons:
|
|
4413
|
-
for addon_name, spec in cfg.addons.items():
|
|
4414
|
-
dest = _validate_local_addon_path(layout, addon_name, spec)
|
|
4415
|
-
addon_req = dest / "requirements.txt"
|
|
4416
|
-
if addon_req.exists():
|
|
4417
|
-
if venv_py is not None:
|
|
4418
|
-
req_files.append(addon_req)
|
|
4419
|
-
addon_req_files.append(addon_req)
|
|
4455
|
+
addon_req_files.append(addon_req)
|
|
4420
4456
|
|
|
4421
4457
|
return req_files, addon_req_files
|
|
4422
4458
|
|
|
@@ -4585,7 +4621,7 @@ def _generate_native_artifacts(layout: Layout, cfg: ProjectConfig, options: Setu
|
|
|
4585
4621
|
# Generate config (unless disabled).
|
|
4586
4622
|
if options.target == "venv" and not options.no_configs:
|
|
4587
4623
|
addon_paths: list[Path] = [
|
|
4588
|
-
|
|
4624
|
+
_resolve_addon_modules_path(layout, addon_name, spec)
|
|
4589
4625
|
for addon_name, spec in cfg.addons.items()
|
|
4590
4626
|
]
|
|
4591
4627
|
conf_text = render_odoo_conf(cfg.config, layout, addon_paths)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: odoo-devops-tools
|
|
3
|
-
Version: 1.27.
|
|
3
|
+
Version: 1.27.4
|
|
4
4
|
Summary: Build reproducible Odoo workspaces from a single project definition.
|
|
5
5
|
Author: Roman Lacko
|
|
6
6
|
License-Expression: MIT
|
|
@@ -208,7 +208,7 @@ odoo-compose docker setup --sync
|
|
|
208
208
|
odoo-compose docker up --build
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
The repositories are cloned into `ROOT/odoo-addons/` and bind-mounted into the Odoo container. Python dependencies from
|
|
211
|
+
The repositories are cloned into `ROOT/odoo-addons/` and bind-mounted into the Odoo container. Python dependencies from the selected addon directories' `requirements.txt` files are included when rebuilding the Docker image.
|
|
212
212
|
|
|
213
213
|
Install the new modules:
|
|
214
214
|
|
|
@@ -414,7 +414,7 @@ Sync the addon repositories and recreate the Python environment to include their
|
|
|
414
414
|
odoo-compose venv setup --sync --create-venv
|
|
415
415
|
```
|
|
416
416
|
|
|
417
|
-
The repositories are cloned into `ROOT/odoo-addons/` and automatically added to the generated `addons_path`. Python dependencies from
|
|
417
|
+
The repositories are cloned into `ROOT/odoo-addons/` and automatically added to the generated `addons_path`. Python dependencies from the selected addon directories' `requirements.txt` files are included in the virtual environment.
|
|
418
418
|
|
|
419
419
|
Install the new modules:
|
|
420
420
|
|
|
@@ -467,7 +467,7 @@ This recreates the virtual environment at `ROOT/venv` using the system Python.
|
|
|
467
467
|
|
|
468
468
|
The `[virtualenv]` section controls additional Python dependencies used when provisioning both the native virtual environment and generated Docker images.
|
|
469
469
|
|
|
470
|
-
Use it to add new packages, pin specific versions, and override packages collected from Odoo or addon
|
|
470
|
+
Use it to add new packages, pin specific versions, and override packages collected from Odoo or addon directory `requirements.txt` files.
|
|
471
471
|
|
|
472
472
|
Use:
|
|
473
473
|
|
|
@@ -1576,33 +1576,80 @@ path = ../odoo
|
|
|
1576
1576
|
|
|
1577
1577
|
Addon sections are optional. You can define as many as needed.
|
|
1578
1578
|
|
|
1579
|
+
- `path` — local directory containing Odoo addons. Relative paths are resolved relative to `ROOT/`.
|
|
1580
|
+
- `repo` — Git repository URL. Required for Git-managed addons.
|
|
1581
|
+
- `branch` — Git branch to check out. Required for Git-managed addons.
|
|
1582
|
+
- `commit` — optional Git commit. When set, the repository is pinned to that exact revision.
|
|
1583
|
+
- `shallow` — whether to use a shallow clone. Default: `true`. Ignored when `commit` is set.
|
|
1584
|
+
- `subdirectory` — optional directory containing Odoo addons, relative to the Git repository root. Default: `.` (repository root). Use `/` separators on every platform. The directory must exist when used. Absolute paths, parent traversal and paths resolving outside the repository are not allowed.
|
|
1585
|
+
|
|
1579
1586
|
Each addon must use exactly one of these source types:
|
|
1580
1587
|
|
|
1581
1588
|
- local addon path: `path`
|
|
1582
|
-
- Git repository: `repo` + `branch` (+ optional `commit` and `
|
|
1589
|
+
- Git repository: `repo` + `branch` (+ optional `commit`, `shallow` and `subdirectory`)
|
|
1583
1590
|
|
|
1584
|
-
|
|
1591
|
+
Git repositories are cloned into `ROOT/odoo-addons/<name>/`, and the selected addon directory is added to the generated `addons_path`.
|
|
1585
1592
|
|
|
1586
|
-
|
|
1587
|
-
- For a Git addon, `repo` and `branch` are required.
|
|
1588
|
-
- `commit` is optional for a Git addon. When set, the repository is pinned to that exact revision.
|
|
1589
|
-
- `shallow` is optional for Git addons and defaults to `true`. It is ignored when `commit` is set.
|
|
1590
|
-
- Relative local paths are resolved relative to `ROOT/`.
|
|
1591
|
-
- Git-based addons are cloned into `ROOT/odoo-addons/<name>/`.
|
|
1592
|
-
- All configured addon directories are automatically appended to the generated `addons_path`.
|
|
1593
|
-
|
|
1594
|
-
Examples:
|
|
1593
|
+
Example of Git-managed addons in subdirectories:
|
|
1595
1594
|
|
|
1596
1595
|
```ini
|
|
1597
|
-
[addons.
|
|
1598
|
-
|
|
1596
|
+
[addons.custom]
|
|
1597
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1598
|
+
branch = ${odoo:version}
|
|
1599
|
+
subdirectory = addons
|
|
1599
1600
|
|
|
1600
|
-
[addons.oca-web]
|
|
1601
|
-
repo = https://github.com/
|
|
1601
|
+
[addons.3rd-party-oca-web]
|
|
1602
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1603
|
+
branch = ${odoo:version}
|
|
1604
|
+
subdirectory = 3rd-party/oca-web
|
|
1605
|
+
|
|
1606
|
+
[addons.3rd-party-muk-it]
|
|
1607
|
+
repo = https://github.com/my-company/odoo-addons.git
|
|
1602
1608
|
branch = ${odoo:version}
|
|
1603
|
-
|
|
1609
|
+
subdirectory = 3rd-party/muk-it
|
|
1604
1610
|
```
|
|
1605
1611
|
|
|
1612
|
+
Expected directory layout (relevant subdirectories only):
|
|
1613
|
+
|
|
1614
|
+
```text
|
|
1615
|
+
ROOT/odoo-addons/
|
|
1616
|
+
├── custom/
|
|
1617
|
+
│ └── addons/
|
|
1618
|
+
│ ├── requirements.txt
|
|
1619
|
+
│ ├── custom_sale/
|
|
1620
|
+
│ │ └── __manifest__.py
|
|
1621
|
+
│ └── custom_stock/
|
|
1622
|
+
│ └── __manifest__.py
|
|
1623
|
+
├── 3rd-party-oca-web/
|
|
1624
|
+
│ └── 3rd-party/
|
|
1625
|
+
│ └── oca-web/
|
|
1626
|
+
│ ├── requirements.txt
|
|
1627
|
+
│ ├── web_environment_ribbon/
|
|
1628
|
+
│ │ └── __manifest__.py
|
|
1629
|
+
│ └── web_responsive/
|
|
1630
|
+
│ └── __manifest__.py
|
|
1631
|
+
└── 3rd-party-muk-it/
|
|
1632
|
+
└── 3rd-party/
|
|
1633
|
+
└── muk-it/
|
|
1634
|
+
├── muk_ai/
|
|
1635
|
+
│ └── __manifest__.py
|
|
1636
|
+
├── muk_ai_automation/
|
|
1637
|
+
│ └── __manifest__.py
|
|
1638
|
+
└── muk_mcp/
|
|
1639
|
+
└── __manifest__.py
|
|
1640
|
+
```
|
|
1641
|
+
|
|
1642
|
+
Generated addon paths (excluding standard Odoo paths):
|
|
1643
|
+
|
|
1644
|
+
```text
|
|
1645
|
+
ROOT/odoo-addons/custom/addons
|
|
1646
|
+
ROOT/odoo-addons/3rd-party-oca-web/3rd-party/oca-web
|
|
1647
|
+
ROOT/odoo-addons/3rd-party-muk-it/3rd-party/muk-it
|
|
1648
|
+
```
|
|
1649
|
+
|
|
1650
|
+
The same Git repository can be configured multiple times using distinct
|
|
1651
|
+
addon source names, branches, and subdirectories.
|
|
1652
|
+
|
|
1606
1653
|
### `[docker]`
|
|
1607
1654
|
|
|
1608
1655
|
This section is optional.
|
|
@@ -62,3 +62,24 @@ class WorkspaceTest(unittest.TestCase):
|
|
|
62
62
|
|
|
63
63
|
def setup_ws(self, workflow="venv", *args, **kw) -> str:
|
|
64
64
|
return ok(self.invoke(workflow, "setup", "--no-provisioning-log", *args, **kw))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def write_addon_project(root, addon_options):
|
|
68
|
+
ini = root / "odoo-project.ini"
|
|
69
|
+
ini.write_text(
|
|
70
|
+
"[odoo]\nversion = 19.0\n[addons.company]\n" + addon_options,
|
|
71
|
+
encoding="utf-8",
|
|
72
|
+
)
|
|
73
|
+
return ini
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def make_nested_addons(source):
|
|
77
|
+
modules = source / "src/addons"
|
|
78
|
+
for directory in (modules / "nested_module", source / "root_module"):
|
|
79
|
+
directory.mkdir(parents=True)
|
|
80
|
+
(directory / "__manifest__.py").write_text("{'name': 'test'}", encoding="utf-8")
|
|
81
|
+
(source / "requirements.txt").write_text("root-package==1\n", encoding="utf-8")
|
|
82
|
+
(modules / "requirements.txt").write_text("nested-package==2\n", encoding="utf-8")
|
|
83
|
+
(source / "src/requirements.txt").write_text("intermediate-package==3\n", encoding="utf-8")
|
|
84
|
+
(modules / "nested_module/requirements.txt").write_text("module-package==4\n", encoding="utf-8")
|
|
85
|
+
return modules
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Portable bundle creation, integrity checks and offline restoration."""
|
|
2
2
|
|
|
3
|
+
import configparser
|
|
3
4
|
import hashlib
|
|
4
5
|
import json
|
|
5
6
|
from pathlib import Path
|
|
@@ -8,6 +9,9 @@ import zipfile
|
|
|
8
9
|
|
|
9
10
|
import pytest
|
|
10
11
|
|
|
12
|
+
from odoo_devops_tools import odoo_compose as odt
|
|
13
|
+
from tests.common import cli, ok, make_nested_addons, write_addon_project
|
|
14
|
+
from tests.test_git import create_repo, git
|
|
11
15
|
from tests.conftest import command
|
|
12
16
|
from tests.integration_support import (
|
|
13
17
|
cli as e2e_cli, expect_modules, pg, require, run_scenario, write_ini,
|
|
@@ -82,5 +86,45 @@ def test_portable_bundle(integration_stack):
|
|
|
82
86
|
"python3", "-m", "tests.test_bundle")
|
|
83
87
|
|
|
84
88
|
|
|
89
|
+
def test_bundle_preserves_subdirectory_and_source_root(tmp_path):
|
|
90
|
+
workspace = tmp_path / "workspace"
|
|
91
|
+
workspace.mkdir()
|
|
92
|
+
source = create_repo(workspace / "odoo-addons/company")
|
|
93
|
+
make_nested_addons(source)
|
|
94
|
+
git(source, "add", ".")
|
|
95
|
+
git(source, "commit", "-qm", "nested addons")
|
|
96
|
+
ini = write_addon_project(workspace, "repo = example.git\nbranch = main\nsubdirectory = src/addons\n")
|
|
97
|
+
cfg = odt.load_project_config(ini, log_resolved=False)
|
|
98
|
+
layout = odt.Layout.from_root(workspace)
|
|
99
|
+
layout.odoo_dir.mkdir()
|
|
100
|
+
(layout.odoo_dir / "odoo-bin").touch()
|
|
101
|
+
layout.wheelhouse_dir.mkdir()
|
|
102
|
+
(layout.wheelhouse_dir / "all-requirements.lock.txt").touch()
|
|
103
|
+
archive = odt.create_workspace_bundle(layout=layout, cfg=cfg, ini_path=ini,
|
|
104
|
+
output_path=tmp_path / "bundle.zip", vars_overrides=None, ini_overrides=None, allow_dirty=False)
|
|
105
|
+
imported = tmp_path / "imported"
|
|
106
|
+
imported_ini, _ = odt.extract_workspace_bundle(archive, imported)
|
|
107
|
+
imported_cfg = odt.load_project_config(imported_ini, log_resolved=False)
|
|
108
|
+
spec = imported_cfg.addons["company"]
|
|
109
|
+
assert spec.path == "odoo-addons/company/src/addons"
|
|
110
|
+
assert spec.subdirectory == "."
|
|
111
|
+
assert spec.is_local
|
|
112
|
+
assert "subdirectory" not in imported_ini.read_text()
|
|
113
|
+
imported_layout = odt.Layout.from_root(imported)
|
|
114
|
+
root = imported / "odoo-addons/company"
|
|
115
|
+
assert (root / "root_module/__manifest__.py").is_file()
|
|
116
|
+
assert (root / "requirements.txt").is_file()
|
|
117
|
+
modules = odt._resolve_addon_modules_path(imported_layout, "company", spec)
|
|
118
|
+
assert modules == (root / "src/addons").resolve()
|
|
119
|
+
assert (modules / "nested_module/__manifest__.py").is_file()
|
|
120
|
+
reqs, addon_reqs = odt._sync_addon_sources(imported_layout, imported_cfg, False, Path("python"), False)
|
|
121
|
+
assert reqs == addon_reqs == [modules / "requirements.txt"]
|
|
122
|
+
assert (imported_layout.wheelhouse_dir / "all-requirements.lock.txt").is_file()
|
|
123
|
+
ok(cli("venv", "setup", "--root", imported, "--no-provisioning-log"))
|
|
124
|
+
conf = configparser.ConfigParser()
|
|
125
|
+
conf.read(imported / "odoo-configs/odoo-server.conf", encoding="utf-8")
|
|
126
|
+
assert str(modules) in conf.get("options", "addons_path").split(",")
|
|
127
|
+
|
|
128
|
+
|
|
85
129
|
if __name__ == "__main__":
|
|
86
130
|
run_scenario(bundle)
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import configparser
|
|
6
|
+
import logging
|
|
5
7
|
from pathlib import Path
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from odoo_devops_tools import odoo_compose as odt
|
|
12
|
+
|
|
13
|
+
from tests.common import DEFAULT_INI, WorkspaceTest, cli, fails, ok, run, make_nested_addons, write_addon_project
|
|
8
14
|
|
|
9
15
|
GIT_ENV = dict(GIT_AUTHOR_NAME="CI", GIT_AUTHOR_EMAIL="ci@example.test", GIT_COMMITTER_NAME="CI", GIT_COMMITTER_EMAIL="ci@example.test", GIT_CONFIG_COUNT="1", GIT_CONFIG_KEY_0="maintenance.auto", GIT_CONFIG_VALUE_0="false")
|
|
10
16
|
|
|
@@ -150,3 +156,110 @@ class GitSourceSelection(WorkspaceTest):
|
|
|
150
156
|
git(publisher, "push", "-q", "origin", "main")
|
|
151
157
|
fails(self.invoke("docker", "setup", "--sync", "--no-provisioning-log"), "Refusing to reset local Git branch")
|
|
152
158
|
self.assertEqual(git(checkout, "rev-parse", "HEAD").strip(), new_tip)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def test_nested_addon_cli_workflows(tmp_path):
|
|
162
|
+
source = create_repo(tmp_path / "repository")
|
|
163
|
+
make_nested_addons(source)
|
|
164
|
+
git(source, "add", ".")
|
|
165
|
+
git(source, "commit", "-qm", "nested addons")
|
|
166
|
+
options = f"repo = {source.as_posix()}\nbranch = main\n"
|
|
167
|
+
|
|
168
|
+
workspace = tmp_path / "workspace"
|
|
169
|
+
workspace.mkdir()
|
|
170
|
+
# Exercise --set on the actual CLI; setup must persist the option for later use.
|
|
171
|
+
ini = write_addon_project(workspace, options)
|
|
172
|
+
output = ok(cli("docker", "setup", "--root", workspace, "--sync-addons", "--create-docker-deploy",
|
|
173
|
+
"--set", "addons.company:subdirectory=src/addons", "--no-provisioning-log"))
|
|
174
|
+
root = workspace / "odoo-addons/company"
|
|
175
|
+
assert (root / "root_module/__manifest__.py").is_file()
|
|
176
|
+
assert (root / ".git").is_dir()
|
|
177
|
+
assert f"Using requirements.txt for [addons.company]: {root.resolve() / 'src/addons/requirements.txt'}" in output
|
|
178
|
+
assert "Ignoring requirements.txt" not in output
|
|
179
|
+
layout = odt.Layout.from_root(workspace)
|
|
180
|
+
cfg = odt.load_project_config(ini, log_resolved=False)
|
|
181
|
+
assert cfg.addons["company"].subdirectory == "src/addons"
|
|
182
|
+
expected = root / "src/addons"
|
|
183
|
+
mount = odt._compose_host_path(layout, expected)
|
|
184
|
+
compose = (workspace / "compose.yaml").read_text()
|
|
185
|
+
assert f'source: "{mount}"' in compose
|
|
186
|
+
assert f'target: "{odt._DOCKER_ADDONS_CONTAINER_ROOT}/company"' in compose
|
|
187
|
+
assert f"addons_path = {odt._DOCKER_ADDONS_CONTAINER_ROOT}/company" in (
|
|
188
|
+
workspace / "docker/local/configs/odoo.conf").read_text()
|
|
189
|
+
assert (workspace / "docker/deploy/addons/nested_module/__manifest__.py").is_file()
|
|
190
|
+
assert not (workspace / "docker/deploy/addons/root_module").exists()
|
|
191
|
+
for context in ("local", "deploy"):
|
|
192
|
+
reqs = (workspace / f"docker/{context}/requirements/all-requirements.in.txt").read_text()
|
|
193
|
+
assert "nested-package==2" in reqs
|
|
194
|
+
for ignored in ("root-package", "intermediate-package", "module-package"):
|
|
195
|
+
assert ignored not in reqs
|
|
196
|
+
|
|
197
|
+
# Without syncing again, native setup must reuse the existing directory and dependencies.
|
|
198
|
+
ok(cli("venv", "setup", "--root", workspace, "--no-provisioning-log"))
|
|
199
|
+
conf = configparser.ConfigParser()
|
|
200
|
+
conf.read(workspace / "odoo-configs/odoo-server.conf", encoding="utf-8")
|
|
201
|
+
paths = conf.get("options", "addons_path").split(",")
|
|
202
|
+
assert str(expected.resolve()) in paths
|
|
203
|
+
assert str(root.resolve()) not in paths
|
|
204
|
+
reqs, addon_reqs = odt._sync_addon_sources(layout, cfg, False, Path("python"), False)
|
|
205
|
+
assert reqs == addon_reqs == [expected.resolve() / "requirements.txt"]
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def test_root_requirements_collected_only_once(tmp_path):
|
|
209
|
+
source = tmp_path / "local"
|
|
210
|
+
make_nested_addons(source)
|
|
211
|
+
ini = write_addon_project(tmp_path, "path = local\n")
|
|
212
|
+
cfg = odt.load_project_config(ini, log_resolved=False)
|
|
213
|
+
reqs, addon_reqs = odt._sync_addon_sources(odt.Layout.from_root(tmp_path), cfg, True, None, False)
|
|
214
|
+
assert reqs == addon_reqs == [source.resolve() / "requirements.txt"]
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_local_path_directly_selects_addons(tmp_path):
|
|
218
|
+
source = tmp_path / "local"
|
|
219
|
+
modules = make_nested_addons(source)
|
|
220
|
+
ini = write_addon_project(tmp_path, "path = local/src/addons\n")
|
|
221
|
+
layout = odt.Layout.from_root(tmp_path)
|
|
222
|
+
cfg = odt.load_project_config(ini, log_resolved=False)
|
|
223
|
+
assert odt._resolve_addon_modules_path(layout, "company", cfg.addons["company"]) == modules.resolve()
|
|
224
|
+
reqs, addon_reqs = odt._sync_addon_sources(layout, cfg, True, None, False)
|
|
225
|
+
assert reqs == addon_reqs == [modules.resolve() / "requirements.txt"]
|
|
226
|
+
ok(cli("docker", "setup", "--root", tmp_path, "--create-docker-deploy", "--no-provisioning-log"))
|
|
227
|
+
assert (tmp_path / "docker/deploy/addons/nested_module/__manifest__.py").is_file()
|
|
228
|
+
assert not (tmp_path / "docker/deploy/addons/root_module").exists()
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@pytest.mark.parametrize("source_type", ["repo", "repo-subdirectory", "local"])
|
|
232
|
+
@pytest.mark.parametrize("selected_exists", [True, False])
|
|
233
|
+
def test_only_selected_requirements_are_collected(tmp_path, caplog, monkeypatch, source_type, selected_exists):
|
|
234
|
+
source = tmp_path / "odoo-addons/company"
|
|
235
|
+
nested = make_nested_addons(source)
|
|
236
|
+
if source_type == "repo":
|
|
237
|
+
options = "repo = example.git\nbranch = main\n"
|
|
238
|
+
selected = source
|
|
239
|
+
elif source_type == "repo-subdirectory":
|
|
240
|
+
options = "repo = example.git\nbranch = main\nsubdirectory = src/addons\n"
|
|
241
|
+
selected = nested
|
|
242
|
+
else:
|
|
243
|
+
options = "path = odoo-addons/company/src/addons\n"
|
|
244
|
+
selected = nested
|
|
245
|
+
selected_req = selected / "requirements.txt"
|
|
246
|
+
if not selected_exists:
|
|
247
|
+
selected_req.unlink()
|
|
248
|
+
ini = write_addon_project(tmp_path, options)
|
|
249
|
+
cfg = odt.load_project_config(ini, log_resolved=False)
|
|
250
|
+
layout = odt.Layout.from_root(tmp_path)
|
|
251
|
+
def unexpected_walk(*args, **kwargs):
|
|
252
|
+
pytest.fail("Addon requirements collection must not scan the source tree")
|
|
253
|
+
|
|
254
|
+
with monkeypatch.context() as patch, caplog.at_level(logging.INFO, logger=odt._logger.name):
|
|
255
|
+
patch.setattr(odt.os, "walk", unexpected_walk)
|
|
256
|
+
reqs, addon_reqs = odt._sync_addon_sources(layout, cfg, False, Path("python"), True)
|
|
257
|
+
assert reqs == addon_reqs == ([selected_req.resolve()] if selected_exists else [])
|
|
258
|
+
|
|
259
|
+
records = [record for record in caplog.records
|
|
260
|
+
if "requirements.txt" in record.getMessage()]
|
|
261
|
+
assert [record.getMessage() for record in records] == (
|
|
262
|
+
[f"Using requirements.txt for [addons.company]: {selected_req.resolve()}"]
|
|
263
|
+
if selected_exists else []
|
|
264
|
+
)
|
|
265
|
+
assert all(record.levelno == logging.INFO for record in records)
|
|
@@ -7,7 +7,10 @@ import unittest
|
|
|
7
7
|
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
|
8
8
|
import threading
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from odoo_devops_tools import odoo_compose as odt
|
|
13
|
+
from tests.common import DEFAULT_INI, WorkspaceTest, cli, fails, ok, make_nested_addons, write_addon_project
|
|
11
14
|
from tests.test_git import git
|
|
12
15
|
|
|
13
16
|
|
|
@@ -185,3 +188,65 @@ class IniSourceTests(WorkspaceTest):
|
|
|
185
188
|
self.assertEqual(__import__("json").loads(state.read_text())["status"], "success")
|
|
186
189
|
output = ok(self.invoke("venv", "setup", "--show-last-run"))
|
|
187
190
|
self.assertIn("success", output)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
@pytest.mark.parametrize("option,expected", [("", "."), ("subdirectory = .\n", "."),
|
|
194
|
+
("subdirectory =\n", "."), ("subdirectory = ./src/addons/\n", "src/addons")])
|
|
195
|
+
def test_subdirectory_default_and_normalization(tmp_path, option, expected):
|
|
196
|
+
ini = write_addon_project(tmp_path, "repo = example.git\nbranch = main\n" + option)
|
|
197
|
+
cfg = odt.load_project_config(ini, log_resolved=False)
|
|
198
|
+
assert cfg.addons["company"].subdirectory == expected
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@pytest.mark.parametrize("value", ["../addons", "src/../addons", "/addons", "//host/share",
|
|
202
|
+
"C:/addons", "C:addons", r"src\addons", "src/.. /addons", "src/addons."])
|
|
203
|
+
def test_unsafe_subdirectory(tmp_path, value):
|
|
204
|
+
ini = write_addon_project(tmp_path, f"repo = example.git\nbranch = main\nsubdirectory = {value}\n")
|
|
205
|
+
with pytest.raises(Exception, match="Invalid option 'subdirectory'"):
|
|
206
|
+
odt.load_project_config(ini, log_resolved=False)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@pytest.mark.parametrize("kind", ["missing", "file"])
|
|
210
|
+
def test_subdirectory_must_be_existing_directory(tmp_path, kind):
|
|
211
|
+
source = tmp_path / "odoo-addons/company"
|
|
212
|
+
source.mkdir(parents=True)
|
|
213
|
+
if kind == "file":
|
|
214
|
+
(source / "addons").touch()
|
|
215
|
+
ini = write_addon_project(tmp_path, "repo = example.git\nbranch = main\nsubdirectory = addons\n")
|
|
216
|
+
cfg = odt.load_project_config(ini, log_resolved=False)
|
|
217
|
+
with pytest.raises(Exception, match="Addon subdirectory.*(does not exist|not a directory)"):
|
|
218
|
+
odt._resolve_addon_modules_path(odt.Layout.from_root(tmp_path), "company", cfg.addons["company"])
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
@pytest.mark.skipif(os.name == "nt", reason="Windows symlinks require developer-mode privileges")
|
|
222
|
+
def test_subdirectory_symlink_escape(tmp_path):
|
|
223
|
+
source = tmp_path / "odoo-addons/company"
|
|
224
|
+
source.mkdir(parents=True)
|
|
225
|
+
outside = tmp_path / "outside"
|
|
226
|
+
outside.mkdir()
|
|
227
|
+
(source / "addons").symlink_to(outside, target_is_directory=True)
|
|
228
|
+
ini = write_addon_project(tmp_path, "repo = example.git\nbranch = main\nsubdirectory = addons\n")
|
|
229
|
+
cfg = odt.load_project_config(ini, log_resolved=False)
|
|
230
|
+
with pytest.raises(Exception, match="Unsafe subdirectory"):
|
|
231
|
+
odt._resolve_addon_modules_path(odt.Layout.from_root(tmp_path), "company", cfg.addons["company"])
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
@pytest.mark.parametrize("value", ["src/addons", ".", ""])
|
|
235
|
+
def test_local_path_rejects_subdirectory(tmp_path, value):
|
|
236
|
+
ini = write_addon_project(tmp_path, f"path = local\nsubdirectory = {value}\n")
|
|
237
|
+
with pytest.raises(Exception, match="'subdirectory' can only be used with 'repo'"):
|
|
238
|
+
odt.load_project_config(ini, log_resolved=False)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def test_subdirectory_requires_repo(tmp_path):
|
|
242
|
+
ini = write_addon_project(tmp_path, "subdirectory = src/addons\n")
|
|
243
|
+
with pytest.raises(Exception, match="'subdirectory' can only be used with 'repo'"):
|
|
244
|
+
odt.load_project_config(ini, log_resolved=False)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def test_local_path_rejects_subdirectory_override(tmp_path):
|
|
248
|
+
make_nested_addons(tmp_path / "local")
|
|
249
|
+
write_addon_project(tmp_path, "path = local/src/addons\n")
|
|
250
|
+
fails(cli("docker", "setup", "--root", tmp_path,
|
|
251
|
+
"--set", "addons.company:subdirectory=src/addons",
|
|
252
|
+
"--no-provisioning-log"), "'subdirectory' can only be used with 'repo'")
|
|
File without changes
|
|
File without changes
|
{odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{odoo_devops_tools-1.27.3 → odoo_devops_tools-1.27.4}/odoo_devops_tools.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|