diff mbox series

[v5,4/4] yocto-check-layer.bbclass: enforce missing SRCREV check during layer validation

Message ID 20260602062940.3107241-5-saisneha196@gmail.com
State Changes Requested
Headers show
Series Add missing SRCREV check for SCM URIs | expand

Commit Message

Sai Sneha June 2, 2026, 6:29 a.m. UTC
Add check_missing_srcrev() to yocto-check-layer.bbclass to enforce
the missing-srcrev check as an error during yocto-check-layer runs,
using the shared oe.qa.check_uri_srcrev() helper.

This ensures layer maintainers submitting layers to the Yocto
ecosystem must fix all missing SRCREVs before their layer passes
validation, even if their layer only gets WARN_QA during normal builds.

Note on design: missing-srcrev is not added to CHECKLAYER_REQUIRED_TESTS
because that would promote it to ERROR_QA for all layers globally during
normal builds, contradicting the layer-specific enforcement requested in
Bug 16051 Comment 3. This direct implementation in yocto-check-layer.bbclass
enforces it strictly during checklayer validation without affecting
normal builds.

This satisfies the requirement from Bug 16051 Comment 2:
'add a QA check outside of checklayer then add it to checklayer'

Reported-by: Yoann Congal <yoann.congal@smile.fr>
Fixes: https://bugzilla.yoctoproject.org/show_bug.cgi?id=16051
AI-Generated: Developed with assistance from Anthropic Claude
Signed-off-by: Sai Sneha <saisneha196@gmail.com>
---

Changes in v5:
- No changes to this patch

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added docstring

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag

Changes in v2:
- Initial public submission
 meta/classes-global/yocto-check-layer.bbclass | 15 +++++++++++++++
 meta/lib/oe/qa.py                             |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-global/yocto-check-layer.bbclass b/meta/classes-global/yocto-check-layer.bbclass
index ba93085325..11b7f5d2ee 100644
--- a/meta/classes-global/yocto-check-layer.bbclass
+++ b/meta/classes-global/yocto-check-layer.bbclass
@@ -56,7 +56,22 @@  def check_network_flag(d):
         if network and not is_allowed(bpn, task):
             bb.error(f"QA Issue: task {task} has network enabled")
 
+def check_missing_srcrev(d):
+    """
+    Enforce missing-srcrev check as error during yocto-check-layer runs.
+    Uses the shared oe.qa.check_uri_srcrev() helper.
+    """
+    import oe.qa
+    src_uri = (d.getVar('SRC_URI', False) or '').split()
+    pn = d.getVar('PN')
+    for uri in src_uri:
+        rev = oe.qa.check_uri_srcrev(pn, uri, d)
+        if rev is None:
+            bb.error("QA Issue: %s: SRCREV not set for SCM URI %s [missing-srcrev]" % (pn, uri))
+            d.setVar("QA_ERRORS_FOUND", "True")
+
 python () {
     check_insane_skip(d)
     check_network_flag(d)
+    check_missing_srcrev(d)
 }
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 0987aaf2c4..3da45e33ce 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -245,7 +245,7 @@  def check_uri_srcrev(pn, uri, d):
     Check that a single SCM URI has a valid SRCREV set.
 
     Returns the resolved revision string if valid (including '${AUTOREV}').
-    Returns '' for non-SCM URIs or URIs with inline rev= parameter (skip).
+    Returns '' for non-SCM URIs or URIs with inline rev= or tag= parameter (skip).
     Returns None if SRCREV is missing or INVALID.
     """
     import bb.fetch2