Skip to content
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

Fix MacOS version detection #1546

Merged
merged 2 commits into from
Feb 7, 2023
Merged

Fix MacOS version detection #1546

merged 2 commits into from
Feb 7, 2023

Conversation

fweikert
Copy link
Member

@fweikert fweikert commented Feb 6, 2023

#1542 relied on platform.mac_ver() to detect the MacOS version, which did not work as expected. Consequently, the previous PR led the CI to activate an incorrect version of Xcode. This behavior has been fixed by this change.

Related to #1431.

Users can still request a specific Xcode version in their CI config.

bazelbuild#1542 relied on platform.mac_ver() to detect the MacOS version, which did not work as expected.
Consequently, the previous PR led the CI to activate an incorrect version of Xcode.
This behavior has been fixed by this change.

Related to bazelbuild#1431.
@brentleyjones
Copy link

Users can still request a specific Xcode version in their CI config.

Does that work though? Here we set Xcode 13, bazel still tried to use Xcode 14.2.

@fweikert
Copy link
Member Author

fweikert commented Feb 7, 2023

Xcode support on Bazel CI basically means running the following two commands:

/usr/bin/sudo /usr/bin/xcode-select --switch /Applications/Xcode<$VERSION>.app
/usr/bin/sudo /usr/bin/xcodebuild -runFirstLaunch

However, rules_apple seems to be doing its own thing by setting the XCODE_VERSION_OVERRIDE env variable to whatever is returned by apple_common.XcodeVersionConfig. I'm not familiar enough with rules_apple to fix this.

@BalestraPatrick
Copy link
Member

@fweikert Doesn't setting xcode_version: "13.0" run those two commands automatically though? We can see in our CI config that it's selecting 13.0, but right after xcode-locator says that no default version is selected: No default Xcode version is set with 'xcode-select', so I believe it's not actually selecting it correctly.

@meteorcloudy
Copy link
Member

meteorcloudy commented Feb 7, 2023

@fweikert I guess we can verify if xcrun xcodebuild -version returns the correct result after running

/usr/bin/sudo /usr/bin/xcode-select --switch /Applications/Xcode<$VERSION>.app
/usr/bin/sudo /usr/bin/xcodebuild -runFirstLaunch

IIUC, https://cs.opensource.google/bazel/bazel/+/master:tools/osx/xcode_configure.bzl;l=195-197, this is now rules_apple detects the default xcode version and uses it to populate XCODE_VERSION_OVERRIDE later?

@BalestraPatrick
Copy link
Member

So I did some testing, and yes, the Xcode version is correctly selected, but it's an invalid Xcode version for the macOS version that the machine is on. At the moment, when we set xcode_version: "13.0", the CI machine selected is an iMac Pro that runs macOS 13.2, which doesn't support Xcode 13.x anymore. So yes, it's selected, but we can't use it for anything.

As mentioned in this comment, is there a way for us to run on the Mac Studio machines running Monterey instead of Ventura? In that way, we should be able to correctly use Xcode 13.0.

See here the build logs: bazelbuild/rules_apple#1820

@brentleyjones
Copy link

Seems if we set the xcode_version we aren't being routed to a machine that supports that version (sort of the opposite of what the logic here is touching). We want Xcode 13, which means we can't get placed on Ventura machines.

@meteorcloudy
Copy link
Member

I'm not sure how well rules_apple works on Apple Silicon machines, if that's not a concern, you can simply change macos to macos_arm64 at https://github.com/bazelbuild/rules_apple/blob/master/.bazelci/presubmit.yml#LL6C20-L6C20, then all jobs will run on the MacStudio machines.

BTW, how soon will you move the Xcode 14? I guess at some point, we'll have to upgrade the OS of the MacStudio machines as well. Until the virtualization of the mac fleet is done, there is no easy way to switch OS versions for Mac machines on Bazel CI.

@fweikert fweikert merged commit 9e34259 into bazelbuild:master Feb 7, 2023
fmeum pushed a commit to fmeum/continuous-integration that referenced this pull request Dec 10, 2023
bazelbuild#1542 relied on
platform.mac_ver() to detect the MacOS version, which did not work as
expected. Consequently, the previous PR led the CI to activate an
incorrect version of Xcode. This behavior has been fixed by this change.

Related to bazelbuild#1431.

Users can still request a specific Xcode version in their CI config.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants