From 2437d82a6981898fc46d7c69fe2e7181127a06ea Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Fri, 19 Apr 2024 14:05:10 +0200
Subject: [PATCH] [CI] CI now checks that existing machdeps are conforming to
 the schema

---
 nix/kernel-tests.nix    | 1 +
 nix/mk_tests.nix        | 2 ++
 share/machdeps/Makefile | 7 +++++++
 3 files changed, 10 insertions(+)

diff --git a/nix/kernel-tests.nix b/nix/kernel-tests.nix
index f243ca6a08c..91451c9310c 100644
--- a/nix/kernel-tests.nix
+++ b/nix/kernel-tests.nix
@@ -20,5 +20,6 @@ mk_tests {
       src/plugins/server/tests/batch \
       tests/fc_script \
       tests/syntax
+    make -C share/machdeps check-schema
   '';
 }
diff --git a/nix/mk_tests.nix b/nix/mk_tests.nix
index 9d71cbf776d..ceab5c12649 100644
--- a/nix/mk_tests.nix
+++ b/nix/mk_tests.nix
@@ -30,6 +30,7 @@
 , clang
 , frama-c
 , perl
+, python3Packages
 , stdenvNoCC
 , time
 , unixtools
@@ -56,6 +57,7 @@ stdenvNoCC.mkDerivation {
     clang
     frama-c
     perl
+    python3Packages.jsonschema
     time
     unixtools.getopt
     yq
diff --git a/share/machdeps/Makefile b/share/machdeps/Makefile
index a05ad92aa8e..5ab36af3da0 100644
--- a/share/machdeps/Makefile
+++ b/share/machdeps/Makefile
@@ -46,3 +46,10 @@ machdep_%.yaml: machdep_gcc_%.yaml Makefile
 	@echo "Checking $*"
 	@./make_machdep/make_machdep.py --from-file $* --check-only
 	@touch $@
+
+.PHONY: check-schema
+
+check-schema:
+	@$(foreach machdep, $(wildcard machdep_*.yaml), \
+           ./make_machdep/make_machdep.py --from-file $(machdep) --check-only \
+           || echo "$(machdep) does not conform to machdep schema";)
-- 
GitLab