From 24269939b1631df74c16e915049b3b342232ce2c Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Thu, 26 Jan 2023 13:12:33 +0100 Subject: [PATCH] Validate target names passed to build_examples.py (#24644) * Validate target names passed to build_examples.py Skipping invalid target names might lead to false positive CI passes in case when target name is invalid. In such case test was never executed. * Fix target names for Tizen examples CI checks * Restyled by isort * Add libwebsockets submodule to Tizen platform Co-authored-by: Restyled.io --- .github/workflows/examples-tizen.yaml | 6 +++--- .gitmodules | 2 +- scripts/build/build_examples.py | 17 +++++++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 528323915f6cd4..fab5e7ddc07e5b 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -61,9 +61,9 @@ jobs: --enable-flashbundle \ --target tizen-arm-all-clusters \ --target tizen-arm-all-clusters-minimal-no-wifi \ - --target chip-tool-ubsan \ - --target light \ - --target light-no-ble-no-wifi \ + --target tizen-arm-chip-tool-ubsan \ + --target tizen-arm-light \ + --target tizen-arm-light-no-ble-no-wifi \ build \ --copy-artifacts-to out/artifacts \ " diff --git a/.gitmodules b/.gitmodules index 74addf59b3d0d7..048d1f48b7734b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -293,4 +293,4 @@ [submodule "third_party/libwebsockets/repo"] path = third_party/libwebsockets/repo url = https://github.com/warmcat/libwebsockets - platforms = linux,darwin + platforms = linux,darwin,tizen diff --git a/scripts/build/build_examples.py b/scripts/build/build_examples.py index 14439f32289376..c70a5da7981d49 100755 --- a/scripts/build/build_examples.py +++ b/scripts/build/build_examples.py @@ -20,11 +20,11 @@ import click import coloredlogs - -import build from builders.builder import BuilderOptions from runner import PrintOnlyRunner, ShellRunner +import build + sys.path.append(os.path.abspath(os.path.dirname(__file__))) @@ -59,6 +59,18 @@ def ValidateRepoPath(context, parameter, value): return value +def ValidateTargetNames(context, parameter, values): + """ + Validates that the given target name is valid. + """ + for value in values: + if not any(target.StringIntoTargetParts(value.lower()) + for target in build.targets.BUILD_TARGETS): + raise click.BadParameter( + "'%s' is not a valid target name." % value) + return values + + @click.group(chain=True) @click.option( '--log-level', @@ -69,6 +81,7 @@ def ValidateRepoPath(context, parameter, value): '--target', default=[], multiple=True, + callback=ValidateTargetNames, help='Build target(s)' ) @click.option(