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 basic slack CLI support #995

Closed
wants to merge 13 commits into from

Conversation

WilliamBergamin
Copy link
Contributor

The goal of this PR is to introduce basic support for slack CLI in Bolt for python. This is accomplished by implementing the get-hooks, get-manifest and start interface. Support for default and message-boundaries communication protocol was also implemented in order to leverage the full capabilities of the slack CLI

Testing

  1. slack create -t https://github.com/slack-samples/bolt-python-starter-template -b cli-support
  2. (Optional) In your project set up a venv with python -m venv .venv and source .venv/bin/activate
  3. pip install -r requirements.txt
  4. pip uninstall slack-bolt
  5. Pull the latest PR branch of bolt python to your local
  6. In the Bolt-Python project run scripts/build_pypi_package.sh this will generate a .whl in the dist/ folder
  7. Back in your project run pip install global/path/to/bolt-python/dist/something.whl
  8. Add the following fields in the manifest.json
    • "outgoing_domains": []
    • "settings"."function_runtime": "remote"
    • "settings"."org_deploy_enabled": true
  9. Now you should be able to run the following
    • slack manifest
    • slack run

Feedback

  • Code implementation, what could be improved are there any technical issues with this approach
  • I was able to manually test slack run for async apps but had issues implementing scenario tests for them, any ideas for this can help
  • User experience, are error clear and handled nicely, does this integrate well with the existing capabilities of the CLI
  • Are there any higher level solutions I might have missed that are worth discussing
  • Any concerns you may have on this, this addition has any moving components I very well may have missed something

Category

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

Copy link

codecov bot commented Nov 24, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (9209e7b) 91.76% compared to head (761e4d7) 91.87%.

Files Patch % Lines
slack_bolt/cli/protocol/protocol.py 75.00% 5 Missing ⚠️
slack_bolt/cli/protocol/default_protocol.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #995      +/-   ##
==========================================
+ Coverage   91.76%   91.87%   +0.11%     
==========================================
  Files         181      189       +8     
  Lines        6312     6450     +138     
==========================================
+ Hits         5792     5926     +134     
- Misses        520      524       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

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

At glance, the code looks great to me!

While checking this PR, I discovered that there's no need for the slack_bolt.cli code to be included in the slack_bolt package. If my understanding is correct , I would recommend creating a new package for all CLI-related stuff. The name for the new one can be slack-cli-hooks or whatever (note that slack-cli is already taken by a community developer).

The main benefit of having a smaller dedicated package for the CLI integration would be a different release cycle. We can start with 0.1.0 with a clear alpha/beta declaration. This makes the active development of the CLI integration much easier and faster.

@WilliamBergamin
Copy link
Contributor Author

WilliamBergamin commented Nov 27, 2023

@seratch I agree that isolating this code in a package brings the advantage of owning its release cycle
My concerned that this may yield a more complex developer experience since developers will potentially need to import 2 packages before being able to use the CLI

Should the slack-cli-hooks project import slack-bolt for the developer?
Should this package live in this repository?

@filmaj
Copy link
Contributor

filmaj commented Nov 27, 2023

@WilliamBergamin the example template listed in the testing instructions above doesn't include a Custom Function, right?

@WilliamBergamin
Copy link
Contributor Author

the example template listed in the testing instructions above doesn't include a Custom Function, right?

No it does not include a custom function

@seratch
Copy link
Member

seratch commented Nov 28, 2023

@WilliamBergamin Either way, developers need to install required packges (at least slack-bolt and its underlying dependecny slack-sdk). If our CLI mechanism has a limitation that developers cannot smoothly import multiple PyPI packages,

Should the slack-cli-hooks project import slack-bolt for the developer?

I am down to this idea. With this approach, the slack-cli-hooks can resolve slack-bolt and slack-sdk automatically. Developers do not need to know what packages are required to spin up their apps.

Comment on lines +10 to +11
"get-manifest": f"python -m {get_manifest.__name__}",
"start": f"python -m {start.__name__}",
Copy link
Member

Choose a reason for hiding this comment

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

Are there any concerns around using the python runtime? For example, my macOS system doesn't have a python binary installed and instead uses python3.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a great catch 💯 I very much glanced over this, let me look into this and try to find a broader solution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using python3 instead of python seem to be the safer option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants