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
showBuildSettings does not require to call clean #8921
Conversation
….3 because Xcode bug has being fixed and this workaround is not required anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 looking promising, left a couple of comments
many thx for your contribution @punty
fastlane_core/spec/project_spec.rb
Outdated
@@ -299,7 +299,12 @@ def within_a_temp_dir | |||
it "SUPPORTED_PLATFORMS should be iphonesimulator iphoneos" do | |||
options = { project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" } | |||
@project = FastlaneCore::Project.new(options, xcodebuild_list_silent: true, xcodebuild_suppress_stderr: true) | |||
expect(FastlaneCore::Project).to receive(:run_command).with("xcodebuild clean -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2> /dev/null", { timeout: 10, retries: 3, print: false }).and_return(File.read("./fastlane_core/spec/fixtures/projects/build_settings_with_toolchains")) | |||
if FastlaneCore::Helper.xcode_higher_than_8_3? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this should be splitted up into 2 tests. with mocked return of xcode_atleast
on time with false
and one time with true
to be sure that it works on old and new xcodes.
the current variation is depending on the local xcode installation.
@@ -213,6 +213,13 @@ def self.keychain_path(name) | |||
keychain_path | |||
end | |||
|
|||
# @return true if XCode version is higher than 8.3 | |||
def self.xcode_higher_than_8_3? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename this to: self.xcode_atleast?(version)
- so we can use this method for variuous version checks of xcode?
def self.xcode_higher_than_8_3? | ||
FastlaneCore::UI.user_error!("Unable to locate Xcode. Please make sure to have Xcode installed on your machine") if xcode_version.nil? | ||
v = xcode_version | ||
Gem::Version.new(v) >= Gem::Version.new('8.3.0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and use it here: Gem::Version.new(v) >= Gem::Version.new(version)
gym/lib/gym/xcode.rb
Outdated
UI.user_error!("Unable to locate Xcode. Please make sure to have Xcode installed on your machine") if xcode_version.nil? | ||
v = xcode_version | ||
Gem::Version.new(v) >= Gem::Version.new('8.3.0') | ||
FastlaneCore::Helper.xcode_higher_than_8_3? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then use FastlaneCore::Helper.xcode_atleast?("8.3")
- Update Unit Testing
@hjanuschka I implemented the changes you requested! Much better! |
fastlane_core/spec/project_spec.rb
Outdated
expect(@project.build_settings(key: "SUPPORTED_PLATFORMS")).to eq("iphonesimulator iphoneos") | ||
end | ||
unless FastlaneCore::Helper.xcode_atleast?('8.3') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we get rid of the unless, and mock the result of xcode_atleast to 8.1?
removing the unless and turning the allow
to an expect
should do it, the allow should also be changed in the above test. so we always no matter which local xcode is installed verify it works on 8.1 and 8.3
or i am i wrong?
thx for your patience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this. According to the official Apple documentation, the XCode bug has being fixed in 8.3, so if we are running this test, by mocking the call to return true, we will end up calling showBuildSettings without the clean command (even for XCode < 8.3). So in this case there is a risk this command will hangs?
According to Apple this happens only if the project contains Core Data. But I still think we should include test for scenarios that are not possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow is used for Mocking, https://www.relishapp.com/rspec/rspec-mocks/v/2-14/docs/method-stubs so when I call that method i return true or false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the command is not really run in the tests.
expect(FastlaneCore::Project).to receive(:run_command).with(command.to_s, { timeout: 10, retries: 3, print: false }).and_return(File.read("./fastlane_core/spec/fixtures/projects/build_settings_with_toolchains"))
mocks it.
the goal should be to test the following two scenarios.
user has xcode < 8.3
- force
xcode_atleast?("8.3")
to returnfalse
- expect the resulting command, to include
clean
user has xcode >= 8.3
- force
xcode_atleast?("8.3")
to returntrue
- expect the resulting command, to NOT include
clean
by forcing the result we bypass the local installation interfering the unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the clarification. I will have a look at that!
@punty awesome, looking solid 👍 thx for your work and patience, one comment left. |
@hjanuschka thanks again for your suggestions! I implemented the changes you requested |
@@ -213,6 +213,13 @@ def self.keychain_path(name) | |||
keychain_path | |||
end | |||
|
|||
# @return true if XCode version is higher than 8.3 | |||
def self.xcode_atleast?(version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xcode_at_least?
fastlane_core/spec/project_spec.rb
Outdated
@@ -296,10 +296,21 @@ def within_a_temp_dir | |||
end | |||
|
|||
describe "build_settings() can handle empty lines" do | |||
it "SUPPORTED_PLATFORMS should be iphonesimulator iphoneos" do | |||
it "SUPPORTED_PLATFORMS should be iphonesimulator iphoneos on XCode >= 8.3" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xcode
# The 'clean' portion of this command is a workaround for an xcodebuild bug with Core Data projects. | ||
# See: https://github.com/fastlane/fastlane/pull/5626 | ||
command = "xcodebuild clean -showBuildSettings #{xcodebuild_parameters.join(' ')}" | ||
if FastlaneCore::Helper.xcode_atleast?('8.3') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you reference in a command on why this was added, when it was fixed, etc.
- add more comments and fix some typos
@KrauseFx thanks for your feedback. I just implemented the changes you requested. |
@punty 🚀 merged, many thx for your contribution 🎉 |
Congratulations! 🎉 This was released as part of fastlane 2.28.3 🚀 |
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validDescription
In show building settings, don't call xcodebuild clean, because it's not a necessary workaround anymore.
Motivation and Context
This change will allow the user to do not clean the build (unless specified in the following commands).
Previously for example event setting clean: false, will result in callling clean because of the generated
xcodebuild clean -showBuildSettings
As stated in the comment this was a workaround for an xcodebuild bug. But this bug has being fixed in 8.3 so it's not necessary anymore. https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html
As huge benefit, I can keep using fastlane with my CI, and for example, caching pod builds, and reduce my build time significantly.
This pull request also fixes #8099