Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 48 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ jobs:
macOS
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-macos == 'true'
strategy:
fail-fast: false
matrix:
Expand All @@ -217,7 +217,7 @@ jobs:
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-ubuntu == 'true'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -248,7 +248,7 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-ubuntu == 'true'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -304,7 +304,7 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-ubuntu == 'true'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -368,7 +368,7 @@ jobs:
build-android:
name: Android (${{ matrix.arch }})
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-android == 'true'
timeout-minutes: 60
strategy:
fail-fast: false
Expand All @@ -390,7 +390,7 @@ jobs:
build-ios:
name: iOS
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-ios == 'true'
timeout-minutes: 60
runs-on: macos-15
steps:
Expand All @@ -413,15 +413,15 @@ jobs:
build-wasi:
name: 'WASI'
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-wasi == 'true'
uses: ./.github/workflows/reusable-wasi.yml

test-hypothesis:
name: "Hypothesis tests on Ubuntu"
runs-on: ubuntu-24.04
timeout-minutes: 60
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-ubuntu == 'true'
env:
OPENSSL_VER: 3.0.18
PYTHONSTRICTEXTENSIONBUILD: 1
Expand Down Expand Up @@ -528,7 +528,7 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-ubuntu == 'true'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -581,7 +581,7 @@ jobs:
# ${{ '' } is a hack to nest jobs under the same sidebar category.
name: Sanitizers${{ '' }} # zizmor: ignore[obfuscation]
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-ubuntu == 'true'
strategy:
fail-fast: false
matrix:
Expand All @@ -606,7 +606,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
if: needs.build-context.outputs.run-ubuntu == 'true'
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -724,13 +724,36 @@ jobs:
&& '
check-autoconf-regen,
check-generated-files,
'
|| ''
}}
${{
!fromJSON(needs.build-context.outputs.run-windows-tests)
&& '
build-windows,
'
|| ''
}}
${{
!fromJSON(needs.build-context.outputs.run-ci-fuzz)
&& '
cifuzz,
'
|| ''
}}
${{
!fromJSON(needs.build-context.outputs.run-macos)
&& '
build-macos,
'
|| ''
}}
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
${{
!fromJSON(needs.build-context.outputs.run-ubuntu)
&& '
build-ubuntu,
build-ubuntu-ssltests-awslc,
build-ubuntu-ssltests-openssl,
build-android,
build-ios,
build-wasi,
test-hypothesis,
build-asan,
build-san,
Expand All @@ -739,16 +762,23 @@ jobs:
|| ''
}}
${{
!fromJSON(needs.build-context.outputs.run-windows-tests)
!fromJSON(needs.build-context.outputs.run-android)
&& '
build-windows,
build-android,
'
|| ''
}}
${{
!fromJSON(needs.build-context.outputs.run-ci-fuzz)
!fromJSON(needs.build-context.outputs.run-ios)
&& '
cifuzz,
build-ios,
'
|| ''
}}
${{
!fromJSON(needs.build-context.outputs.run-wasi)
&& '
build-wasi,
'
|| ''
}}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/reusable-context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ on: # yamllint disable-line rule:truthy
run-ci-fuzz:
description: Whether to run the CIFuzz job
value: ${{ jobs.compute-changes.outputs.run-ci-fuzz }} # bool
run-macos:
description: Whether to run the macOS tests
value: ${{ jobs.compute-changes.outputs.run-macos }} # bool
run-ubuntu:
description: Whether to run the Ubuntu tests
value: ${{ jobs.compute-changes.outputs.run-ubuntu }} # bool
run-android:
description: Whether to run the Android tests
value: ${{ jobs.compute-changes.outputs.run-android }} # bool
run-ios:
description: Whether to run the iOS tests
value: ${{ jobs.compute-changes.outputs.run-ios }} # bool
run-wasi:
description: Whether to run the WASI tests
value: ${{ jobs.compute-changes.outputs.run-wasi }} # bool
Comment thread
StanFromIreland marked this conversation as resolved.

jobs:
compute-changes:
Expand All @@ -44,6 +59,11 @@ jobs:
run-tests: ${{ steps.changes.outputs.run-tests }}
run-windows-msi: ${{ steps.changes.outputs.run-windows-msi }}
run-windows-tests: ${{ steps.changes.outputs.run-windows-tests }}
run-macos: ${{ steps.changes.outputs.run-macos }}
run-ubuntu: ${{ steps.changes.outputs.run-ubuntu }}
run-android: ${{ steps.changes.outputs.run-android }}
run-ios: ${{ steps.changes.outputs.run-ios }}
run-wasi: ${{ steps.changes.outputs.run-wasi }}
Comment thread
StanFromIreland marked this conversation as resolved.
steps:
- name: Set up Python
uses: actions/setup-python@v5
Expand Down
84 changes: 80 additions & 4 deletions Tools/build/compute-changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")})
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 Platforms/ move happens.



@dataclass(kw_only=True, slots=True)
class Outputs:
Expand All @@ -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
Comment thread
StanFromIreland marked this conversation as resolved.


def compute_changes() -> None:
Expand All @@ -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,
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
)
outputs = process_target_branch(outputs, target_branch)

if outputs.run_tests:
Expand Down Expand Up @@ -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:
Comment thread
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
Comment thread
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
Comment thread
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
Expand All @@ -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
Comment thread
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.
Expand All @@ -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:
Comment thread
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
Comment thread
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,
)


Expand Down Expand Up @@ -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:
Expand Down
Loading