Skip to content

Commit d64c0dd

Browse files
committed
Add explanation when release task is not found while bumping a release
1 parent 06c80f0 commit d64c0dd

3 files changed

Lines changed: 45 additions & 16 deletions

File tree

lib/fastlane/plugin/ddg_apple_automation/actions/validate_internal_release_bump_action.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ def self.run(params)
3535

3636
def self.find_release_task_if_needed(params)
3737
if params[:release_task_url].to_s.empty?
38-
params.merge!(
39-
Fastlane::Actions::AsanaFindReleaseTaskAction.run(
40-
asana_access_token: params[:asana_access_token],
41-
github_token: params[:github_token],
42-
platform: params[:platform]
38+
begin
39+
params.merge!(
40+
Fastlane::Actions::AsanaFindReleaseTaskAction.run(
41+
asana_access_token: params[:asana_access_token],
42+
github_token: params[:github_token],
43+
platform: params[:platform]
44+
)
4345
)
44-
)
46+
rescue FastlaneCore::Interface::FastlaneError
47+
UI.important("Regular release task not found. If this is an automatic bump after merging a hotfix branch, this failure is expected. Rerun this workflow from an internal release branch, providing the release task URL explicitly.")
48+
raise
49+
end
4550
else
4651
params[:release_task_id] = Helper::AsanaHelper.extract_asana_task_id(params[:release_task_url], set_gha_output: false)
4752
other_action.ensure_git_branch(branch: "^release/.+$")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Fastlane
22
module DdgAppleAutomation
3-
VERSION = "3.1.1"
3+
VERSION = "3.1.2"
44
end
55
end

spec/validate_internal_release_bump_action_spec.rb

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
allow(Fastlane::Actions).to receive(:other_action).and_return(@other_action)
2222
allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:find_latest_marketing_version)
2323
.and_return("1.0.0")
24-
25-
allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed) do |params|
26-
params[:release_branch] = "release_branch_name"
27-
params[:release_task_id] = "mock_task_id"
28-
end
2924
end
3025
end
3126

@@ -48,6 +43,13 @@
4843
end
4944
include_context "common setup"
5045

46+
before do
47+
allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed) do |params|
48+
params[:release_branch] = "release_branch_name"
49+
params[:release_task_id] = "mock_task_id"
50+
end
51+
end
52+
5153
context "when there are changes in the release branch" do
5254
it "proceeds with release bump if release notes are valid" do
5355
expect(Fastlane::UI).to receive(:message).with("Validating release notes")
@@ -94,11 +96,17 @@
9496
describe "#find_release_task_if_needed" do
9597
include_context "common setup"
9698

99+
subject { Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params) }
100+
97101
context "when release_task_url is provided" do
102+
before do
103+
@params[:release_task_url] = "https://app.asana.com/0/1234567890/987654321"
104+
end
105+
98106
it "sets release_task_id and release_branch from release_task_url" do
99107
allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed).and_call_original
100-
@params[:release_task_url] = "https://app.asana.com/0/1234567890/987654321"
101-
Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params)
108+
109+
subject
102110

103111
expect(Fastlane::Helper::AsanaHelper).to have_received(:extract_asana_task_id).with(@params[:release_task_url], set_gha_output: false)
104112
expect(Fastlane::Actions.other_action).to have_received(:ensure_git_branch).with(branch: "^release/.+$")
@@ -108,10 +116,14 @@
108116
end
109117

110118
context "when release_task_url is not provided" do
119+
before do
120+
@params[:release_task_url] = nil
121+
end
122+
111123
it "runs AsanaFindReleaseTaskAction to find the release task" do
112-
allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed).and_call_original
113124
allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:run).and_return({ release_task_id: "1234567890", release_branch: "release_branch_name" })
114-
Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params)
125+
126+
subject
115127

116128
expect(Fastlane::Actions::AsanaFindReleaseTaskAction).to have_received(:run).with(
117129
asana_access_token: "secret-token",
@@ -121,6 +133,18 @@
121133
expect(@params[:release_task_id]).to eq("1234567890")
122134
expect(@params[:release_branch]).to eq("release_branch_name")
123135
end
136+
137+
context "when the release task is not found" do
138+
before do
139+
allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:run).and_raise(FastlaneCore::Interface::FastlaneError.new)
140+
allow(Fastlane::UI).to receive(:important)
141+
end
142+
143+
it "raises an error" do
144+
expect { subject }.to raise_error(FastlaneCore::Interface::FastlaneError)
145+
expect(Fastlane::UI).to have_received(:important).with("Regular release task not found. If this is an automatic bump after merging a hotfix branch, this failure is expected. Rerun this workflow from an internal release branch, providing the release task URL explicitly.")
146+
end
147+
end
124148
end
125149
end
126150

0 commit comments

Comments
 (0)