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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby 3.0] replace slack-notifier gem with internal library #18537

Merged
merged 11 commits into from Apr 30, 2021

Conversation

ainame
Copy link
Contributor

@ainame ainame commented Apr 10, 2021

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

As per the plan #17931 for Ruby 3.0, I've been working on fixing Ruby 2.7's deprecation warnings which will crash on Ruby 3.0. There is an issue where one of the fastlane's dependencies slack-notifier, which is not maintained any more, keeps producing that warning. As I explained in #18512 I decided to go with having our own implementation to post messages to Slack in fastlane. That way we get full control of logic. It is not only about Ruby version support but also Slack's webhook transition.

Right now there are two translations ongoing

To be fair, slack-notifier does support those but we don't know what changes will be coming from Slack in future.

Description

Prior to this PR, I've updated fastlane/spec/fastlane/actions_specs/slack_spec.rb so it's now independent from the gem. This PR added Fastlane::Notification::Slack class to own simple alternative of slack-notifier. (I suppose it might be interesting to support Microsoft teams or whatever other popular chat tools in fastlane as it's remote working era馃檪 That's why it's got Fastlane::Notification namespace.)

After digging through the gem, I realised most of the extra features in slack-notifier was not used by fastlane. Only Slack::Notifier::Util::LinkFormatter was needed to be re-implemented.

Testing Steps

Get an incoming webook url from here
https://www.slack.com/apps/manage/custom-integrations

Add this snippet to fastlane/Fastfile in the repo

lane :slack_test do
  slack(
    slack_url: 'https://hooks.slack.com/services/xxxxxxxxxxx',
    pretext: 'pretext test <@xxxxxx> #general',
    username: 'ainame-bot',
    channel: '#general',
    message: 'test <@xxxxxx> #general  <a href="https://fastlane.tools">fastlane</a> [GitHub](https://github.com/fastlane)',
    link_names: true,
  )
end

Run bundle exec fastlane slack_test

Legacy incoming webhook Slack App's incoming webhook
Screenshot 2021-04-10 at 08 20 29 Screenshot 2021-04-10 at 08 30 08

As you can see Slack app's incoming webhook can't overwrite username and icon. Instead, you need to customise them on its settings page.

@ainame ainame changed the title [Ruby 3.0] Replace slack-notifier gem with own implementation [Ruby 3.0] replace slack-notifier gem with own implementation Apr 10, 2021
@google-cla google-cla bot added the cla: yes label Apr 10, 2021
@ainame ainame changed the title [Ruby 3.0] replace slack-notifier gem with own implementation [Ruby 3.0] replace slack-notifier gem with internal library Apr 10, 2021
@ainame ainame marked this pull request as ready for review April 10, 2021 23:48
@ainame ainame force-pushed the replace-slack-notifier branch 2 times, most recently from 81449b1 to 722e640 Compare April 12, 2021 04:29
Copy link
Member

@rogerluan rogerluan left a comment

Choose a reason for hiding this comment

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

馃殌 Really good stuff!!

fastlane/lib/fastlane/notification/slack.rb Outdated Show resolved Hide resolved
fastlane/lib/fastlane/notification/slack.rb Outdated Show resolved Hide resolved
@@ -0,0 +1,56 @@
module Fastlane
module Notification
Copy link
Member

@rogerluan rogerluan Apr 17, 2021

Choose a reason for hiding this comment

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

I almost forgot to mention that I like this namespace strategy a lot 馃槉

@joshdholtz
Copy link
Member

@ainame This is ready for a rebase whenever you got time! I tried to do it on my own but it looked liked a large rebase than I felt comfortable doing as I didn鈥檛 want to mess up your PR 馃槈

@ainame
Copy link
Contributor Author

ainame commented Apr 20, 2021

FYI: We can rebase this branch without having to resolve conflicts like below馃檪

$ git rebase --onto origin/master dc2cd566

dc2cd56 is the last commit in the previous branch. This way commits made for this PR will be applied to the master branch that has previous PR's changes squashed.

@ainame
Copy link
Contributor Author

ainame commented Apr 20, 2021

@joshdholtz Thanks! This PR is ready to review!

@ainame ainame requested a review from joshdholtz April 20, 2021 05:30
@joshdholtz
Copy link
Member

FYI: We can rebase this branch without having to resolve conflicts like below馃檪

$ git rebase --onto origin/master dc2cd566

dc2cd56 is the last commit in the previous branch. This way commits made for this PR will be applied to the master branch that has previous PR's changes squashed.

OMG... I had no idea about --onto 馃く Thanks!

Copy link
Member

@crazymanish crazymanish left a comment

Choose a reason for hiding this comment

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

This looks great to me, thank you 馃憦

@google-cla
Copy link

google-cla bot commented Apr 30, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

鈩癸笍 Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Apr 30, 2021
@ainame
Copy link
Contributor Author

ainame commented Apr 30, 2021

@googlebot I consent.

@google-cla
Copy link

google-cla bot commented Apr 30, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

鈩癸笍 Googlers: Go here for more info.

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

This is beautiful 馃槏 Thanks again for all your work. This 3.0 dream is getting reeaaaalllll 鉂わ笍

@joshdholtz joshdholtz merged commit a45e8f3 into fastlane:master Apr 30, 2021
@fastlane-bot
Copy link

Hey @ainame 馃憢

Thank you for your contribution to fastlane and congrats on getting this pull request merged 馃帀
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 馃憤
We'll notify you once we shipped a new release with your changes 馃殌

@fastlane-bot
Copy link

Congratulations! 馃帀 This was released as part of fastlane 2.182.0 馃殌

@fastlane fastlane locked and limited conversation to collaborators Jul 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants