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

Post annotations quicker #1

Open
seanh opened this issue Nov 7, 2024 · 0 comments
Open

Post annotations quicker #1

seanh opened this issue Nov 7, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@seanh
Copy link
Contributor

seanh commented Nov 7, 2024

Problem

Currently the GitHub Actions workflow runs once every five minutes, which is the maximum frequency that GHA can run a scheduled workflow at. Each time the workflow runs it checks the Hypothesis API once for new annotations, posts any new ones to Slack, and then exits.

This means that after creating an annotation in Hypothesis it can take up to five minutes for the annotation to appear in Slack.

We'd like this to be faster.

Possible solution

GitHub Actions jobs are allowed to run for up to 6 hours continuously. Change the slack-annotations script to call the Hypothesis API, post any new annotations to Slack, sleep for n seconds (say n=5) then repeat in a loop for 3 hours then exit. And change the scheduled GitHub Actions workflows that run the script (eng_annotations.yml and pr_website.yml) to run the script every 3 hours instead of every 5 minutes.

It won't be perfect, but this hack should mean that, for the most part, annotations get posted into Slack within a few seconds after they're created. This should be more than good enough.

Notes:

  • There's a test.yml workflow that calls the slack-annotations script and posts results into the #test-slack-annotations Slack channel. This test workflow isn't run automatically, it's only run manually for testing purposes. When running this test workflow we would not want the script to loop for three hours, we'd want it to loop only once then exit. So the time to loop for will need to be a command line argument to the script.

  • Currently the Python script itself doesn't actually post annotations to Slack, it just prints them out in a Slack-compatible format and then after the script exits the GHA workflow pipes its output to Slack's official GitHub action to do the actual posting for us. This was just a shortcut to save me time not having to write my own code for posting to Slack. In order to implement the looping hack I think you'll have to change it to have the Python code itself actually do the posting to the Slack API instead of piping to Slack's action, as that'll be necessary in order to post in a loop.

    • The script will need to take a Slack API token as a command line argument.
    • On GitHub Actions, the notify.yml workflow can pass ${{ secrets.SLACK_BOT_TOKEN }} as the command line argument.
    • It might be convenient to have a --dry-run option for testing locally without a Slack API token: just print out some messages about what would have been posted to Slack.
  • eng_annotations.yml and pr_website.yml have Dead Man's Snitch alerts that expect the scheduled workflows to complete once an hour otherwise an alarm will go off. These should be changed to three hours.

@seanh seanh added the enhancement New feature or request label Nov 7, 2024
@mtomilov mtomilov self-assigned this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants