Skip to content

Commit 3133d2c

Browse files
Hugo's review
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent ff64baf commit 3133d2c

File tree

3 files changed

+58
-99
lines changed

3 files changed

+58
-99
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -712,13 +712,7 @@ jobs:
712712
test-hypothesis,
713713
cifuzz,
714714
allowed-skips: >-
715-
${{
716-
!fromJSON(needs.build-context.outputs.run-docs)
717-
&& '
718-
check-docs,
719-
'
720-
|| ''
721-
}}
715+
${{ !fromJSON(needs.build-context.outputs.run-docs) && 'check-docs,' || '' }}
722716
${{
723717
needs.build-context.outputs.run-tests != 'true'
724718
&& '
@@ -727,27 +721,9 @@ jobs:
727721
'
728722
|| ''
729723
}}
730-
${{
731-
!fromJSON(needs.build-context.outputs.run-windows-tests)
732-
&& '
733-
build-windows,
734-
'
735-
|| ''
736-
}}
737-
${{
738-
!fromJSON(needs.build-context.outputs.run-ci-fuzz)
739-
&& '
740-
cifuzz,
741-
'
742-
|| ''
743-
}}
744-
${{
745-
!fromJSON(needs.build-context.outputs.run-macos)
746-
&& '
747-
build-macos,
748-
'
749-
|| ''
750-
}}
724+
${{ !fromJSON(needs.build-context.outputs.run-windows-tests) && 'build-windows,' || '' }}
725+
${{ !fromJSON(needs.build-context.outputs.run-ci-fuzz) && 'cifuzz,' || '' }}
726+
${{ !fromJSON(needs.build-context.outputs.run-macos) && 'build-macos,' || '' }}
751727
${{
752728
!fromJSON(needs.build-context.outputs.run-ubuntu)
753729
&& '
@@ -761,25 +737,7 @@ jobs:
761737
'
762738
|| ''
763739
}}
764-
${{
765-
!fromJSON(needs.build-context.outputs.run-android)
766-
&& '
767-
build-android,
768-
'
769-
|| ''
770-
}}
771-
${{
772-
!fromJSON(needs.build-context.outputs.run-ios)
773-
&& '
774-
build-ios,
775-
'
776-
|| ''
777-
}}
778-
${{
779-
!fromJSON(needs.build-context.outputs.run-wasi)
780-
&& '
781-
build-wasi,
782-
'
783-
|| ''
784-
}}
740+
${{ !fromJSON(needs.build-context.outputs.run-android) && 'build-android,' || '' }}
741+
${{ !fromJSON(needs.build-context.outputs.run-ios) && 'build-ios,' || '' }}
742+
${{ !fromJSON(needs.build-context.outputs.run-wasi) && 'build-wasi,' || '' }}
785743
jobs: ${{ toJSON(needs) }}

.github/workflows/reusable-context.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,53 @@ on: # yamllint disable-line rule:truthy
1717
# || 'falsy-branch'
1818
# }}
1919
#
20-
run-docs:
21-
description: Whether to build the docs
22-
value: ${{ jobs.compute-changes.outputs.run-docs }} # bool
23-
run-tests:
24-
description: Whether to run the regular tests
25-
value: ${{ jobs.compute-changes.outputs.run-tests }} # bool
26-
run-windows-tests:
27-
description: Whether to run the Windows tests
28-
value: ${{ jobs.compute-changes.outputs.run-windows-tests }} # bool
29-
run-windows-msi:
30-
description: Whether to run the MSI installer smoke tests
31-
value: ${{ jobs.compute-changes.outputs.run-windows-msi }} # bool
20+
run-android:
21+
description: Whether to run the Android tests
22+
value: ${{ jobs.compute-changes.outputs.run-android }} # bool
3223
run-ci-fuzz:
3324
description: Whether to run the CIFuzz job
3425
value: ${{ jobs.compute-changes.outputs.run-ci-fuzz }} # bool
26+
run-docs:
27+
description: Whether to build the docs
28+
value: ${{ jobs.compute-changes.outputs.run-docs }} # bool
29+
run-ios:
30+
description: Whether to run the iOS tests
31+
value: ${{ jobs.compute-changes.outputs.run-ios }} # bool
3532
run-macos:
3633
description: Whether to run the macOS tests
3734
value: ${{ jobs.compute-changes.outputs.run-macos }} # bool
35+
run-tests:
36+
description: Whether to run the regular tests
37+
value: ${{ jobs.compute-changes.outputs.run-tests }} # bool
3838
run-ubuntu:
3939
description: Whether to run the Ubuntu tests
4040
value: ${{ jobs.compute-changes.outputs.run-ubuntu }} # bool
41-
run-android:
42-
description: Whether to run the Android tests
43-
value: ${{ jobs.compute-changes.outputs.run-android }} # bool
44-
run-ios:
45-
description: Whether to run the iOS tests
46-
value: ${{ jobs.compute-changes.outputs.run-ios }} # bool
4741
run-wasi:
4842
description: Whether to run the WASI tests
4943
value: ${{ jobs.compute-changes.outputs.run-wasi }} # bool
44+
run-windows-msi:
45+
description: Whether to run the MSI installer smoke tests
46+
value: ${{ jobs.compute-changes.outputs.run-windows-msi }} # bool
47+
run-windows-tests:
48+
description: Whether to run the Windows tests
49+
value: ${{ jobs.compute-changes.outputs.run-windows-tests }} # bool
5050

