This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/main by this push:
new 874b60c Allow users to configure between lightweight and RAT checks
874b60c is described below
commit 874b60ca3cea42cb311525d0cdb5c45d2870f2a9
Author: Sean B. Palmer <[email protected]>
AuthorDate: Tue Dec 30 14:46:32 2025 +0000
Allow users to configure between lightweight and RAT checks
---
atr/get/projects.py | 1 +
atr/models/sql.py | 13 ++++++++++
atr/shared/projects.py | 6 +++++
atr/storage/writers/policy.py | 1 +
atr/tasks/checks/license.py | 16 +++++++++---
atr/tasks/checks/rat.py | 6 +++++
migrations/versions/0032_2025.12.30_bb1b64a3.py | 34 +++++++++++++++++++++++++
7 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/atr/get/projects.py b/atr/get/projects.py
index 0f240a8..6fdab15 100644
--- a/atr/get/projects.py
+++ b/atr/get/projects.py
@@ -276,6 +276,7 @@ def _render_compose_form(project: sql.Project) ->
htm.Element:
defaults={
"project_name": project.name,
"source_artifact_paths":
"\n".join(project.policy_source_artifact_paths),
+ "license_check_mode": project.policy_license_check_mode,
"binary_artifact_paths":
"\n".join(project.policy_binary_artifact_paths),
"github_repository_name":
project.policy_github_repository_name or "",
"github_compose_workflow_path":
"\n".join(project.policy_github_compose_workflow_path),
diff --git a/atr/models/sql.py b/atr/models/sql.py
index 5b21220..ea94807 100644
--- a/atr/models/sql.py
+++ b/atr/models/sql.py
@@ -139,6 +139,12 @@ class DistributionPlatform(enum.Enum):
)
+class LicenseCheckMode(str, enum.Enum):
+ BOTH = "Both"
+ LIGHTWEIGHT = "Lightweight"
+ RAT = "RAT"
+
+
class ProjectStatus(str, enum.Enum):
ACTIVE = "active"
DORMANT = "dormant"
@@ -654,6 +660,12 @@ Thanks,
# But the production server has None values
return policy.source_artifact_paths or []
+ @property
+ def policy_license_check_mode(self) -> LicenseCheckMode:
+ if (policy := self.release_policy) is None:
+ return LicenseCheckMode.BOTH
+ return policy.license_check_mode
+
@property
def policy_strict_checking(self) -> bool:
# This is bool, so it should never be None
@@ -997,6 +1009,7 @@ class ReleasePolicy(sqlmodel.SQLModel, table=True):
source_artifact_paths: list[str] = sqlmodel.Field(
default_factory=list, sa_column=sqlalchemy.Column(sqlalchemy.JSON)
)
+ license_check_mode: LicenseCheckMode =
sqlmodel.Field(default=LicenseCheckMode.BOTH)
strict_checking: bool = sqlmodel.Field(default=False)
github_repository_name: str = sqlmodel.Field(default="")
github_compose_workflow_path: list[str] = sqlmodel.Field(
diff --git a/atr/shared/projects.py b/atr/shared/projects.py
index 9619bca..b27dd6f 100644
--- a/atr/shared/projects.py
+++ b/atr/shared/projects.py
@@ -23,6 +23,7 @@ from typing import Annotated, Literal
import pydantic
import atr.form as form
+import atr.models.sql as sql
import atr.util as util
type COMPOSE = Literal["compose"]
@@ -110,6 +111,11 @@ class ComposePolicyForm(form.Form):
"Paths to source artifacts to be included in the release.",
widget=form.Widget.TEXTAREA,
)
+ license_check_mode: form.Enum[sql.LicenseCheckMode] = form.label(
+ "License check mode",
+ "Choose which license checks to run on source artifacts. Lightweight
checks always run on binary artifacts.",
+ widget=form.Widget.RADIO,
+ )
binary_artifact_paths: str = form.label(
"Binary artifact paths",
"Paths to binary artifacts to be included in the release.",
diff --git a/atr/storage/writers/policy.py b/atr/storage/writers/policy.py
index e047d6a..cb71a7d 100644
--- a/atr/storage/writers/policy.py
+++ b/atr/storage/writers/policy.py
@@ -96,6 +96,7 @@ class CommitteeMember(CommitteeParticipant):
_, release_policy = await self.__get_or_create_policy(project_name)
release_policy.source_artifact_paths =
_split_lines(form.source_artifact_paths)
+ release_policy.license_check_mode = form.license_check_mode #
pyright: ignore[reportAttributeAccessIssue]
release_policy.binary_artifact_paths =
_split_lines(form.binary_artifact_paths)
release_policy.github_repository_name =
form.github_repository_name.strip()
release_policy.github_compose_workflow_path =
_split_lines(form.github_compose_workflow_path)
diff --git a/atr/tasks/checks/license.py b/atr/tasks/checks/license.py
index e67c00d..12f28b1 100644
--- a/atr/tasks/checks/license.py
+++ b/atr/tasks/checks/license.py
@@ -127,8 +127,12 @@ async def files(args: checks.FunctionArguments) ->
results.Results | None:
recorder = await args.recorder()
if not (artifact_abs_path := await recorder.abs_path()):
return None
- if await recorder.primary_path_is_binary():
- 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
log.info(f"Checking license files for {artifact_abs_path} (rel:
{args.primary_rel_path})")
@@ -155,8 +159,12 @@ async def headers(args: checks.FunctionArguments) ->
results.Results | None:
recorder = await args.recorder()
if not (artifact_abs_path := await recorder.abs_path()):
return None
- if await recorder.primary_path_is_binary():
- 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 await recorder.check_cache(artifact_abs_path):
log.info(f"Using cached license headers result for {artifact_abs_path}
(rel: {args.primary_rel_path})")
diff --git a/atr/tasks/checks/rat.py b/atr/tasks/checks/rat.py
index 3bce4f5..65840c8 100644
--- a/atr/tasks/checks/rat.py
+++ b/atr/tasks/checks/rat.py
@@ -27,6 +27,7 @@ import atr.archives as archives
import atr.config as config
import atr.log as log
import atr.models.results as results
+import atr.models.sql as sql
import atr.tasks.checks as checks
import atr.util as util
@@ -53,6 +54,11 @@ async def check(args: checks.FunctionArguments) ->
results.Results | None:
log.info(f"Skipping RAT check for binary artifact {artifact_abs_path}
(rel: {args.primary_rel_path})")
return None
+ project = await recorder.project()
+ if project.policy_license_check_mode == sql.LicenseCheckMode.LIGHTWEIGHT:
+ log.info(f"Skipping RAT check for {artifact_abs_path} (mode is
LIGHTWEIGHT)")
+ return None
+
if await recorder.check_cache(artifact_abs_path):
log.info(f"Using cached RAT result for {artifact_abs_path} (rel:
{args.primary_rel_path})")
return None
diff --git a/migrations/versions/0032_2025.12.30_bb1b64a3.py
b/migrations/versions/0032_2025.12.30_bb1b64a3.py
new file mode 100644
index 0000000..5181e66
--- /dev/null
+++ b/migrations/versions/0032_2025.12.30_bb1b64a3.py
@@ -0,0 +1,34 @@
+"""Add a license check mode to release policies
+
+Revision ID: 0032_2025.12.30_bb1b64a3
+Revises: 0031_2025.12.22_0f049a07
+Create Date: 2025-12-30 14:25:09.373904+00:00
+"""
+
+from collections.abc import Sequence
+
+import sqlalchemy as sa
+from alembic import op
+
+# Revision identifiers, used by Alembic
+revision: str = "0032_2025.12.30_bb1b64a3"
+down_revision: str | None = "0031_2025.12.22_0f049a07"
+branch_labels: str | Sequence[str] | None = None
+depends_on: str | Sequence[str] | None = None
+
+
+def upgrade() -> None:
+ with op.batch_alter_table("releasepolicy", schema=None) as batch_op:
+ batch_op.add_column(
+ sa.Column(
+ "license_check_mode",
+ sa.Enum("LIGHTWEIGHT", "RAT", "BOTH", name="licensecheckmode"),
+ server_default="BOTH",
+ nullable=False,
+ )
+ )
+
+
+def downgrade() -> None:
+ with op.batch_alter_table("releasepolicy", schema=None) as batch_op:
+ batch_op.drop_column("license_check_mode")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]