Skip to content

Commit 255d108

Browse files
committed
GithubHelper#create_milestone: Rename parameters to be more descriptive
1 parent 10528de commit 255d108

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@ def self.run(params)
1111

1212
github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
1313
last_stone = github_helper.get_last_milestone(repository)
14+
1415
UI.message("Last detected milestone: #{last_stone[:title]} due on #{last_stone[:due_on]}.")
16+
1517
milestone_duedate = last_stone[:due_on]
1618
milestone_duration = params[:milestone_duration]
1719
newmilestone_duedate = (milestone_duedate.to_datetime.next_day(milestone_duration).to_time).utc
1820
newmilestone_number = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(last_stone[:title])
1921
number_of_days_from_code_freeze_to_release = params[:number_of_days_from_code_freeze_to_release]
22+
# If there is a review process, we want to submit the binary 3 days before its release
23+
# Using 3 days is mostly for historical reasons where we release the apps on Monday and submit them on Friday.
24+
days_until_submission = params[:need_appstore_submission] ? (number_of_days_from_code_freeze_to_release - 3) : milestone_duration
25+
2026
UI.message("Next milestone: #{newmilestone_number} due on #{newmilestone_duedate}.")
27+
2128
github_helper.create_milestone(
2229
repository: repository,
23-
newmilestone_number: newmilestone_number,
24-
newmilestone_duedate: newmilestone_duedate,
25-
newmilestone_duration: milestone_duration,
26-
number_of_days_from_code_freeze_to_release: number_of_days_from_code_freeze_to_release,
27-
need_submission: params[:need_appstore_submission]
30+
title: newmilestone_number,
31+
due_date: newmilestone_duedate,
32+
days_until_submission: days_until_submission,
33+
days_until_release: number_of_days_from_code_freeze_to_release
2834
)
2935
end
3036

lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,16 @@ def get_last_milestone(repository)
7474
# Creates a new milestone
7575
#
7676
# @param [String] repository The repository name, including the organization (e.g. `wordpress-mobile/wordpress-ios`)
77-
# @param [String] newmilestone_number The name of the milestone we want to create (e.g.: `16.9`)
78-
# @param [Time] newmilestone_duedate milestone due date (e.g. `2022-10-22T12:00:00Z`)
79-
# @param [Integer] newmilestone_duration Number of days that a milestone extents
80-
# @param [Integer] number_of_days_from_code_freeze_to_release Number of days from code freeze to release
81-
# @param [Boolean] need_submission The app needs to be submitted?
82-
# if `true`, will subtract 3 days from the `:number_of_days_from_code_freeze_to_release`.
83-
# if `false`, will use the days of `:newmilestone_duration`
84-
#
85-
def create_milestone(repository:, newmilestone_number:, newmilestone_duedate:, newmilestone_duration:, number_of_days_from_code_freeze_to_release:, need_submission:)
86-
# If there is a review process, we want to submit the binary 3 days before its release
87-
#
88-
# Using 3 days is mostly for historical reasons where we release the apps on Monday and submit them on Friday.
89-
days_until_submission = need_submission ? (number_of_days_from_code_freeze_to_release - 3) : newmilestone_duration
90-
submission_date = newmilestone_duedate.to_datetime.next_day(days_until_submission)
91-
release_date = newmilestone_duedate.to_datetime.next_day(number_of_days_from_code_freeze_to_release)
77+
# @param [String] title The name of the milestone we want to create (e.g.: `16.9`)
78+
# @param [Time] due_date milestone due date (e.g. `2022-10-22T12:00:00Z`)
79+
# @param [Integer] days_until_submission Number of days until submission
80+
# @param [Integer] days_until_release Number of days from code freeze to release
81+
#
82+
def create_milestone(repository:, title:, due_date:, days_until_submission:, days_until_release:)
83+
submission_date = due_date.to_datetime.next_day(days_until_submission)
84+
release_date = due_date.to_datetime.next_day(days_until_release)
9285
comment = <<~MILESTONE_DESCRIPTION
93-
Code freeze: #{newmilestone_duedate.to_datetime.strftime('%B %d, %Y')}
86+
Code freeze: #{due_date.to_datetime.strftime('%B %d, %Y')}
9487
App Store submission: #{submission_date.strftime('%B %d, %Y')}
9588
Release: #{release_date.strftime('%B %d, %Y')}
9689
MILESTONE_DESCRIPTION
@@ -107,9 +100,9 @@ def create_milestone(repository:, newmilestone_number:, newmilestone_duedate:, n
107100
#
108101
# This is a bug in the GitHub API, not in our date computation logic.
109102
# To solve this, we trick it by forcing the time component of the ISO date we send to be `12:00:00Z`.
110-
options[:due_on] = newmilestone_duedate.strftime('%Y-%m-%dT12:00:00Z')
103+
options[:due_on] = due_date.strftime('%Y-%m-%dT12:00:00Z')
111104
options[:description] = comment
112-
client.create_milestone(repository, newmilestone_number, options)
105+
client.create_milestone(repository, title, options)
113106
end
114107

115108
# Creates a Release on GitHub as a Draft

spec/github_helper_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ def get_milestone(milestone_name:)
234234
end
235235

236236
def create_milestone(need_submission:, milestone_duration:, days_code_freeze:)
237+
days_until_submission = need_submission ? (days_code_freeze - 3) : milestone_duration
237238
helper = described_class.new(github_token: 'Fake-GitHubToken-123')
238239
helper.create_milestone(
239240
repository: test_repo,
240-
newmilestone_number: test_milestone_number,
241-
newmilestone_duedate: test_milestone_duedate.to_time.utc,
242-
newmilestone_duration: milestone_duration,
243-
number_of_days_from_code_freeze_to_release: days_code_freeze,
244-
need_submission: need_submission
241+
title: test_milestone_number,
242+
due_date: test_milestone_duedate.to_time.utc,
243+
days_until_submission: days_until_submission,
244+
days_until_release: days_code_freeze
245245
)
246246
end
247247
end

0 commit comments

Comments
 (0)