diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb8d92a0ff5..f5e35dc453c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,7 @@ jobs: runs-on: ubuntu-24.04 outputs: docs: ${{ steps.set-matrix.outputs.docs }} + zephyr-tests: ${{ steps.set-matrix.outputs.zephyr-tests }} ports: ${{ steps.set-matrix.outputs.ports }} cp-version: ${{ steps.set-up-submodules.outputs.version }} steps: @@ -102,6 +103,7 @@ jobs: zephyr-tests: needs: scheduler + if: needs.scheduler.outputs.zephyr-tests == 'True' uses: ./.github/workflows/run-zephyr-tests.yml with: cp-version: ${{ needs.scheduler.outputs.cp-version }} diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index 17dace96969..26d3bed4ebc 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -71,6 +71,11 @@ GITHUB_MATRIX_LIMIT = 256 +# The Zephyr tests build native_sim and the two bsim boards out of the shared sources, so a +# change confined to these cannot reach them: another port, a translation, a frozen library +# (this port has none), documentation or the unix test suite. +PATTERN_ZEPHYR_TESTS_IGNORE = re.compile(r"^(?:docs|frozen|locale|tests)/|^ports/(?!zephyr-cp/)") + PATTERN_WINDOWS = { ".github/", "extmod/", @@ -321,6 +326,21 @@ def set_docs(run: bool): set_output("docs", run) +def set_zephyr_tests(run: bool): + if not run: + if any(job.startswith("zephyr-tests") for job in last_failed_jobs): + run = True + else: + for file in changed_files: + if not PATTERN_ZEPHYR_TESTS_IGNORE.match(file): + run = True + break + + # Set the step outputs + print("Running Zephyr tests:", run) + set_output("zephyr-tests", run) + + def set_windows(run: bool): if not run: if last_failed_jobs.get("windows"): @@ -347,6 +367,7 @@ def main(): print("Running: " + ("all" if run_all else "conditionally")) # Set jobs set_docs(run_all) + set_zephyr_tests(run_all) set_windows(run_all) set_boards(run_all)