Skip to content
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

Add AsanaUploadAction #2

Merged
merged 6 commits into from
Sep 2, 2024
Merged

Add AsanaUploadAction #2

merged 6 commits into from
Sep 2, 2024

Conversation

jaceklyp
Copy link
Contributor

Task URL: https://app.asana.com/0/1201392122292466/1208137627434497/f

Description:
This change adds new lane that replaces asana-upload action

@jaceklyp jaceklyp requested a review from ayoy August 30, 2024 15:34
Comment on lines 20 to 27
url = Helper::DdgAppleAutomationHelper::ASANA_API_URL + "/tasks/#{task_id}/attachments"
response = HTTParty.post(url,
headers: { 'Authorization' => "Bearer #{token}" },
body: { file: file })

unless response.success?
UI.user_error!("Failed to upload file to Asana task: (#{response.code} #{response.message})")
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Since UI.user_error! doesn't cause a test to stop (while it causes fastlane to stop the action/lane), it's tricky to test UI.user_error! stopping execution. I would suggest that we include all this code under begin/rescue clause, so that UI.user_error! calls are always the last thing to happen within #run function.

This may not scale as the complexity of our action raises and we may need to either find a different solution or stop testing user_error that thoroughly :/

unless response.success?
UI.user_error!("Failed to upload file to Asana task: (#{response.code} #{response.message})")
end
rescue Errno::ENOENT
Copy link
Contributor

Choose a reason for hiding this comment

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

I think at least Errno::EPERM could also be raised here for file that the user has no permission to access, so perhaps we could just use rescue here:

Suggested change
rescue Errno::ENOENT
rescue

Copy link
Contributor

@ayoy ayoy left a comment

Choose a reason for hiding this comment

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

LGTM! Please update lib/fastlane/plugin/ddg_apple_automation/version.rb to 0.4.0 before merging :)

end

it "shows error if file does not exist" do
allow(HTTParty).to receive(:post).and_return(double(success?: true))
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is not needed now 👍

@jaceklyp jaceklyp merged commit a207fde into main Sep 2, 2024
1 check passed
@jaceklyp jaceklyp deleted the jacek/asana-upload branch September 2, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants