Skip to content

Commit 6aca574

Browse files
committed
Merge branch 'fix/dependencies_with_registry_url' into 'main'
fix: dependency with registry_url unrecognized correctly See merge request espressif/idf-component-manager!439
2 parents d927cbd + be31fac commit 6aca574

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

idf_component_tools/manifest/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ class DependencyItem(BaseModel):
135135
path: str = None # type: ignore
136136
git: str = None # type: ignore
137137
registry_url: str = Field(
138-
default=None, validation_alias=AliasChoices('service_url', 'registry_url')
138+
default=None,
139+
validation_alias=AliasChoices(
140+
'registry_url',
141+
'service_url',
142+
),
139143
) # type: ignore
140144
rules: t.List[OptionalDependency] = None # type: ignore
141145
matches: t.List[OptionalDependency] = None # type: ignore

idf_component_tools/manifest/schemas.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212

1313
# `if` is aliased
1414
MANIFEST_JSON_SCHEMA = Manifest.model_json_schema(by_alias=True)
15+
# we have one rename in the manifest model
16+
# dependencies-*-service_url-type:string -> dependencies-*-registry_url-type:string
17+
# manually add it in the json schema
18+
MANIFEST_JSON_SCHEMA['$defs']['DependencyItem']['properties']['service_url'] = MANIFEST_JSON_SCHEMA[
19+
'$defs'
20+
]['DependencyItem']['properties']['registry_url']
1521

1622

1723
def _flatten_json_schema_keys(schema, stack=None):

idf_component_tools/sources/web_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ def download_archive(url: str, download_dir: str, save_original_filename: bool =
9797
class WebServiceSource(BaseSource):
9898
registry_url: str = Field(
9999
default=IDF_COMPONENT_REGISTRY_URL,
100-
validation_alias=AliasChoices('service_url', 'registry_url'),
100+
validation_alias=AliasChoices(
101+
'registry_url',
102+
'service_url',
103+
),
101104
) # type: ignore
102105
type: Literal['service'] = 'service' # type: ignore
103106
pre_release: bool = None # type: ignore

tests/test_prepare_dep_dirs.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-License-Identifier: Apache-2.0
3+
import os
4+
import textwrap
5+
from pathlib import Path
6+
7+
import yaml
8+
9+
from idf_component_manager.core import ComponentManager
10+
from idf_component_manager.prepare_components.prepare import _component_list_file
11+
12+
13+
def _generate_lock_file(project_dir: Path, yaml_str: str, build_dir: str = 'build'):
14+
managed_components_list_file = project_dir / build_dir / 'managed_components_list.temp.cmake'
15+
local_components_list_file = project_dir / build_dir / 'local_components_list.temp.yml'
16+
17+
os.makedirs(project_dir / 'main')
18+
(project_dir / 'main' / 'CMakeLists.txt').touch()
19+
20+
(project_dir / 'main' / 'idf_component.yml').write_text(textwrap.dedent(yaml_str))
21+
22+
os.makedirs(project_dir / build_dir)
23+
24+
ComponentManager(
25+
path=str(project_dir),
26+
interface_version=2,
27+
).prepare_dep_dirs(
28+
managed_components_list_file=str(managed_components_list_file),
29+
component_list_file=_component_list_file('build'),
30+
local_components_list_file=str(local_components_list_file),
31+
)
32+
33+
34+
def test_dependencies_with_registry_url(tmp_path, monkeypatch):
35+
monkeypatch.setenv('CI_TESTING_IDF_VERSION', '5.4.0')
36+
monkeypatch.setenv('IDF_TARGET', 'esp32')
37+
monkeypatch.setenv('IDF_PATH', '/tmp')
38+
39+
_generate_lock_file(
40+
tmp_path,
41+
"""
42+
dependencies:
43+
example/cmp:
44+
version: "*"
45+
registry_url: "https://components-staging.espressif.com"
46+
""",
47+
)
48+
49+
assert (tmp_path / 'dependencies.lock').exists()
50+
with open(tmp_path / 'dependencies.lock') as f:
51+
lock_data = yaml.safe_load(f)
52+
53+
assert lock_data['dependencies']['example/cmp']
54+
assert (
55+
lock_data['dependencies']['example/cmp']['source']['registry_url']
56+
== 'https://components-staging.espressif.com'
57+
)
58+
assert lock_data['dependencies']['example/cmp']['source']['type'] == 'service'

0 commit comments

Comments
 (0)