5151
jobs:
5252
compute-changes:
5353
name: Create context from changed files
5454
runs-on: ubuntu-latest
5555
timeout-minutes: 10
5656
outputs:
57+
run-android: ${{ steps.changes.outputs.run-android }}
5758
run-ci-fuzz: ${{ steps.changes.outputs.run-ci-fuzz }}
5859
run-docs: ${{ steps.changes.outputs.run-docs }}
59-
run-tests: ${{ steps.changes.outputs.run-tests }}
60-
run-windows-msi: ${{ steps.changes.outputs.run-windows-msi }}
61-
run-windows-tests: ${{ steps.changes.outputs.run-windows-tests }}
60+
run-ios: ${{ steps.changes.outputs.run-ios }}
6261
run-macos: ${{ steps.changes.outputs.run-macos }}
62+
run-tests: ${{ steps.changes.outputs.run-tests }}
6363
run-ubuntu: ${{ steps.changes.outputs.run-ubuntu }}
64-
run-android: ${{ steps.changes.outputs.run-android }}
65-
run-ios: ${{ steps.changes.outputs.run-ios }}
6664
run-wasi: ${{ steps.changes.outputs.run-wasi }}
65+
run-windows-msi: ${{ steps.changes.outputs.run-windows-msi }}
66+
run-windows-tests: ${{ steps.changes.outputs.run-windows-tests }}
6767
steps:
6868
- name: Set up Python
6969
uses: actions/setup-python@v5

Tools/build/compute-changes.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@
4545
SUFFIXES_C_OR_CPP = frozenset({".c", ".h", ".cpp"})
4646
SUFFIXES_DOCUMENTATION = frozenset({".rst", ".md"})
4747

48-
MACOS_DIRS = frozenset({"Mac"})
49-
IOS_DIRS = frozenset({"Apple", "iOS"})
5048
ANDROID_DIRS = frozenset({"Android"})
49+
IOS_DIRS = frozenset({"Apple", "iOS"})
50+
MACOS_DIRS = frozenset({"Mac"})
5151
WASI_DIRS = frozenset({Path("Tools", "wasm")})
5252

5353

5454
@dataclass(kw_only=True, slots=True)
5555
class Outputs:
56+
run_android: bool = False
5657
run_ci_fuzz: bool = False
5758
run_docs: bool = False
58-
run_tests: bool = False
59-
run_windows_msi: bool = False
60-
run_windows_tests: bool = False
59+
run_ios: bool = False
6160
run_macos: bool = False
61+
run_tests: bool = False
6262
run_ubuntu: bool = False
63-
run_android: bool = False
64-
run_ios: bool = False
6563
run_wasi: bool = False
64+
run_windows_msi: bool = False
65+
run_windows_tests: bool = False
6666

6767

6868
def compute_changes() -> None:
@@ -74,13 +74,13 @@ def compute_changes() -> None:
7474
else:
7575
# Otherwise, just run the tests
7676
outputs = Outputs(
77-
run_tests=True,
78-
run_windows_tests=True,
79-
run_macos=True,
80-
run_ubuntu=True,
8177
run_android=True,
8278
run_ios=True,
79+
run_macos=True,
80+
run_tests=True,
81+
run_ubuntu=True,
8382
run_wasi=True,
83+
run_windows_tests=True,
8484
)
8585
outputs = process_target_branch(outputs, target_branch)
8686

