diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af55b623c63..c284a57f788 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,8 @@ jobs: outputs: docs: ${{ steps.set-matrix.outputs.docs }} zephyr-tests: ${{ steps.set-matrix.outputs.zephyr-tests }} + tests: ${{ steps.set-matrix.outputs.tests }} + mpy-cross: ${{ steps.set-matrix.outputs.mpy-cross }} ports: ${{ steps.set-matrix.outputs.ports }} cp-version: ${{ steps.set-up-submodules.outputs.version }} steps: @@ -99,6 +101,7 @@ jobs: tests: needs: scheduler + if: needs.scheduler.outputs.tests == 'True' uses: ./.github/workflows/run-tests.yml with: cp-version: ${{ needs.scheduler.outputs.cp-version }} @@ -112,7 +115,7 @@ jobs: mpy-cross: needs: scheduler - if: needs.scheduler.outputs.ports != '{}' + if: needs.scheduler.outputs.mpy-cross == 'True' uses: ./.github/workflows/build-mpy-cross.yml secrets: inherit with: @@ -121,7 +124,7 @@ jobs: mpy-cross-mac: runs-on: macos-latest needs: scheduler - if: needs.scheduler.outputs.ports != '{}' + if: needs.scheduler.outputs.mpy-cross == 'True' env: CP_VERSION: ${{ needs.scheduler.outputs.cp-version }} steps: @@ -226,7 +229,8 @@ jobs: ports: needs: [scheduler, tests] - if: needs.scheduler.outputs.ports != '{}' + # Without !failure() and !cancelled(), a skipped tests job would skip this job too. + if: ${{ !failure() && !cancelled() && needs.scheduler.outputs.ports != '{}' }} uses: ./.github/workflows/build-boards.yml secrets: inherit strategy: diff --git a/tools/ci_fetch_deps.py b/tools/ci_fetch_deps.py index 312b87c5ba4..52c131b41f8 100644 --- a/tools/ci_fetch_deps.py +++ b/tools/ci_fetch_deps.py @@ -205,16 +205,6 @@ def main(target): submodules = ["extmod/ulab", "frozen"] elif target == "mpy-cross" or target == "mpy-cross-mac": submodules = ["tools/"] # for huffman - elif target == "windows": - # This builds one board from a number of ports so fill out a bunch of submodules - for port in ("atmel-samd", "nordic", "raspberrypi", "stm"): - submodules.append(f"ports/{port}") - submodules.extend(PORT_DEPS[port]) - unique_submodules = set(submodules) - submodules = list(unique_submodules) - elif target == "windows-zephyr": - submodules.append("ports/zephyr-cp") - submodules.extend(PORT_DEPS["zephyr-cp"]) elif target == "website": submodules = ["tools/adabot", "frozen"] elif target == "pre-commit": @@ -288,6 +278,6 @@ def main(target): run("Sync submodule URLs", "git submodule sync --quiet", cwd=TOP) - # Target will be a board, "test", "docs", "mpy-cross-mac", or "windows" + # Target will be a board, "test", "docs" or "mpy-cross-mac" for target in sys.argv[1:]: main(target) diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index f95bc1cfb10..971583e28d5 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -81,6 +81,16 @@ r"|^\.github/workflows/zephyr-autogen-pr\.yml$" ) +# Files that can't affect the unix coverage tests: other ports and the documentation. +# The tests build nothing from ports/ except ports/unix. frozen/ is not on this list, +# because run-tests.py puts the frozen asyncio and Ticks libraries on the module search path. +PATTERN_TESTS_IGNORE = re.compile(r"^docs/|^ports/(?!unix/)") + +# Files that can't affect mpy-cross: ports, frozen libraries, the documentation and the tests. +# The board builds don't need the mpy-cross and mpy-cross-mac jobs. They use the mpy-cross +# that the scheduler job builds. +PATTERN_MPY_CROSS_IGNORE = re.compile(r"^(?:docs|frozen|ports|tests)/") + # Zephyr boards don't use make, so their module tables can't be computed here. Each # board's build writes autogen_board_info.toml next to its circuitpython.toml and that # file is committed; a board whose table is missing, unreadable or doesn't name a @@ -110,18 +120,6 @@ def zephyr_board_has_module(board, module): return board not in zephyr_modules or zephyr_modules[board].get(module, True) -PATTERN_WINDOWS = { - ".github/", - "extmod/", - "lib/", - "mpy-cross/", - "ports/unix/", - "py/", - "tools/", - "requirements-dev.txt", -} - - def git_diff(pattern: str): return set( subprocess.run( @@ -384,25 +382,25 @@ def set_zephyr_tests(run: bool): set_output("zephyr-tests", run) -def set_windows(run: bool): +# These don't check last_failed_jobs. If a tests or mpy-cross job failed on the last checked +# commit, ci_changes_per_commit.py reports no commit, so all the pull request's changes are +# checked again. +def set_tests(run: bool): if not run: - if last_failed_jobs.get("windows"): - run = True - else: - for file in changed_files: - for pattern in PATTERN_WINDOWS: - if file.startswith(pattern) and not any( - [file.startswith(path) for path in IGNORE_BOARD] - ): - run = True - break - else: - continue - break + run = any(not PATTERN_TESTS_IGNORE.match(file) for file in changed_files) + + # Set the step outputs + print("Running tests:", run) + set_output("tests", run) + + +def set_mpy_cross(run: bool): + if not run: + run = any(not PATTERN_MPY_CROSS_IGNORE.match(file) for file in changed_files) # Set the step outputs - print("Building windows:", run) - set_output("windows", run) + print("Building mpy-cross:", run) + set_output("mpy-cross", run) def main(): @@ -411,7 +409,9 @@ def main(): # Set jobs set_docs(run_all) set_zephyr_tests(run_all) - set_windows(run_all) + set_tests(run_all) + # Pushes upload each version's mpy-cross binaries to S3, so build them every time. + set_mpy_cross(run_all or os.environ.get("GITHUB_EVENT_NAME") == "push") set_boards(run_all)