This project is the work of many contributors. You're encouraged to submit pull requests and to propose features and discuss issues.
In the examples below, substitute your GitHub username for contributor in URLs.
Fork the project on GitHub and check out your copy.
git clone https://github.com/contributor/slack-ruby-client.git
cd slack-ruby-client
git remote add upstream https://github.com/slack-ruby/slack-ruby-client.gitEnsure that you can build the project and run tests. The gem supports Ruby 2.7 and newer.
bundle install
bundle exec rakeSign up for Slack, create a private Slack workspace for yourself, then create an app and obtain a token. To get a token, install the app in a workspace and use the "User OAuth Token" from the installed app settings.
Try running the examples in the examples directory.
cd examples/hi_web
bundle install
SLACK_API_TOKEN=... bundle exec ruby hi.rbMake sure your fork is up to date and create a topic branch for your feature or bug fix.
git checkout master
git pull upstream master
git checkout -b my-feature-branchTry to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add tests to spec.
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
Implement your feature or bug fix.
Ruby style, Markdown, YAML, and spelling are enforced with RuboCop, including exception message conventions, rubocop-md, rubocop-prose, rubocop-spellcheck, and rubocop-yaml. The main Gemfile includes lint dependencies only on Ruby 3.2 and newer so tests can continue running on older supported Ruby versions.
bundle install
bundle exec rake lintFix any style issues highlighted, auto-correcting safe issues with bundle exec rubocop -a. Exception message corrections require -A; review them and update message expectations in tests. Add reviewed project vocabulary, such as API names and contributor handles, to .spellcheck.txt rather than disabling spelling checks. To regenerate the baseline for generally ignored issues, including line lengths or code complexity metrics, run bundle exec rubocop --auto-gen-config.
The default bundle exec rake runs tests only. CI runs lint separately on Ruby 4.0.
Benchmarks in benchmarks measure iterations per second and allocations with benchmark-ips and benchmark-memory. Web client benchmarks answer requests in process with canned JSON, so they measure the client stack without network latency. Run them before and after a performance change and include the results in your pull request.
bundle exec rake benchmark
bundle exec ruby benchmarks/formatting.rb
BENCHMARK_TIME=5 bundle exec ruby benchmarks/web_client.rbDocument any external behavior in the README. Keep each Markdown paragraph on a single line.
Add a line to CHANGELOG under the (Next) release, above * Your contribution here., which must not be removed. Make it look like every other line, including a link to the pull request, your name, and a link to your GitHub account.
* [#123](https://github.com/slack-ruby/slack-ruby-client/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).If you don't know the pull request number yet, open the pull request first, then amend the entry.
Make sure Git knows your name and email address.
git config --global user.name "Your Name"
git config --global user.email "contributor@example.com"Writing good commit logs is important. A commit log should describe what changed and why.
git add ...
git commitgit push origin my-feature-branchGo to https://github.com/contributor/slack-ruby-client, select your feature branch, and click the "Pull Request" button. Pull requests are usually reviewed within a few days.
If you've been working on a change for a while, rebase on upstream/master and amend your commit as needed.
git fetch upstream
git rebase upstream/master
git push origin my-feature-branch --force-with-leaseGo back to your pull request after a few minutes and check whether it passed CI. Everything should look green; otherwise, fix the issues and amend your commit as described above. Danger checks the changelog and the README table of contents and comments on the pull request when it finds problems.
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there! While you wait, you can help keep the Slack Web API up to date, see below.
Please make sure to create a separate branch for your changes.
The Slack Web API is generated from slack-api-ref, a maintained, machine-readable version of the Slack API documentation. The Update API workflow runs this weekly and opens a pull request. To update the Web API from the latest definition locally, run the following Rake task.
bundle exec rake slack:api:updateSometimes it's necessary to patch auto-generated Slack Web API methods. For example, we want to help clients with calling to_json on the attachments parameter sent to chat_postMessage. See #20.
The broad steps are:
- Run
bundle exec rake slack:api:updateto check that existing patches are still valid. If you run into afailed to apply patcherror, the auto-generated methods likely drifted from the last patch; follow the steps below. This may add new methods if the API has been updated; if so, please split them into separate pull requests. - Make a change to a generated file, for example
lib/slack/web/api/endpoints/chat.rb. - Generate a patch with
git diff --no-color HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.added-support.patch. - Run
bundle exec rake slack:api:updateto ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
The auto-generated method files may drift over time, e.g. new arguments may be added or descriptions changed. Since previous patches were based on the older auto-generated files, Git may be unable to apply them to the new files. Resolving them requires some good ol' splicing:
- Run
bundle exec rake slack:api:update SKIP_PATCH=trueto create the raw auto-generated files. Commit the files that you are updating, so you can rungit difflater. - Go through the old patches for the files (e.g.
lib/slack/web/api/patches/chat.added-support.patch), copying code into the new files. Rungit apply --reject path/to/patch-file.patchto see hunks that couldn't be applied. - Continue with step 2 above.
Please do know that we really appreciate and value your time and work. We love you, really.