Skip to content

Commit 6106993

Browse files
keithaaronsky
andauthored
Fix CI by pinning to old versions temporarily (#2802)
- Also fixes google/xctestrunner#70 but for the other rule in this repo - Adds xctestrunner patches which are needed for newer Xcode versions --------- Signed-off-by: Aaron Sky <aaronsky@skyaaron.com> Co-authored-by: Aaron Sky <aaronsky@skyaaron.com>
1 parent e73bc35 commit 6106993

10 files changed

Lines changed: 135 additions & 45 deletions

File tree

.bazelci/presubmit.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ x_defaults:
44
# it doesn't know about; so that is used to avoid repeating common subparts.
55
common: &common
66
platform: macos_arm64
7+
xcode_version: "16.4"
78
shell_commands:
89
- xcrun simctl runtime list
9-
- xcrun simctl runtime delete 22D8075 || true
10-
- xcrun simctl runtime delete 21F79 || true
10+
- xcodebuild -downloadPlatform iOS -buildVersion 18.5
11+
- xcrun simctl runtime match set iphoneos18.5 22F77
1112
- xcrun simctl runtime list
1213
- xcrun simctl runtime match list
13-
- xcrun simctl runtime match set xros2.2 22N895
14-
- xcrun simctl runtime match list
1514
post_shell_commands:
16-
- xcrun simctl runtime match set xros2.2 --default
15+
- xcrun simctl runtime match set iphoneos18.5 --default
1716
- xcrun simctl runtime match list
1817
build_targets:
1918
- "tools/..."
@@ -36,24 +35,32 @@ x_defaults:
3635
# NOTE: To avoid listing the same things for build_flags/test_flags for each
3736
# of these tasks, they are listed in the .bazelrc instead.
3837
tasks:
39-
macos_latest:
40-
name: "Current LTS"
41-
bazel: latest
38+
macos_7.x:
39+
name: "7.x"
40+
bazel: 7.x
4241
<<: *common
4342

44-
macos_last_rc:
45-
name: "Last RC Bazel"
46-
bazel: last_rc
43+
macos_8.x:
44+
name: "8.x"
45+
bazel: 8.x
4746
<<: *common
4847

48+
# TODO: Re-enable when we fix bazel 9.x
49+
# macos_last_rc:
50+
# name: "Last RC Bazel"
51+
# bazel: last_rc
52+
# <<: *common
53+
4954
macos_last_green:
5055
name: "Last Green Bazel"
51-
bazel: last_green
56+
# TODO: Move back to last_green ASAP
57+
bazel: 5409637c4e2d5c010b7264172b1004a2afd46bfe
5258
<<: *common
5359

5460
doc_tests:
5561
name: "Doc tests"
56-
bazel: last_green
62+
# TODO: Move back to last_green once rules_cc is fixed
63+
bazel: 48555196ef92f54d0a331a01dac9db0a6aabc8b4
5764
platform: ubuntu2004
5865
test_targets:
5966
- "doc/..."

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rolling
1+
5409637c4e2d5c010b7264172b1004a2afd46bfe

apple/internal/xctrunner.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def _xctrunner_impl(ctx):
113113
args = ctx.actions.args()
114114
args.add("--name", ctx.attr.name)
115115
args.add("--platform", PLATFORM_MAP[platform])
116+
args.add("--xcode-version", xcode_config.xcode_version())
116117
if ctx.attr.verbose:
117118
args.add("--verbose", ctx.attr.verbose)
118119

apple/repositories.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,12 @@ def apple_rules_dependencies(ignore_version_differences = False, include_bzlmod_
146146
],
147147
strip_prefix = "xctestrunner-8710f141dfb0a3efe2744f865f914783259c24b0",
148148
sha256 = "34d3b9bcb3dcb5b2a0bf2cd4be58c03f6a0f0eb4329f87cd758461aeb00e9326",
149+
patch_args = ["-p1"],
150+
patches = [
151+
# https://github.com/google/xctestrunner/pull/76
152+
"//tools/patches:xctestrunner_loads.patch",
153+
# https://github.com/google/xctestrunner/pull/71
154+
"//tools/patches:xctestrunner_framework.patch",
155+
],
149156
ignore_version_differences = ignore_version_differences,
150157
)

