Slack: Subscribing to events from the Checks API

Created on 20 Dec 2018  路  16Comments  路  Source: integrations/slack

Doesn't look like it is possible to subscribe to events from the Checks API.

It would be great to be able to do.

This documentation, https://developer.github.com/v3/activity/events/types/, might be relevant.

feature

Most helpful comment

Why does it update the existing message? I would rather see it creating a new message for every new check run since the opening of the PR can be far back in the slack history and harder to find. Also, my initial PR passed all the checks, but when I now committed a bug that doesn't update the message.

It might be that it is a good reason for not creating a new message, but I do think that would make more sense. Preferably it should also contain a link to the details for the check run.

I also agree that it should be disconnected from PR, especially now with actions that you have running for a branch that might not have a PR associated with it yet. (I do agree that you should create a PR first, but that doesn't always happen)

All 16 comments

Thanks for opening this issue! If you would like to help implement an improvement, read more about contributing and consider submitting a pull request.

Hey @dentarg , just wanted to let you know that the integration now supports displaying checks in the PR messaging you see in Slack. You can read about the changes we shipped today on the GitHub Blog. It's not exactly subscribing just to checks, but it may help unblock your use case.

The key thing to note is that this required some updated permissions on the application, so the owner of any repositories that have the GitHub Slack App installed will need to accept those permissions. If you try to use the command without the permissions, you'll be prompted to update them 鉂わ笍.

Thanks for your patience on this! Please re-open this issue if you find that there is an additional use case for subscribing to checks specifically in another way. If there is, if you can give an example of what you'd like to see that would be great!

@IAmHughes I think the use case I had in mind when opening this issue was to get feedback from Travis CI Cron Jobs in Slack (without having to set up Travis -> Slack integration). However, I'm not sure it is possible to use the Checks API without the context of a pull request. Do you know? :)

@dentarg ah okay that's an interesting use case and a bit different than what we shipped. I think this latest update will help some, in that the Checks Suites (see the checks tab of a pull request) will report their status when a pull request is unfurled, opened, etc.

  • Checks tab:
    image

  • New functionality:
    image

I'll re-open this issue as what you're referring to would be a little different I believe. Thanks for the feedback!

Hi @dentarg 馃憢

However, I'm not sure it is possible to use the Checks API without the context of a pull request. Do you know? :)

Checks (CheckRun and CheckSuite) only require a the head-sha (commit hash), so they are not bound to a pull-request.

So if you want to create a Check based on a commit hash, that should not be a problem.
This in conjunction with the new support for Check related events, you should be able to create a Check without a PR from Travis and see the result in Slack.
Might be worth giving it a shot.

Hi @scepticulous

I just checked my repo with check_runs_for_ref in Octokit and I can see that Travis CI created an check run for the cron job that ran today.

I also used /github subscribe list features and checked what my repo is subscribed to: issues, pulls, deployments, statuses, public, commits:all, releases, comments, branches, reviews

I take it that statuses should include check runs:

https://github.com/integrations/slack/blob/a4e5847b9bce5d4108955144ef2f700ca9036757/lib/models/subscription.js#L8

We have also approved the "Updated Permissions Request" for the GitHub App Slack (almost two weeks ago).

But I haven't seen any message in Slack that could be the check run. Is there any other criteria that needs to be met? Other events like comments, new pull requests, deployments is posted correctly to Slack. Do I need to re-subscribe?

Hi @dentarg,
just to make sure I have all the information.
Did you check out this part of the PR+Status announcement?

Checks and Statuses are part of the PR message that is posted to the Slack channel. So in order to reproduce the behavior could you please try the following:

  • subscribe to a repo including the pulls and statuses features (should be the default
  • create a PR in the repo
  • verify that the PR is posted to that slack channel
  • create a Check-Run within 30 (ideally a few) minutes and check if there is a status section at the bottom of the PR message

It should look like the image in the linked blog post. Let me know if this works for you and if not, what exact step failed.

Yes, I did read the blog post, and yes, it works for pull requests. I just did this test:

Screenshot 2019-08-12 at 16 22 52

  • create a Check-Run within 30 (ideally a few) minutes and check if there is a status section at the bottom of the PR message

If I do this, will it update the same message, or post a new message?

It will update the existing message for a duration of max 30 minutes AFAIR.
(I would have to check for more details)

@scepticulous Okay, but how is this related to check runs without pull requests? Are you just making sure this part is working?

Hey @dentarg,

sorry for the confusion. When I initially answered your question about Checks without PRs, I was only talking about CheckRuns independent of the Slack context.
After double-checking the implementation, the Slack integration only handled Checks that are attached to a PR.

https://github.com/integrations/slack/blob/33ed9a24dd415f40b164bcc9c1d4eee563d4626f/lib/activity/pull-requests.js#L99-L116

I assume that is not what you needed and I might have added to your confusion. Sorry about that.
Am I correct, that you are looking for a way to receive check-results without a PR in Slack?
If so, we have to consider this a feature request, since the last ship only added PR-related status/checks capabilities.

Am I correct, that you are looking for a way to receive check-results without a PR in Slack?

Yes!

If so, we have to consider this a feature request, since the last ship only added PR-related status/checks capabilities.

Sure, I guess that's why @IAmHughes re-opened this issue.

Why does it update the existing message? I would rather see it creating a new message for every new check run since the opening of the PR can be far back in the slack history and harder to find. Also, my initial PR passed all the checks, but when I now committed a bug that doesn't update the message.

It might be that it is a good reason for not creating a new message, but I do think that would make more sense. Preferably it should also contain a link to the details for the check run.

I also agree that it should be disconnected from PR, especially now with actions that you have running for a branch that might not have a PR associated with it yet. (I do agree that you should create a PR first, but that doesn't always happen)

I also agree that it should be disconnected from PR, especially now with actions that you have running for a branch that might not have a PR associated with it yet.

Or for Actions that run on a cron schedule, for example.

We are running checks (via Actions) in PRs but also on master. Our build pipeline only triggers after checks in master pass and the current behavior of the Slack integration causes confusion as to why didn't the build pipeline start. You can see e.g. "1 new commit pushed to master" and would expect the next message to come from the build pipeline, but if the checks fail, nothing's reported to Slack and the build pipeline never triggers.

+1 for the same issue @fortum-vaanavil described. The checks support on PRs is great, but we run the same checks after commits are merged (or pushed directly) to master and those are not currently possible to display with this integration AFAIK because they're outside a PR. For now we're manually posting to Slack at the start/end of a GH action only when the branch is master as a workaround.

Was this page helpful?
0 / 5 - 0 ratings