From 4eb66bd7e052a42416d7db5b5b51636d6d37ab51 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Mon, 23 Jan 2023 19:53:02 +0100 Subject: [PATCH 1/4] Remove skip_glotpress parameter from the ios_bump_version_release Action --- .../actions/ios/ios_bump_version_release.rb | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb index 03670d08a..2cddf478f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb @@ -21,10 +21,6 @@ def self.run(params) Fastlane::Helper::GitHelper.create_branch(@new_release_branch, from: default_branch) UI.message 'Done!' - UI.message 'Updating glotPressKeys...' unless params[:skip_glotpress] - update_glotpress_key unless params[:skip_glotpress] - UI.message 'Done' unless params[:skip_glotpress] - UI.message 'Updating Fastlane deliver file...' unless params[:skip_deliver] Fastlane::Helper::Ios::VersionHelper.update_fastlane_deliver(@new_short_version) unless params[:skip_deliver] UI.message 'Done!' unless params[:skip_deliver] @@ -35,7 +31,7 @@ def self.run(params) Fastlane::Helper::Ios::GitHelper.commit_version_bump( include_deliverfile: !params[:skip_deliver], - include_metadata: !params[:skip_glotpress] + include_metadata: false ) UI.message 'Done.' @@ -55,16 +51,11 @@ def self.details def self.available_options [ - FastlaneCore::ConfigItem.new(key: :skip_glotpress, - env_name: 'FL_IOS_CODEFREEZE_BUMP_SKIPGLOTPRESS', - description: 'Skips GlotPress key update', - is_string: false, # true: verifies the input is a string, false: every kind of value - default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :skip_deliver, env_name: 'FL_IOS_CODEFREEZE_BUMP_SKIPDELIVER', description: 'Skips Deliver key update', - is_string: false, # true: verifies the input is a string, false: every kind of value - default_value: false), # the default value if the user didn't provide one + type: Boolean, + default_value: false), FastlaneCore::ConfigItem.new(key: :default_branch, env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH', description: 'Default branch of the repository', @@ -105,15 +96,6 @@ def self.show_config UI.message("New short version: #{@new_short_version}") UI.message("Release branch: #{@new_release_branch}") end - - def self.update_glotpress_key - dm_file = ENV['DOWNLOAD_METADATA'] - if File.exist?(dm_file) - sh("sed -i '' \"s/let glotPressWhatsNewKey.*/let glotPressWhatsNewKey = \\\"v#{@new_short_version}-whats-new\\\"/\" #{dm_file}") - else - UI.user_error!("Can't find #{dm_file}.") - end - end end end end From 32d3d8eba2c3894998cd9ba544fae168708d5866 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Mon, 23 Jan 2023 23:16:58 +0100 Subject: [PATCH 2/4] Add basic unit tests for Action ios_bump_version_release --- spec/ios_bump_version_release_spec.rb | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 spec/ios_bump_version_release_spec.rb diff --git a/spec/ios_bump_version_release_spec.rb b/spec/ios_bump_version_release_spec.rb new file mode 100644 index 000000000..7cc1df250 --- /dev/null +++ b/spec/ios_bump_version_release_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe Fastlane::Actions::IosBumpVersionReleaseAction do + let(:default_branch) { 'my_new_branch' } + let(:ensure_git_action_instance) { double() } + let(:versions) { ['6.30'] } + let(:next_version) { '6.31.0.0' } + let(:next_version_short) { '6.31' } + + describe 'creates the release branch, bumps the app version and commits the changes' do + before do + allow(Fastlane::Action).to receive(:other_action).and_return(ensure_git_action_instance) + allow(ensure_git_action_instance).to receive(:ensure_git_branch).with(branch: default_branch) + + allow(Fastlane::Helper::GitHelper).to receive(:checkout_and_pull).with(default_branch) + allow(Fastlane::Helper::GitHelper).to receive(:create_branch).with("release/#{next_version_short}", from: default_branch) + + allow(Fastlane::Helper::Ios::VersionHelper).to receive(:get_version_strings).and_return(versions) + allow(Fastlane::Helper::Ios::VersionHelper).to receive(:update_xc_configs).with(next_version, next_version_short, nil) + end + + it 'does the fastlane deliver update' do + skip_deliver = false + + expect(Fastlane::Helper::Ios::VersionHelper).to receive(:update_fastlane_deliver).with(next_version_short) + expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump).with(include_deliverfile: !skip_deliver, include_metadata: false) + + run_described_fastlane_action( + skip_deliver: skip_deliver, + default_branch: default_branch + ) + end + + it 'skips the fastlane deliver update properly' do + skip_deliver = true + + expect(Fastlane::Helper::Ios::VersionHelper).not_to receive(:update_fastlane_deliver) + expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump).with(include_deliverfile: !skip_deliver, include_metadata: false) + + run_described_fastlane_action( + skip_deliver: skip_deliver, + default_branch: default_branch + ) + end + end +end From 8953126f505a183c64461e01c51c1a5d8f163d9d Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Tue, 24 Jan 2023 23:27:31 +0100 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b39ab1f2d..22075a2d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ### Breaking Changes -_None_ +- Remove the `skip_glotpress` parameter from the `ios_bump_version_release` action [#443] ### New Features From 7449556bee6a5e15885cd40aa6962e6cfa639041 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Thu, 26 Jan 2023 00:12:51 +0100 Subject: [PATCH 4/4] Improve naming for other_action mock (PR comment) --- spec/ios_bump_version_release_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/ios_bump_version_release_spec.rb b/spec/ios_bump_version_release_spec.rb index 7cc1df250..f2a3f882e 100644 --- a/spec/ios_bump_version_release_spec.rb +++ b/spec/ios_bump_version_release_spec.rb @@ -2,15 +2,15 @@ describe Fastlane::Actions::IosBumpVersionReleaseAction do let(:default_branch) { 'my_new_branch' } - let(:ensure_git_action_instance) { double() } let(:versions) { ['6.30'] } let(:next_version) { '6.31.0.0' } let(:next_version_short) { '6.31' } describe 'creates the release branch, bumps the app version and commits the changes' do before do - allow(Fastlane::Action).to receive(:other_action).and_return(ensure_git_action_instance) - allow(ensure_git_action_instance).to receive(:ensure_git_branch).with(branch: default_branch) + other_action_mock = double() + allow(Fastlane::Action).to receive(:other_action).and_return(other_action_mock) + allow(other_action_mock).to receive(:ensure_git_branch).with(branch: default_branch) allow(Fastlane::Helper::GitHelper).to receive(:checkout_and_pull).with(default_branch) allow(Fastlane::Helper::GitHelper).to receive(:create_branch).with("release/#{next_version_short}", from: default_branch)