@@ -129,7 +129,7 @@ def get_changed_files(
129129
return frozenset(map(Path, filter(None, map(str.strip, changed_files))))
130130

131131

132-
def is_platform_specific(file: Path) -> str | None:
132+
def get_file_platform(file: Path) -> str | None:
133133
if not file.parts:
134134
return None
135135
first_part = file.parts[0]
@@ -152,7 +152,7 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
152152
run_windows_msi = False
153153

154154
platforms_changed = set()
155-
has_non_plat_specific_change = False
155+
has_platform_specific_change = True
156156

157157
for file in changed_files:
158158
# Documentation files
@@ -161,7 +161,8 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
161161

162162
if file.parent == GITHUB_WORKFLOWS_PATH:
163163
if file.name == "build.yml":
164-
run_tests = run_ci_fuzz = has_non_plat_specific_change = True
164+
run_tests = run_ci_fuzz = True
165+
has_platform_specific_change = False
165166
if file.name == "reusable-docs.yml":
166167
run_docs = True
167168
if file.name == "reusable-windows-msi.yml":
@@ -178,11 +179,11 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
178179
):
179180
run_tests = True
180181

181-
platform = is_platform_specific(file)
182+
platform = get_file_platform(file)
182183
if platform is not None:
183184
platforms_changed.add(platform)
184185
else:
185-
has_non_plat_specific_change = True
186+
has_platform_specific_change = False
186187
if file not in UNIX_BUILD_SYSTEM_FILE_NAMES:
187188
run_windows_tests = True
188189

@@ -206,7 +207,7 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
206207

207208
# Check which platform specific tests to run
208209
if run_tests:
209-
if has_non_plat_specific_change or not platforms_changed:
210+
if not has_platform_specific_change or not platforms_changed:
210211
run_macos = True
211212
run_ubuntu = True
212213
run_android = True
@@ -226,16 +227,16 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
226227
run_wasi = False
227228

228229
return Outputs(
230+
run_android=run_android,
229231
run_ci_fuzz=run_ci_fuzz,
230232
run_docs=run_docs,
231-
run_tests=run_tests,
232-
run_windows_tests=run_windows_tests,
233-
run_windows_msi=run_windows_msi,
233+
run_ios=run_ios,
234234
run_macos=run_macos,
235+
run_tests=run_tests,
235236
run_ubuntu=run_ubuntu,
236-
run_android=run_android,
237-
run_ios=run_ios,
238237
run_wasi=run_wasi,
238+
run_windows_msi=run_windows_msi,
239+
run_windows_tests=run_windows_tests,
239240
)
240241

241242

@@ -262,16 +263,16 @@ def write_github_output(outputs: Outputs) -> None:
262263
return
263264

264265
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f:
266+
f.write(f"run-android={bool_lower(outputs.run_android)}\n")
265267
f.write(f"run-ci-fuzz={bool_lower(outputs.run_ci_fuzz)}\n")
266268
f.write(f"run-docs={bool_lower(outputs.run_docs)}\n")
267-
f.write(f"run-tests={bool_lower(outputs.run_tests)}\n")
268-
f.write(f"run-windows-tests={bool_lower(outputs.run_windows_tests)}\n")
269-
f.write(f"run-windows-msi={bool_lower(outputs.run_windows_msi)}\n")
269+
f.write(f"run-ios={bool_lower(outputs.run_ios)}\n")
270270
f.write(f"run-macos={bool_lower(outputs.run_macos)}\n")
271+
f.write(f"run-tests={bool_lower(outputs.run_tests)}\n")
271272
f.write(f"run-ubuntu={bool_lower(outputs.run_ubuntu)}\n")
272-
f.write(f"run-android={bool_lower(outputs.run_android)}\n")
273-
f.write(f"run-ios={bool_lower(outputs.run_ios)}\n")
274273
f.write(f"run-wasi={bool_lower(outputs.run_wasi)}\n")
274+
f.write(f"run-windows-msi={bool_lower(outputs.run_windows_msi)}\n")
275+
f.write(f"run-windows-tests={bool_lower(outputs.run_windows_tests)}\n")
275276

276277

277278
def bool_lower(value: bool, /) -> str:

0 commit comments

Comments
 (0)