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


The following commit(s) were added to refs/heads/sbp by this push:
     new 87a32fd3 Skip license checks for binary archives
87a32fd3 is described below

commit 87a32fd3554e5554af5a331c5c242fe76dd25764
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Mar 13 14:26:39 2026 +0000

    Skip license checks for binary archives
---
 atr/tasks/checks/license.py       | 16 +++++---
 tests/unit/test_checks_license.py | 80 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/atr/tasks/checks/license.py b/atr/tasks/checks/license.py
index d9673cc3..abef74e7 100644
--- a/atr/tasks/checks/license.py
+++ b/atr/tasks/checks/license.py
@@ -81,7 +81,7 @@ INCLUDED_PATTERNS: Final[list[str]] = [
 # Release policy fields which this check relies on - used for result caching
 INPUT_POLICY_KEYS: Final[list[str]] = ["license_check_mode", 
"source_excludes_lightweight"]
 INPUT_EXTRA_ARGS: Final[list[str]] = ["is_podling"]
-CHECK_VERSION_FILES: Final[str] = "3"
+CHECK_VERSION_FILES: Final[str] = "4"
 CHECK_VERSION_HEADERS: Final[str] = "3"
 
 _MAX_LICENSE_NOTICE_SIZE: Final[int] = 1024 * 1024
@@ -136,10 +136,16 @@ async def files(args: checks.FunctionArguments) -> 
results.Results | None:
         return None
 
     is_binary = await recorder.primary_path_is_binary()
-    if not is_binary:
-        project = await recorder.project()
-        if project.policy_license_check_mode == sql.LicenseCheckMode.RAT:
-            return None
+    if is_binary:
+        log.info(
+            "Skipping license and notice file check for binary artifact "
+            f"{artifact_abs_path} (rel: {args.primary_rel_path})"
+        )
+        return None
+
+    project = await recorder.project()
+    if project.policy_license_check_mode == sql.LicenseCheckMode.RAT:
+        return None
 
     is_podling = args.extra_args.get("is_podling", False)
 
diff --git a/tests/unit/test_checks_license.py 
b/tests/unit/test_checks_license.py
index e9057e12..4353da73 100644
--- a/tests/unit/test_checks_license.py
+++ b/tests/unit/test_checks_license.py
@@ -15,11 +15,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+import datetime
 import pathlib
 import tarfile
+import unittest.mock as mock
+from collections.abc import Awaitable, Callable
+
+import pytest
 
 import atr.constants as constants
 import atr.models.sql as sql
+import atr.tasks.checks as checks
 import atr.tasks.checks.license as license
 
 TEST_ARCHIVE = pathlib.Path(__file__).parent.parent / "e2e" / "test_files" / 
"apache-test-0.2.tar.gz"
@@ -93,6 +99,71 @@ def test_files_valid_license_and_notice(tmp_path):
     assert all(r.status == sql.CheckResultStatus.SUCCESS for r in 
artifact_results)
 
 
+class BinaryRecorder(checks.Recorder):
+    def __init__(self, path: pathlib.Path) -> None:
+        super().__init__(
+            checker="tests.unit.test_checks_license",
+            inputs_hash=None,
+            project_name="test",
+            version_name="0.2.0",
+            revision_number="00001",
+            primary_rel_path="apache-test-0.2-bin.zip",
+            member_rel_path=None,
+            afresh=False,
+        )
+        self._path = path
+        self.messages: list[tuple[str, str, dict | None]] = []
+
+    async def abs_path(self, rel_path: str | None = None) -> pathlib.Path | 
None:
+        return self._path if rel_path is None else self._path / rel_path
+
+    async def primary_path_is_binary(self) -> bool:
+        return True
+
+    async def _add(
+        self,
+        status: sql.CheckResultStatus,
+        message: str,
+        data: object,
+        primary_rel_path: str | None = None,
+        member_rel_path: str | None = None,
+    ) -> sql.CheckResult:
+        self.messages.append((status.value, message, data if isinstance(data, 
dict) else None))
+        return sql.CheckResult(
+            id=0,
+            release_name=self.release_name,
+            revision_number=self.revision_number,
+            checker=self.checker,
+            primary_rel_path=primary_rel_path,
+            member_rel_path=member_rel_path,
+            created=datetime.datetime.now(datetime.UTC),
+            status=status,
+            message=message,
+            data=data,
+            inputs_hash=None,
+        )
+
+
[email protected]
+async def test_files_skip_binary_artifacts(tmp_path: pathlib.Path) -> None:
+    recorder = BinaryRecorder(tmp_path / "apache-test-0.2-bin.zip")
+    args = checks.FunctionArguments(
+        recorder=_get_recorder(recorder),
+        asf_uid="test",
+        project_name="test",
+        version_name="0.2.0",
+        revision_number="00001",
+        primary_rel_path="apache-test-0.2-bin.zip",
+        extra_args={},
+    )
+
+    with mock.patch.object(checks, "resolve_archive_dir", 
new=mock.AsyncMock()) as resolve_archive_dir:
+        await license.files(args)
+
+    resolve_archive_dir.assert_not_awaited()
+    assert recorder.messages == []
+
+
 def test_headers_check_data_fields_match_model(tmp_path):
     cache_dir = _extract_test_archive(tmp_path)
     results = list(license._headers_check_core_logic(cache_dir, 
TEST_ARCHIVE_BASENAME, [], "none"))
@@ -152,3 +223,12 @@ def _extract_test_archive(tmp_path: pathlib.Path) -> 
pathlib.Path:
     with tarfile.open(TEST_ARCHIVE) as tf:
         tf.extractall(cache_dir, filter="data")
     return cache_dir
+
+
+def _get_recorder(
+    recorder: checks.Recorder,
+) -> Callable[[], Awaitable[checks.Recorder]]:
+    async def _recorder() -> checks.Recorder:
+        return recorder
+
+    return _recorder


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to