You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by ar...@apache.org on 2026/05/29 15:19:37 UTC

(tooling-trusted-releases) branch arm updated: #139 - Add support for project key to asf.yaml import

This is an automated email from the ASF dual-hosted git repository.

alitheg pushed a commit to branch arm
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/arm by this push:
     new 615cfb10 #139 - Add support for project key to asf.yaml import
615cfb10 is described below

commit 615cfb100e0707ef4ef6d5035a5cdf1c398adc27
Author: Alastair McFarlane <ar...@apache.org>
AuthorDate: Fri May 29 16:19:10 2026 +0100

    #139 - Add support for project key to asf.yaml import
---
 atr/get/projects.py                           | 2 +-
 tests/e2e/projects/test_asf_yaml_roundtrip.py | 8 +++++---
 tests/unit/test_asf_yaml_export.py            | 9 +++++++--
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/atr/get/projects.py b/atr/get/projects.py
index 3598d493..09d2c788 100644
--- a/atr/get/projects.py
+++ b/atr/get/projects.py
@@ -325,7 +325,7 @@ def _asf_yaml_export(project: sql.Project) -> str:
 
 
 def _asf_yaml_metadata(project: sql.Project) -> dict[str, object]:
-    metadata: dict[str, object] = {}
+    metadata: dict[str, object] = {"key": str(project.key)}
     if project.committee_key:
         metadata["committee"] = project.committee_key
     if project.name:
diff --git a/tests/e2e/projects/test_asf_yaml_roundtrip.py b/tests/e2e/projects/test_asf_yaml_roundtrip.py
index 47e72f92..990833b3 100644
--- a/tests/e2e/projects/test_asf_yaml_roundtrip.py
+++ b/tests/e2e/projects/test_asf_yaml_roundtrip.py
@@ -42,6 +42,7 @@ EXPORT_URL: Final[str] = f"/project/yaml/{PROJECT_KEY}"
 SOURCE_YAML: Final[str] = """\
 project:
   metadata:
+    key: test-asfyaml
     committee: test
     name: Apache Test Asfyaml
     short_description: A round-trip fixture project.
@@ -112,13 +113,14 @@ def _delete_project(page: Page) -> None:
 
 
 def _import_payload() -> dict[str, Any]:
-    # Replays what infrastructure-asfyaml does: committee is authored inside the
-    # metadata block but the API expects it at the top level, so pop it out.
+    # Replays what infrastructure-asfyaml does: key and committee are authored inside
+    # the metadata block but the API expects them at the top level, so pop them out.
     block = strictyaml.load(SOURCE_YAML).data["project"]
     metadata = dict(block["metadata"])
+    project_key = metadata.pop("key")
     committee_key = metadata.pop("committee")
     payload: dict[str, Any] = {
-        "project_key": PROJECT_KEY,
+        "project_key": project_key,
         "committee_key": committee_key,
         "project": metadata,
     }
diff --git a/tests/unit/test_asf_yaml_export.py b/tests/unit/test_asf_yaml_export.py
index b356c519..debacb39 100644
--- a/tests/unit/test_asf_yaml_export.py
+++ b/tests/unit/test_asf_yaml_export.py
@@ -24,6 +24,7 @@ import atr.models.sql as sql
 class _FakeProject:
     def __init__(self, recipients=None, **fields):
         defaults = {
+            "key": None,
             "committee_key": None,
             "name": None,
             "description": None,
@@ -50,6 +51,7 @@ class _FakeProject:
 
 def test_export_includes_only_recipient_keys_that_are_set() -> None:
     project = _FakeProject(
+        key="example",
         committee_key="tooling",
         name="Apache Example",
         recipients={sql.RecipientAction.VOTE: {"to": "private@example.apache.org"}},
@@ -61,13 +63,13 @@ def test_export_includes_only_recipient_keys_that_are_set() -> None:
 
 
 def test_export_minimal_project_omits_empty_blocks() -> None:
-    project = _FakeProject(committee_key="tooling", name="Apache Trusted Releases")
+    project = _FakeProject(key="trusted-releases", committee_key="tooling", name="Apache Trusted Releases")
 
     loaded = strictyaml.load(projects._asf_yaml_export(project)).data
 
     assert loaded == {
         "project": {
-            "metadata": {"committee": "tooling", "name": "Apache Trusted Releases"},
+            "metadata": {"key": "trusted-releases", "committee": "tooling", "name": "Apache Trusted Releases"},
             "features": {"atr_sync": "true"},
         }
     }
@@ -75,6 +77,7 @@ def test_export_minimal_project_omits_empty_blocks() -> None:
 
 def test_export_reproduces_every_field() -> None:
     project = _FakeProject(
+        key="trusted-releases",
         committee_key="tooling",
         name="Apache Trusted Releases",
         short_description="A platform for making official ASF software releases.",
@@ -98,6 +101,7 @@ def test_export_reproduces_every_field() -> None:
     assert loaded == {
         "project": {
             "metadata": {
+                "key": "trusted-releases",
                 "committee": "tooling",
                 "name": "Apache Trusted Releases",
                 "short_description": "A platform for making official ASF software releases.",
@@ -122,6 +126,7 @@ def test_export_reproduces_every_field() -> None:
 
 def test_export_splits_comma_joined_columns_into_sequences() -> None:
     project = _FakeProject(
+        key="example",
         committee_key="tooling",
         name="Apache Example",
         categories="data, storage",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org