test/starlark_tests/docc_tests.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def docc_test_suite(name):
4040
text_test_file = "$BUNDLE_ROOT/metadata.json",
4141
text_test_values = [
4242
"\"bundleDisplayName\":\"app_with_swift_dep\"",
43-
"\"bundleIdentifier\":\"com.google.example\"",
43+
"\"bundleID\":\"com.google.example\"",
4444
"\"major\":0",
4545
"\"minor\":1",
4646
"\"patch\":0",
@@ -60,7 +60,7 @@ def docc_test_suite(name):
6060
text_test_file = "$BUNDLE_ROOT/metadata.json",
6161
text_test_values = [
6262
"\"bundleDisplayName\":\"BasicFramework\"",
63-
"\"bundleIdentifier\":\"com.google.example.framework\"",
63+
"\"bundleID\":\"com.google.example.framework\"",
6464
"\"major\":0",
6565
"\"minor\":1",
6666
"\"patch\":0",
@@ -80,7 +80,7 @@ def docc_test_suite(name):
8080
text_test_file = "$BUNDLE_ROOT/metadata.json",
8181
text_test_values = [
8282
"\"bundleDisplayName\":\"BasicLib\"",
83-
"\"bundleIdentifier\":\"com.google.example.objc.lib\"",
83+
"\"bundleID\":\"com.google.example.objc.lib\"",
8484
"\"major\":0",
8585
"\"minor\":1",
8686
"\"patch\":0",

tools/patches/BUILD

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git a/xctestrunner/test_runner/xctestrun.py b/xctestrunner/test_runner/xctestrun.py
2+
index e0f2ef5..4dbae1c 100644
3+
--- a/xctestrunner/test_runner/xctestrun.py
4+
+++ b/xctestrunner/test_runner/xctestrun.py
5+
@@ -649,11 +649,18 @@ def _GenerateTestRootForXctest(self):
6+
os.path.join(platform_path, _LIB_XCTEST_SWIFT_RELATIVE_PATH),
7+
app_under_test_frameworks_dir, app_under_test_signing_identity)
8+
if xcode_info_util.GetXcodeVersionNumber() >= 1300:
9+
- _CopyAndSignFramework(
10+
- os.path.join(
11+
- platform_path, 'Developer/Library/PrivateFrameworks/'
12+
- 'XCUIAutomation.framework'),
13+
- app_under_test_frameworks_dir, app_under_test_signing_identity)
14+
+ if xcode_info_util.GetXcodeVersionNumber() >= 1640:
15+
+ _CopyAndSignFramework(
16+
+ os.path.join(
17+
+ platform_path, 'Developer/Library/Frameworks/'
18+
+ 'XCUIAutomation.framework'),
19+
+ app_under_test_frameworks_dir, app_under_test_signing_identity)
20+
+ else:
21+
+ _CopyAndSignFramework(
22+
+ os.path.join(
23+
+ platform_path, 'Developer/Library/PrivateFrameworks/'
24+
+ 'XCUIAutomation.framework'),
25+
+ app_under_test_frameworks_dir, app_under_test_signing_identity)
26+
_CopyAndSignFramework(
27+
os.path.join(
28+
platform_path, 'Developer/Library/PrivateFrameworks/'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff --git a/BUILD b/BUILD
2+
index e73145e..050376c 100644
3+
--- a/BUILD
4+
+++ b/BUILD
5+
@@ -1,3 +1,5 @@
6+
+load("@rules_python//python:defs.bzl", "py_binary", "py_library")
7+
+
8+
package(default_visibility = ["//visibility:public"])
9+
10+
py_library(
11+
@@ -15,7 +17,10 @@ py_library(
12+
13+
py_binary(
14+
name = "ios_test_runner",
15+
- srcs = ["__init__.py", "xctestrunner/__init__.py"] + glob(
16+
+ srcs = [
17+
+ "__init__.py",
18+
+ "xctestrunner/__init__.py",
19+
+ ] + glob(
20+
["xctestrunner/test_runner/*.py"],
21+
),
22+
main = "xctestrunner/test_runner/ios_test_runner.py",
23+
diff --git a/MODULE.bazel b/MODULE.bazel
24+
index 0ed8806..258f0a4 100644
25+
--- a/MODULE.bazel
26+
+++ b/MODULE.bazel
27+
@@ -3,3 +3,5 @@ module(
28+
version = "0.2.15",
29+
compatibility_level = 1,
30+
)
31+
+
32+
+bazel_dep(name = "rules_python", version = "1.0.0")

tools/xctrunnertool/lib/dependencies.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

tools/xctrunnertool/run.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from lib.shell import shell, cp_r
1111
from lib.model import Configuration
1212
from lib.lipo_util import LipoUtil
13-
from lib.dependencies import FRAMEWORK_DEPS, PRIVATE_FRAMEWORK_DEPS, DYLIB_DEPS
1413

1514

1615
class DefaultHelpParser(argparse.ArgumentParser):
@@ -22,6 +21,17 @@ def error(self, message):
2221
sys.exit(2)
2322

2423

24+
def _parse_xcode_version(version_str: str) -> int:
25+
"""Gets the version number of the given version string."""
26+
parts = version_str.split('.')
27+
version_number = int(parts[0]) * 100
28+
if len(parts) > 1:
29+
version_number += int(parts[1]) * 10
30+
if len(parts) > 2:
31+
version_number += int(parts[2])
32+
return version_number
33+
34+
2535
def main(argv) -> None:
2636
"Script entrypoint."
2737
parser = DefaultHelpParser()
@@ -46,6 +56,11 @@ def main(argv) -> None:
4656
action="append",
4757
help="Path to xctest archive to bundle.",
4858
)
59+
parser.add_argument(
60+
"--xcode-version",
61+
required=True,
62+
help="Current Xcode version.",
63+
)
4964
parser.add_argument(
5065
"--verbose",
5166
required=False,
@@ -142,8 +157,32 @@ def main(argv) -> None:
142157
plist["CFBundleIdentifier"] = config.xctrunner.bundle_identifier
143158
plistlib.dump(plist, open(config.xctrunner.info_plist_path, "wb"))
144159

160+
161+
framework_deps = [
162+
"XCTest.framework",
163+
"Testing.framework", # Xcode 16+
164+
]
165+
166+
private_framework_deps = [
167+
"XCTAutomationSupport.framework",
168+
"XCTestCore.framework",
169+
"XCTestSupport.framework",
170+
"XCUnit.framework",
171+
]
172+
173+
dylib_deps = [
174+
"libXCTestBundleInject.dylib",
175+
"libXCTestSwiftSupport.dylib",
176+
]
177+
178+
xcode_version_int = _parse_xcode_version(args.xcode_version)
179+
if xcode_version_int >= 1640:
180+
framework_deps.append("XCUIAutomation.framework")
181+
else:
182+
private_framework_deps.append("XCUIAutomation.framework")
183+
145184
# Copy dependencies to the bundle and remove unwanted architectures
146-
for framework in FRAMEWORK_DEPS:
185+
for framework in framework_deps:
147186
log.info("Bundling fwk: %s", framework)
148187
fwk_path = f"{config.xcode.frameworks_dir}/{framework}"
149188

@@ -162,7 +201,7 @@ def main(argv) -> None:
162201
bin_path, archs_to_keep
163202
) # Strip architectures not in test bundles.
164203

165-
for framework in PRIVATE_FRAMEWORK_DEPS:
204+
for framework in private_framework_deps:
166205
log.info("Bundling fwk: %s", framework)
167206
cp_r(
168207
f"{config.xcode.private_frameworks_dir}/{framework}",
@@ -172,7 +211,7 @@ def main(argv) -> None:
172211
bin_path = f"{config.xctrunner.path}/Frameworks/{framework}/{fwk_binary}"
173212
lipo.extract_or_thin(bin_path, archs_to_keep)
174213

175-
for dylib in DYLIB_DEPS:
214+
for dylib in dylib_deps:
176215
log.info("Bundling dylib: %s", dylib)
177216
shutil.copy(
178217
f"{config.xcode.dylib_dir}/{dylib}",

0 commit comments

Comments
 (0)