Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ def self.run(params)

def self.find_release_task_if_needed(params)
if params[:release_task_url].to_s.empty?
params.merge!(
Fastlane::Actions::AsanaFindReleaseTaskAction.run(
asana_access_token: params[:asana_access_token],
github_token: params[:github_token],
platform: params[:platform]
begin
params.merge!(
Fastlane::Actions::AsanaFindReleaseTaskAction.run(
asana_access_token: params[:asana_access_token],
github_token: params[:github_token],
platform: params[:platform]
)
)
)
rescue FastlaneCore::Interface::FastlaneError
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.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice message 🙌

raise
end
else
params[:release_task_id] = Helper::AsanaHelper.extract_asana_task_id(params[:release_task_url], set_gha_output: false)
other_action.ensure_git_branch(branch: "^release/.+$")
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/ddg_apple_automation/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module DdgAppleAutomation
VERSION = "3.1.1"
VERSION = "3.1.2"
end
end
42 changes: 33 additions & 9 deletions spec/validate_internal_release_bump_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
allow(Fastlane::Actions).to receive(:other_action).and_return(@other_action)
allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:find_latest_marketing_version)
.and_return("1.0.0")

allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed) do |params|
params[:release_branch] = "release_branch_name"
params[:release_task_id] = "mock_task_id"
end
end
end

Expand All @@ -48,6 +43,13 @@
end
include_context "common setup"

before do
allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed) do |params|
params[:release_branch] = "release_branch_name"
params[:release_task_id] = "mock_task_id"
end
end

context "when there are changes in the release branch" do
it "proceeds with release bump if release notes are valid" do
expect(Fastlane::UI).to receive(:message).with("Validating release notes")
Expand Down Expand Up @@ -94,11 +96,17 @@
describe "#find_release_task_if_needed" do
include_context "common setup"

subject { Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params) }

context "when release_task_url is provided" do
before do
@params[:release_task_url] = "https://app.asana.com/0/1234567890/987654321"
end

it "sets release_task_id and release_branch from release_task_url" do
allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed).and_call_original
@params[:release_task_url] = "https://app.asana.com/0/1234567890/987654321"
Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params)

subject

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

context "when release_task_url is not provided" do
before do
@params[:release_task_url] = nil
end

it "runs AsanaFindReleaseTaskAction to find the release task" do
allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed).and_call_original
allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:run).and_return({ release_task_id: "1234567890", release_branch: "release_branch_name" })
Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params)

subject

expect(Fastlane::Actions::AsanaFindReleaseTaskAction).to have_received(:run).with(
asana_access_token: "secret-token",
Expand All @@ -121,6 +133,18 @@
expect(@params[:release_task_id]).to eq("1234567890")
expect(@params[:release_branch]).to eq("release_branch_name")
end

context "when the release task is not found" do
before do
allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:run).and_raise(FastlaneCore::Interface::FastlaneError.new)
allow(Fastlane::UI).to receive(:important)
end

it "raises an error" do
expect { subject }.to raise_error(FastlaneCore::Interface::FastlaneError)
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.")
end
end
end
end

Expand Down