-
Notifications
You must be signed in to change notification settings - Fork 8
Add ios_get_build_number action
#458
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8646fad
Add `get_build_number`
spencertransier 52549cd
Add `ios_get_build_number` action
spencertransier a55fe1d
Update the class name
spencertransier c91822b
Use `read_build_number_from_config_file`
spencertransier 4ed75df
Merge branch 'trunk' into add/get-build-number-action
spencertransier 5791070
Update CHANGELOG.md
spencertransier 4a3c89d
Add config item for using a path instead of env variable
spencertransier 5bc84ed
Call correct VersionHelper method
spencertransier 6638650
Add argument
spencertransier 6980bd9
Don't need to specify that it's public
spencertransier b083991
Re-add comma
spencertransier d9d69c5
Use `type` instead of `is_string`
spencertransier 7a15bb3
Merge branch 'trunk' into add/get-build-number-action
spencertransier bd10f19
Added unit tests for `ios_get_build_number`
spencertransier 425ae82
Fix Rubocop violation
spencertransier 4c73bc8
Remove _none_ from changelog
spencertransier d514621
Pass 'file/not/found' directly
spencertransier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_number.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| module Fastlane | ||
| module Actions | ||
| class IosGetBuildNumberAction < Action | ||
| def self.run(params) | ||
| require_relative '../../helper/ios/ios_version_helper' | ||
|
|
||
| xcconfig_file_path = params[:xcconfig_file_path] | ||
| Fastlane::Helper::Ios::VersionHelper.read_build_number_from_config_file(xcconfig_file_path) | ||
| end | ||
|
|
||
| ##################################################### | ||
| # @!group Documentation | ||
| ##################################################### | ||
|
|
||
| def self.description | ||
| 'Gets the build number of the app' | ||
| end | ||
|
|
||
| def self.details | ||
| 'Gets the build number of the app' | ||
| end | ||
|
|
||
| def self.available_options | ||
| [ | ||
| FastlaneCore::ConfigItem.new( | ||
| key: :xcconfig_file_path, | ||
| env_name: 'FL_IOS_XCCONFIG_FILE_PATH', | ||
| description: 'Path to the .xcconfig file containing the build number', | ||
| type: String, | ||
| optional: false | ||
| ), | ||
| ] | ||
| end | ||
|
|
||
| def self.output | ||
| # Define the shared values you are going to provide | ||
| end | ||
|
|
||
| def self.return_value | ||
| # If you method provides a return value, you can describe here what it does | ||
| 'Return the build number of the app' | ||
| end | ||
|
|
||
| def self.authors | ||
| # So no one will ever forget your contribution to fastlane :) You are awesome btw! | ||
| ['Automattic'] | ||
| end | ||
|
|
||
| def self.is_supported?(platform) | ||
| [:ios, :mac].include?(platform) | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| require 'spec_helper' | ||
|
|
||
| describe Fastlane::Actions::IosGetBuildNumberAction do | ||
| describe 'getting the build number from the provided .xcconfig file' do | ||
| it 'parses an xcconfig file with keys without spacing and returns the correct build number' do | ||
| xcconfig_mock_content = <<~CONTENT | ||
| // a comment | ||
| VERSION_SHORT=6 | ||
| VERSION_LONG=6.30.0 | ||
| BUILD_NUMBER=1940 | ||
| CONTENT | ||
|
|
||
| expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: '1940') | ||
| end | ||
|
|
||
| it 'parses an xcconfig file with keys with spaces and returns a nil build number' do | ||
| xcconfig_mock_content = <<~CONTENT | ||
| VERSION_SHORT = 6 | ||
| VERSION_LONG = 6.30.1 | ||
| BUILD_NUMBER = 1940 | ||
| CONTENT | ||
|
|
||
| expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: nil) | ||
| end | ||
|
|
||
| it 'parses an xcconfig file with an invalid format and returns a nil build number' do | ||
| xcconfig_mock_content = <<~CONTENT | ||
| VERSION_SHORT = 6 | ||
| VERSION_LONG = 6.30.1 | ||
| BUILD_NUMBER 1940 | ||
| CONTENT | ||
|
|
||
| expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: nil) | ||
| end | ||
|
|
||
| it 'parses an xcconfig file with no build number and returns a nil build number' do | ||
| xcconfig_mock_content = <<~CONTENT | ||
| VERSION_SHORT = 6 | ||
| // a comment | ||
| CONTENT | ||
|
|
||
| expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: nil) | ||
| end | ||
|
|
||
| it 'throws an error when the xcconfig file does not exist' do | ||
| expect do | ||
| run_described_fastlane_action( | ||
| xcconfig_file_path: 'file/not/found' | ||
| ) | ||
| # Ruby error for 'No such file or directory': https://ruby-doc.org/core-2.7.4/SystemCallError.html | ||
| end.to raise_error(Errno::ENOENT) | ||
| end | ||
|
|
||
| def expect_build_number(xcconfig_mock_content:, expected_build_number:) | ||
| with_tmp_file(named: 'mock_xcconfig.xcconfig', content: xcconfig_mock_content) do |tmp_file_path| | ||
| build_number_result = run_described_fastlane_action( | ||
| xcconfig_file_path: tmp_file_path | ||
| ) | ||
|
|
||
| expect(build_number_result).to eq(expected_build_number) | ||
| end | ||
| end | ||
| end | ||
| end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 was surprised by this because
key = valueis a validxcconfigsyntax. Looking at the pre-existing, underlying implementation, I can see why this is required given that we manually parse thexcconfigfilesrelease-toolkit/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb
Lines 286 to 302 in e4b28a4
We should be able to replace that bespoke logic with the API provided by the
xcodeprojgem like we do in Jetpack and WordPress iOS: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.
It looks like @iangmaia already started working on using
xcodeprojinstead of the manual parsing: #451I decided to implement this as-is and update it as needed after Ian's PRs are fully merged into the project.