-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-142278: Add granular change detection for platforms in CI #142350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+130
−45
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,11 @@ | |
| SUFFIXES_C_OR_CPP = frozenset({".c", ".h", ".cpp"}) | ||
| SUFFIXES_DOCUMENTATION = frozenset({".rst", ".md"}) | ||
|
|
||
| MACOS_DIRS = frozenset({"Mac"}) | ||
| IOS_DIRS = frozenset({"Apple", "iOS"}) | ||
| ANDROID_DIRS = frozenset({"Android"}) | ||
| WASI_DIRS = frozenset({Path("Tools", "wasm")}) | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is technically too broad as it includes Emscripten (since 3,14), but I don't think it's worth changing until the |
||
|
|
||
|
|
||
| @dataclass(kw_only=True, slots=True) | ||
| class Outputs: | ||
|
|
@@ -53,6 +58,11 @@ class Outputs: | |
| run_tests: bool = False | ||
| run_windows_msi: bool = False | ||
| run_windows_tests: bool = False | ||
| run_macos: bool = False | ||
| run_ubuntu: bool = False | ||
| run_android: bool = False | ||
| run_ios: bool = False | ||
| run_wasi: bool = False | ||
|
StanFromIreland marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def compute_changes() -> None: | ||
|
|
@@ -63,7 +73,15 @@ def compute_changes() -> None: | |
| outputs = process_changed_files(files) | ||
| else: | ||
| # Otherwise, just run the tests | ||
| outputs = Outputs(run_tests=True, run_windows_tests=True) | ||
| outputs = Outputs( | ||
| run_tests=True, | ||
| run_windows_tests=True, | ||
| run_macos=True, | ||
| run_ubuntu=True, | ||
| run_android=True, | ||
| run_ios=True, | ||
| run_wasi=True, | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| ) | ||
| outputs = process_target_branch(outputs, target_branch) | ||
|
|
||
| if outputs.run_tests: | ||
|
|
@@ -111,25 +129,47 @@ def get_changed_files( | |
| return frozenset(map(Path, filter(None, map(str.strip, changed_files)))) | ||
|
|
||
|
|
||
| def is_platform_specific(file: Path) -> str | None: | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| if not file.parts: | ||
| return None | ||
| first_part = file.parts[0] | ||
| if first_part in MACOS_DIRS: | ||
| return "macos" | ||
| if first_part in IOS_DIRS: | ||
| return "ios" | ||
| if first_part in ANDROID_DIRS: | ||
| return "android" | ||
| if len(file.parts) >= 2 and Path(*file.parts[:2]) in WASI_DIRS: # Tools/wasm/ | ||
| return "wasi" | ||
| return None | ||
|
|
||
|
|
||
| def process_changed_files(changed_files: Set[Path]) -> Outputs: | ||
| run_tests = False | ||
| run_ci_fuzz = False | ||
| run_docs = False | ||
| run_windows_tests = False | ||
| run_windows_msi = False | ||
|
|
||
| platforms_changed = set() | ||
| has_non_plat_specific_change = False | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
|
|
||
| for file in changed_files: | ||
| # Documentation files | ||
| doc_or_misc = file.parts[0] in {"Doc", "Misc"} | ||
| doc_file = file.suffix in SUFFIXES_DOCUMENTATION or doc_or_misc | ||
|
|
||
| if file.parent == GITHUB_WORKFLOWS_PATH: | ||
| if file.name == "build.yml": | ||
| run_tests = run_ci_fuzz = True | ||
| run_tests = run_ci_fuzz = has_non_plat_specific_change = True | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| if file.name == "reusable-docs.yml": | ||
| run_docs = True | ||
| if file.name == "reusable-windows-msi.yml": | ||
| run_windows_msi = True | ||
| if file.name == "reusable-macos.yml": | ||
| platforms_changed.add("macos") | ||
| if file.name == "reusable-wasi.yml": | ||
| platforms_changed.add("wasi") | ||
|
|
||
| if not ( | ||
| doc_file | ||
|
|
@@ -138,8 +178,13 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: | |
| ): | ||
| run_tests = True | ||
|
|
||
| if file not in UNIX_BUILD_SYSTEM_FILE_NAMES: | ||
| run_windows_tests = True | ||
| platform = is_platform_specific(file) | ||
| if platform is not None: | ||
| platforms_changed.add(platform) | ||
| else: | ||
| has_non_plat_specific_change = True | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| if file not in UNIX_BUILD_SYSTEM_FILE_NAMES: | ||
| run_windows_tests = True | ||
|
|
||
| # The fuzz tests are pretty slow so they are executed only for PRs | ||
| # changing relevant files. | ||
|
|
@@ -159,12 +204,38 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: | |
| if file.parts[:2] == ("Tools", "msi"): | ||
| run_windows_msi = True | ||
|
|
||
| # Check which platform specific tests to run | ||
| if run_tests: | ||
| if has_non_plat_specific_change or not platforms_changed: | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| run_macos = True | ||
| run_ubuntu = True | ||
| run_android = True | ||
| run_ios = True | ||
| run_wasi = True | ||
| else: | ||
| run_macos = "macos" in platforms_changed | ||
| run_ubuntu = False | ||
| run_android = "android" in platforms_changed | ||
| run_ios = "ios" in platforms_changed | ||
| run_wasi = "wasi" in platforms_changed | ||
| else: | ||
| run_macos = False | ||
| run_ubuntu = False | ||
| run_android = False | ||
| run_ios = False | ||
| run_wasi = False | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
|
|
||
| return Outputs( | ||
| run_ci_fuzz=run_ci_fuzz, | ||
| run_docs=run_docs, | ||
| run_tests=run_tests, | ||
| run_windows_tests=run_windows_tests, | ||
| run_windows_msi=run_windows_msi, | ||
| run_macos=run_macos, | ||
| run_ubuntu=run_ubuntu, | ||
| run_android=run_android, | ||
| run_ios=run_ios, | ||
| run_wasi=run_wasi, | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -196,6 +267,11 @@ def write_github_output(outputs: Outputs) -> None: | |
| f.write(f"run-tests={bool_lower(outputs.run_tests)}\n") | ||
| f.write(f"run-windows-tests={bool_lower(outputs.run_windows_tests)}\n") | ||
| f.write(f"run-windows-msi={bool_lower(outputs.run_windows_msi)}\n") | ||
| f.write(f"run-macos={bool_lower(outputs.run_macos)}\n") | ||
| f.write(f"run-ubuntu={bool_lower(outputs.run_ubuntu)}\n") | ||
| f.write(f"run-android={bool_lower(outputs.run_android)}\n") | ||
| f.write(f"run-ios={bool_lower(outputs.run_ios)}\n") | ||
| f.write(f"run-wasi={bool_lower(outputs.run_wasi)}\n") | ||
|
|
||
|
|
||
| def bool_lower(value: bool, /) -> str: | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.