Skip to content

Commit 3fa7bf4

Browse files
miss-islingtonfreakboy3742hugovk
authored
[3.14] gh-140189: Add CI job to test iOS builds. (GH-140190) (#140696)
Adds a CI configuration to test iOS builds on every build. (cherry picked from commit f4e6370) Co-authored-by: Russell Keith-Magee <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 2e21672 commit 3fa7bf4

File tree

4 files changed

+76
-9
lines changed

4 files changed

+76
-9
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,29 @@ jobs:
386386
- name: Build and test
387387
run: ./Android/android.py ci --fast-ci ${{ matrix.arch }}-linux-android
388388

389+
build-ios:
390+
name: iOS
391+
needs: build-context
392+
if: needs.build-context.outputs.run-tests == 'true'
393+
timeout-minutes: 60
394+
runs-on: macos-15
395+
steps:
396+
- uses: actions/checkout@v4
397+
with:
398+
persist-credentials: false
399+
400+
# GitHub recommends explicitly selecting the desired Xcode version:
401+
# https://github.com/actions/runner-images/issues/12541#issuecomment-3083850140
402+
# This became a necessity as a result of
403+
# https://github.com/actions/runner-images/issues/12541 and
404+
# https://github.com/actions/runner-images/issues/12751.
405+
- name: Select Xcode version
406+
run: |
407+
sudo xcode-select --switch /Applications/Xcode_16.4.app
408+
409+
- name: Build and test
410+
run: python3 Apple ci iOS --fast-ci --simulator 'iPhone 16e,OS=18.5'
411+
389412
build-wasi:
390413
name: 'WASI'
391414
needs: build-context
@@ -694,6 +717,7 @@ jobs:
694717
- build-ubuntu
695718
- build-ubuntu-ssltests
696719
- build-android
720+
- build-ios
697721
- build-wasi
698722
- test-hypothesis
699723
- build-asan
@@ -728,6 +752,7 @@ jobs:
728752
build-ubuntu,
729753
build-ubuntu-ssltests,
730754
build-android,
755+
build-ios,
731756
build-wasi,
732757
test-hypothesis,
733758
build-asan,

Apple/__main__.py

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ def test(context: argparse.Namespace, host: str | None = None) -> None:
823823
+ [
824824
"--",
825825
"test",
826-
"--slow-ci" if context.slow else "--fast-ci",
826+
f"--{context.ci_mode}-ci",
827827
"--single-process",
828828
"--no-randomize",
829829
# Timeout handling requires subprocesses; explicitly setting
@@ -836,11 +836,39 @@ def test(context: argparse.Namespace, host: str | None = None) -> None:
836836
)
837837

838838

839+
def apple_sim_host(platform_name: str) -> str:
840+
"""Determine the native simulator target for this platform."""
841+
for _, slice_parts in HOSTS[platform_name].items():
842+
for host_triple in slice_parts:
843+
parts = host_triple.split('-')
844+
if parts[0] == platform.machine() and parts[-1] == "simulator":
845+
return host_triple
846+
847+
raise KeyError(platform_name)
848+
849+
839850
def ci(context: argparse.Namespace) -> None:
840-
"""The implementation of the "ci" command."""
851+
"""The implementation of the "ci" command.
852+
853+
In "Fast" mode, this compiles the build python, and the simulator for the
854+
build machine's architecture; and runs the test suite with `--fast-ci`
855+
configuration.
856+
857+
In "Slow" mode, it compiles the build python, plus all candidate
858+
architectures (both device and simulator); then runs the test suite with
859+
`--slow-ci` configuration.
860+
"""
841861
clean(context, "all")
842-
build(context, host="all")
843-
test(context, host="all")
862+
if context.ci_mode == "slow":
863+
# In slow mode, build and test the full XCframework
864+
build(context, host="all")
865+
test(context, host="all")
866+
else:
867+
# In fast mode, just build the simulator platform.
868+
sim_host = apple_sim_host(context.platform)
869+
build(context, host="build")
870+
build(context, host=sim_host)
871+
test(context, host=sim_host)
844872

845873

846874
def parse_args() -> argparse.Namespace:
@@ -947,11 +975,13 @@ def parse_args() -> argparse.Namespace:
947975
"an ARM64 iPhone 16 Pro simulator running iOS 26.0."
948976
),
949977
)
950-
cmd.add_argument(
951-
"--slow",
952-
action="store_true",
953-
help="Run tests with --slow-ci options.",
954-
)
978+
group = cmd.add_mutually_exclusive_group()
979+
group.add_argument(
980+
"--fast-ci", action="store_const", dest="ci_mode", const="fast",
981+
help="Add test arguments for GitHub Actions")
982+
group.add_argument(
983+
"--slow-ci", action="store_const", dest="ci_mode", const="slow",
984+
help="Add test arguments for buildbots")
955985

956986
for subcommand in [configure_build, configure_host, build, ci]:
957987
subcommand.add_argument(
@@ -1012,4 +1042,10 @@ def signal_handler(*args):
10121042

10131043

10141044
if __name__ == "__main__":
1045+
# Under the buildbot, stdout is not a TTY, but we must still flush after
1046+
# every line to make sure our output appears in the correct order relative
1047+
# to the output of our subprocesses.
1048+
for stream in [sys.stdout, sys.stderr]:
1049+
stream.reconfigure(line_buffering=True)
1050+
10151051
main()

Apple/testbed/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,9 @@ def main():
412412

413413

414414
if __name__ == "__main__":
415+
# Under the buildbot, stdout is not a TTY, but we must still flush after
416+
# every line to make sure our output appears in the correct order relative
417+
# to the output of our subprocesses.
418+
for stream in [sys.stdout, sys.stderr]:
419+
stream.reconfigure(line_buffering=True)
415420
main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
iOS builds were added to CI.

0 commit comments

Comments
 (0)