-
-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,24 +45,24 @@ | |
| 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"}) | ||
| IOS_DIRS = frozenset({"Apple", "iOS"}) | ||
| MACOS_DIRS = frozenset({"Mac"}) | ||
| WASI_DIRS = frozenset({Path("Tools", "wasm")}) | ||
|
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: | ||
| run_android: bool = False | ||
| run_ci_fuzz: bool = False | ||
| run_docs: bool = False | ||
| run_tests: bool = False | ||
| run_windows_msi: bool = False | ||
| run_windows_tests: bool = False | ||
| run_ios: bool = False | ||
| run_macos: bool = False | ||
| run_tests: bool = False | ||
| run_ubuntu: bool = False | ||
| run_android: bool = False | ||
| run_ios: bool = False | ||
| run_wasi: bool = False | ||
|
StanFromIreland marked this conversation as resolved.
|
||
| run_windows_msi: bool = False | ||
| run_windows_tests: bool = False | ||
|
|
||
|
|
||
| def compute_changes() -> None: | ||
|
|
@@ -74,13 +74,13 @@ def compute_changes() -> None: | |
| else: | ||
| # Otherwise, just run the tests | ||
| outputs = Outputs( | ||
| run_tests=True, | ||
| run_windows_tests=True, | ||
| run_macos=True, | ||
| run_ubuntu=True, | ||
| run_android=True, | ||
| run_ios=True, | ||
| run_macos=True, | ||
| run_tests=True, | ||
| run_ubuntu=True, | ||
| run_wasi=True, | ||
| run_windows_tests=True, | ||
| ) | ||
| outputs = process_target_branch(outputs, target_branch) | ||
|
|
||
|
|
@@ -129,7 +129,7 @@ def get_changed_files( | |
| return frozenset(map(Path, filter(None, map(str.strip, changed_files)))) | ||
|
|
||
|
|
||
| def is_platform_specific(file: Path) -> str | None: | ||
| def get_file_platform(file: Path) -> str | None: | ||
| if not file.parts: | ||
| return None | ||
| first_part = file.parts[0] | ||
|
|
@@ -152,7 +152,7 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: | |
| run_windows_msi = False | ||
|
|
||
| platforms_changed = set() | ||
| has_non_plat_specific_change = False | ||
| has_platform_specific_change = True | ||
|
|
||
| for file in changed_files: | ||
| # Documentation files | ||
|
|
@@ -161,7 +161,8 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: | |
|
|
||
| if file.parent == GITHUB_WORKFLOWS_PATH: | ||
| if file.name == "build.yml": | ||
| run_tests = run_ci_fuzz = has_non_plat_specific_change = True | ||
| run_tests = run_ci_fuzz = True | ||
| has_platform_specific_change = False | ||
| if file.name == "reusable-docs.yml": | ||
| run_docs = True | ||
| if file.name == "reusable-windows-msi.yml": | ||
|
|
@@ -178,11 +179,11 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: | |
| ): | ||
| run_tests = True | ||
|
|
||
| platform = is_platform_specific(file) | ||
| platform = get_file_platform(file) | ||
| if platform is not None: | ||
| platforms_changed.add(platform) | ||
| else: | ||
| has_non_plat_specific_change = True | ||
| has_platform_specific_change = False | ||
| if file not in UNIX_BUILD_SYSTEM_FILE_NAMES: | ||
| run_windows_tests = True | ||
|
|
||
|
|
@@ -206,7 +207,7 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: | |
|
|
||
| # Check which platform specific tests to run | ||
| if run_tests: | ||
| if has_non_plat_specific_change or not platforms_changed: | ||
| if not has_platform_specific_change or not platforms_changed: | ||
| run_macos = True | ||
| run_ubuntu = True | ||
| run_android = True | ||
|
|
@@ -226,16 +227,16 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: | |
| run_wasi = False | ||
|
|
||
| return Outputs( | ||
| run_android=run_android, | ||
| 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_ios=run_ios, | ||
| run_macos=run_macos, | ||
| run_tests=run_tests, | ||
| run_ubuntu=run_ubuntu, | ||
| run_android=run_android, | ||
| run_ios=run_ios, | ||
| run_wasi=run_wasi, | ||
| run_windows_msi=run_windows_msi, | ||
| run_windows_tests=run_windows_tests, | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -262,16 +263,16 @@ def write_github_output(outputs: Outputs) -> None: | |
| return | ||
|
|
||
| with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f: | ||
|
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. With the naming being so consistent, this could be simplified with a |
||
| f.write(f"run-android={bool_lower(outputs.run_android)}\n") | ||
| f.write(f"run-ci-fuzz={bool_lower(outputs.run_ci_fuzz)}\n") | ||
| f.write(f"run-docs={bool_lower(outputs.run_docs)}\n") | ||
| 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-ios={bool_lower(outputs.run_ios)}\n") | ||
| f.write(f"run-macos={bool_lower(outputs.run_macos)}\n") | ||
| f.write(f"run-tests={bool_lower(outputs.run_tests)}\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") | ||
| f.write(f"run-windows-msi={bool_lower(outputs.run_windows_msi)}\n") | ||
| f.write(f"run-windows-tests={bool_lower(outputs.run_windows_tests)}\n") | ||
|
|
||
|
|
||
| def bool_lower(value: bool, /) -> str: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.