diff mbox series

[v4,3/4] insane.bbclass: add missing-srcrev QA check for SCM URIs

Message ID 20260527111756.1306022-4-saisneha196@gmail.com
State New
Headers show
Series Add missing SRCREV check for SCM URIs | expand

Commit Message

Sai Sneha May 27, 2026, 11:17 a.m. UTC
Add a proper QA check test_missing_srcrev() in do_recipe_qa that
fires at build time via oe.qa.handle_error(), using the shared
oe.qa.check_uri_srcrev() helper to avoid code duplication.

Severity is controlled per layer:
- WARN_QA:append = " missing-srcrev" for all layers (warning by default)
- ERROR_QA:append:layer-core = " missing-srcrev" for oe-core (strict)

This follows the same pattern as missing-metadata and missing-maintainer
which are warnings globally but errors for oe-core.

Note on CHECKLAYER_REQUIRED_TESTS: missing-srcrev is intentionally
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.
Instead, yocto-check-layer.bbclass enforces it directly during
checklayer validation runs.

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 v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added note explaining why CHECKLAYER_REQUIRED_TESTS is not used

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

Changes in v2:
- Initial public submission
 meta/classes-global/insane.bbclass | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
index 04700be71c..1fe426646d 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -49,6 +49,9 @@  ERROR_QA ?= "\
 ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}"
 WARN_QA:append:layer-core = " missing-metadata missing-maintainer"
 
+WARN_QA:append = " missing-srcrev"
+ERROR_QA:append:layer-core = " missing-srcrev"
+
 FAKEROOT_QA = "host-user-contaminated"
 FAKEROOT_QA[doc] = "QA tests which need to run under fakeroot. If any \
 enabled tests are listed here, the do_package_qa task will run under fakeroot."
@@ -1455,6 +1458,15 @@  python do_qa_unpack() {
 python do_recipe_qa() {
     import re
 
+    def test_missing_srcrev(pn, d):
+        import oe.qa
+        src_uri = (d.getVar('SRC_URI', False) or '').split()
+        for uri in src_uri:
+            rev = oe.qa.check_uri_srcrev(pn, uri, d)
+            if rev is None:
+                oe.qa.handle_error("missing-srcrev",
+                    "%s: SRCREV not set for SCM URI %s" % (pn, uri), d)
+         
     def test_naming(pn, d):
         if pn.endswith("-native") and not bb.data.inherits_class("native", d):
             oe.qa.handle_error("recipe-naming", "Recipe %s appears native but is not, should inherit native" % pn, d)
@@ -1497,6 +1509,7 @@  python do_recipe_qa() {
 
     pn = d.getVar('PN')
     test_naming(pn, d)
+    test_missing_srcrev(pn, d)
     test_missing_metadata(pn, d)
     test_missing_maintainer(pn, d)
     test_srcuri(pn, d)