ci: cdrouter: validate package manifests before DUT bringup

Currently the cdrouter pipeline validates package manifests only when
package_apply runs in the script phase, after the DUT bringup and init
steps in before_script. When a manifest has human errors, the job spends
several minutes on setup before failing on package_apply.

So lets add an explicit package_validate subcommand that reuses the same
manifest resolution and package option checks without requiring API
mutation, and execute it as the first operational step in before_script.
This fails fast on manifest mistakes and avoids wasting DUT bringup time.

References: PCF-2532
Assisted-by: codex:gpt-5.4:xhigh
Assisted-by: claude:opus-4-6:1m-context
Signed-off-by: Petr Štetiar <petr.stetiar@prplfoundation.org>
This commit is contained in:
Petr Štetiar 2026-02-20 05:53:40 +01:00 committed by Hela Saadani
parent eae3f27ec9
commit 0d0daed7f5
2 changed files with 38 additions and 0 deletions

View File

@ -20,6 +20,9 @@
CDROUTER_ETH0_MAC_ADDRESS_TESTBED_02: 00:03:2d:49:2e:c8
before_script:
- export TEST_PACKAGE="$(echo $CI_JOB_NAME | sed 's/\(\w\) .*/\1/')"
- .gitlab/scripts/testbed-cdrouter.py package_validate $TEST_PACKAGE
- source .gitlab/scripts/helpers.sh
- section_start "testbed-setup" "Testbed Setup" "collapsed"

View File

@ -782,6 +782,33 @@ class TestbedCDRouter:
p = self.cdr.packages.create(p)
logging.info("Created package '{}' with {} tests".format(name, len(tests)))
def package_validate(self):
manifest_path = os.path.join(
self.packages_path, self.args.package_name + ".yaml"
)
resolved = self.resolve_manifest(manifest_path)
name = resolved["name"]
tests = resolved["tests"]
options = resolved.get("options", {})
if not name:
logging.error(
"Resolved manifest name is empty for '{}'".format(manifest_path)
)
exit(1)
if not tests:
logging.error("Resolved manifest has empty test list for '{}'".format(name))
exit(1)
self.build_package_options(options)
logging.info(
"Validated package manifest '{}' as '{}' with {} tests".format(
manifest_path, name, len(tests)
)
)
def main():
logging.basicConfig(
@ -852,6 +879,14 @@ def main():
)
subparser.set_defaults(func=TestbedCDRouter.package_apply)
subparser = subparsers.add_parser(
"package_validate", help="validate package YAML manifest"
)
subparser.add_argument(
"package_name", help="package name (resolves to packages/<name>.yaml)"
)
subparser.set_defaults(func=TestbedCDRouter.package_validate)
subparser = subparsers.add_parser("config_export", help="export configuration")
subparser.add_argument("name", help="configuration name")
subparser.add_argument("filename", help="destination filename")