Skip to content

Commit 56e13d3

Browse files
authored
Merge pull request #11327 from MakerClassCZ/ci-zephyr-tests-gate
ci: run the Zephyr tests only when a change can reach them
2 parents 121489f + a539065 commit 56e13d3

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
runs-on: ubuntu-24.04
2323
outputs:
2424
docs: ${{ steps.set-matrix.outputs.docs }}
25+
zephyr-tests: ${{ steps.set-matrix.outputs.zephyr-tests }}
2526
ports: ${{ steps.set-matrix.outputs.ports }}
2627
cp-version: ${{ steps.set-up-submodules.outputs.version }}
2728
steps:
@@ -102,6 +103,7 @@ jobs:
102103

103104
zephyr-tests:
104105
needs: scheduler
106+
if: needs.scheduler.outputs.zephyr-tests == 'True'
105107
uses: ./.github/workflows/run-zephyr-tests.yml
106108
with:
107109
cp-version: ${{ needs.scheduler.outputs.cp-version }}

tools/ci_set_matrix.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171

7272
GITHUB_MATRIX_LIMIT = 256
7373

74+
# The Zephyr tests build native_sim and the two bsim boards out of the shared sources, so a
75+
# change confined to these cannot reach them: another port, a translation, a frozen library
76+
# (this port has none), documentation or the unix test suite.
77+
PATTERN_ZEPHYR_TESTS_IGNORE = re.compile(r"^(?:docs|frozen|locale|tests)/|^ports/(?!zephyr-cp/)")
78+
7479
PATTERN_WINDOWS = {
7580
".github/",
7681
"extmod/",
@@ -321,6 +326,21 @@ def set_docs(run: bool):
321326
set_output("docs", run)
322327

323328

329+
def set_zephyr_tests(run: bool):
330+
if not run:
331+
if any(job.startswith("zephyr-tests") for job in last_failed_jobs):
332+
run = True
333+
else:
334+
for file in changed_files:
335+
if not PATTERN_ZEPHYR_TESTS_IGNORE.match(file):
336+
run = True
337+
break
338+
339+
# Set the step outputs
340+
print("Running Zephyr tests:", run)
341+
set_output("zephyr-tests", run)
342+
343+
324344
def set_windows(run: bool):
325345
if not run:
326346
if last_failed_jobs.get("windows"):
@@ -347,6 +367,7 @@ def main():
347367
print("Running: " + ("all" if run_all else "conditionally"))
348368
# Set jobs
349369
set_docs(run_all)
370+
set_zephyr_tests(run_all)
350371
set_windows(run_all)
351372
set_boards(run_all)
352373

0 commit comments

Comments
 (0)