You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/06/24 13:13:35 UTC

(tooling-trusted-releases) branch sbp updated (df1fee3c -> 76a745aa)

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

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


    from df1fee3c Recognise SBOM files named using the Maven plugin convention
     add c4ca0470 #1333 - include date of release in artifact model and add boolean for ATR-managed releases.
     new 76a745aa Limit how many nested files can be published in a release

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 atr/models/api.py                               |  9 ++++
 atr/models/sql.py                               |  9 ++++
 atr/shared/catalog.py                           |  3 ++
 atr/storage/writers/announce.py                 | 10 +++-
 atr/storage/writers/release.py                  |  9 ++--
 atr/tasks/checks/paths.py                       | 33 ++++++++++++-
 atr/templates/_catalog_version.html             |  2 +-
 migrations/versions/0097_2026.06.24_6741a40a.py | 31 ++++++++++++
 tests/unit/test_catalog.py                      | 28 +++++++++++
 tests/unit/test_documentation_tree_check.py     | 63 +++++++++++++++++++++++++
 10 files changed, 190 insertions(+), 7 deletions(-)
 create mode 100644 migrations/versions/0097_2026.06.24_6741a40a.py
 create mode 100644 tests/unit/test_documentation_tree_check.py


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


(tooling-trusted-releases) 01/01: Limit how many nested files can be published in a release

Posted by sb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 76a745aaa811862b820b708c4a96d85a227df78a
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Wed Jun 24 14:13:18 2026 +0100

    Limit how many nested files can be published in a release
---
 atr/tasks/checks/paths.py                   | 33 ++++++++++++++-
 tests/unit/test_documentation_tree_check.py | 63 +++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/atr/tasks/checks/paths.py b/atr/tasks/checks/paths.py
index ce847dab..96080f73 100644
--- a/atr/tasks/checks/paths.py
+++ b/atr/tasks/checks/paths.py
@@ -39,10 +39,11 @@ _ALLOWED_TOP_LEVEL_SUFFIXES: Final = ("", ".adoc", ".md", ".rst", ".txt")
 _ALLOWED_TOP_LEVEL: Final = frozenset(
     (name + suffix) for name in _ALLOWED_TOP_LEVEL_NAMES for suffix in _ALLOWED_TOP_LEVEL_SUFFIXES
 )
+_DOC_TREE_MAX_FILES: Final = 512
 # Release policy fields which this check relies on - used for result caching
 INPUT_POLICY_KEYS: Final[list[str]] = ["binary_artifact_paths", "source_artifact_paths"]
 INPUT_EXTRA_ARGS: Final[list[str]] = ["is_podling", "all_files"]
-CHECK_VERSION: Final[str] = "4"
+CHECK_VERSION: Final[str] = "5"
 
 
 async def check(args: checks.FunctionArguments) -> results.Results | None:
@@ -113,6 +114,7 @@ async def check(args: checks.FunctionArguments) -> results.Results | None:
         )
 
     await _check_source_artifact_present(args, recorder_problems, relative_paths, base_path)
+    await _check_documentation_tree(recorder_problems, relative_paths)
 
     return None
 
@@ -149,6 +151,25 @@ async def _check_artifact_rules(
             blockers.append("Podling artifact filenames must include 'incubating'")
 
 
+async def _check_documentation_tree(
+    recorder_problems: checks.Recorder,
+    relative_paths: list[safe.RelPath],
+) -> None:
+    bundled = [path for path in relative_paths if _is_bundled_doc(path)]
+    if len(bundled) <= _DOC_TREE_MAX_FILES:
+        return
+    await recorder_problems.blocker(
+        f"Release bundles {len(bundled)} files, which exceeds the limit of {_DOC_TREE_MAX_FILES}. "
+        "If these files are documentation, please publish them to the project website instead.",
+        {
+            "doc_file_count": len(bundled),
+            "limit": _DOC_TREE_MAX_FILES,
+            "examples": [str(path) for path in bundled[:5]],
+        },
+        primary_rel_path=None,
+    )
+
+
 async def _check_metadata_rules(
     _base_path: safe.StatePath,
     relative_path: safe.RelPath,
@@ -360,6 +381,16 @@ async def _check_source_artifact_present(
         )
 
 
+def _is_bundled_doc(relative_path: safe.RelPath) -> bool:
+    if len(relative_path.as_path().parts) <= 1:
+        return False
+    path_str = str(relative_path)
+    search = re.search(analysis.extension_pattern(), path_str)
+    if search and (search.group("artifact") or search.group("metadata")):
+        return False
+    return not any(path_str.endswith(suffix) for suffix in analysis.STANDALONE_METADATA_SUFFIXES)
+
+
 async def _record(
     recorder_problems: checks.Recorder,
     recorder_suggestions: checks.Recorder,
diff --git a/tests/unit/test_documentation_tree_check.py b/tests/unit/test_documentation_tree_check.py
new file mode 100644
index 00000000..3179443c
--- /dev/null
+++ b/tests/unit/test_documentation_tree_check.py
@@ -0,0 +1,63 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import pytest
+
+import atr.models.safe as safe
+import atr.tasks.checks.paths as paths
+from tests.unit.recorders import RecorderStub
+
+
+@pytest.mark.asyncio
+async def test_artifact_tree_within_limit_records_no_blocker(tmp_path):
+    recorder = _recorder(tmp_path)
+    relative_paths = []
+    for i in range(300):
+        stem = f"binaries/lang-{i}/apache-openoffice-4.1.16-{i}.tar.gz"
+        relative_paths += [safe.RelPath(stem), safe.RelPath(stem + ".asc"), safe.RelPath(stem + ".sha512")]
+    await paths._check_documentation_tree(recorder, relative_paths)
+    assert recorder.messages == []
+
+
+@pytest.mark.asyncio
+async def test_bundled_docs_over_limit_records_blocker(tmp_path):
+    recorder = _recorder(tmp_path)
+    relative_paths = [safe.RelPath(f"javadoc/page-{i}.html") for i in range(paths._DOC_TREE_MAX_FILES + 1)]
+    await paths._check_documentation_tree(recorder, relative_paths)
+    blockers = [(s, m) for s, m, _ in recorder.messages if s == "blocker"]
+    assert len(blockers) == 1
+    assert "documentation" in blockers[0][1]
+
+
+@pytest.mark.asyncio
+async def test_bundled_docs_within_limit_records_no_blocker(tmp_path):
+    recorder = _recorder(tmp_path)
+    relative_paths = [safe.RelPath(f"docs/page-{i}.html") for i in range(paths._DOC_TREE_MAX_FILES)]
+    await paths._check_documentation_tree(recorder, relative_paths)
+    assert recorder.messages == []
+
+
+def test_is_bundled_doc_excludes_artifacts_metadata_and_top_level():
+    assert paths._is_bundled_doc(safe.RelPath("javadoc/index.html")) is True
+    assert paths._is_bundled_doc(safe.RelPath("binaries/de/app-1.0.tar.gz")) is False
+    assert paths._is_bundled_doc(safe.RelPath("binaries/de/app-1.0.tar.gz.asc")) is False
+    assert paths._is_bundled_doc(safe.RelPath("sub/sbom.cdx.json")) is False
+    assert paths._is_bundled_doc(safe.RelPath("index.html")) is False
+
+
+def _recorder(tmp_path) -> RecorderStub:
+    return RecorderStub(safe.StatePath(tmp_path), "atr.tasks.checks.paths.check_errors", "5")


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