Skip to content

Commit dfedd90

Browse files
valeroscparata
authored andcommitted
Add functionality to ignore library examples in CI for PlatformIO
By default `Keyboard` and `Mouse` libraries are skipped as they may require additional configuration steps Related stm32duino#1743
1 parent 31e8a27 commit dfedd90

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

CI/build/platformio-builder.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,26 @@
33
import subprocess
44
import sys
55

6+
# Libraries that are not meant to be checked in CI by default
7+
DEFAULT_IGNORED_LIBRARIES = (
8+
"keyboard",
9+
"mouse"
10+
)
11+
612

713
def run_platformio(example_path, boards):
814
return subprocess.call(
915
["platformio", "ci", example_path] + ["--board=" + b for b in boards]
1016
)
1117

1218

13-
def collect_examples(libs_dir):
19+
def collect_examples(libs_dir, ignored_libraries=None):
20+
ignored_libraries = ignored_libraries or []
1421
examples = []
1522
for lib in os.listdir(libs_dir):
23+
if lib.lower() in ignored_libraries:
24+
print(f"Skipping examples from the `{lib}` library...")
25+
continue
1626
lib_dir = os.path.join(libs_dir, lib)
1727
examples_dir = os.path.join(lib_dir, "examples")
1828
if os.path.isdir(examples_dir):
@@ -27,6 +37,9 @@ def collect_examples(libs_dir):
2737
parser.add_argument(
2838
"-b", "--board", action="append", help="board ID used for PlatformIO project"
2939
)
40+
parser.add_argument(
41+
"-i", "--ignore-library", action="append", help="Library name to ignore when collecting project examples"
42+
)
3043

3144

3245
def main():
@@ -35,8 +48,12 @@ def main():
3548
if boards is None:
3649
boards = ["nucleo_f401re"]
3750

51+
ignored_libraries = args.ignore_library
52+
if ignored_libraries is None:
53+
ignored_libraries = DEFAULT_IGNORED_LIBRARIES
54+
3855
libs_dir = os.path.join(os.environ["GITHUB_WORKSPACE"], "libraries")
39-
if any(run_platformio(example, boards) for example in collect_examples(libs_dir)):
56+
if any(run_platformio(example, boards) for example in collect_examples(libs_dir, ignored_libraries)):
4057
sys.exit(1)
4158

4259

0 commit comments

Comments
 (0)