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

"This is now live" automatic notifications #715

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

RubenRBS
Copy link
Member

@RubenRBS RubenRBS commented Apr 29, 2022

There is still some work to be done, but the gist of it is:

  • ce builds set_current ... store the oldest non-notified commit, skipping if something is already stored
  • ce environment refresh (and later ce instances restart) get the currently deployed version, and:
    • We ask github for the commits between both
    • Query github for the linked PRs for all those commits
    • Using GraphQL, find the linked issues for every PR, and for each:
      • Check if it already has a "This is now live" comment (Just in case)
      • Send a message saying "This is now live"
  • Delete the stored commit so new build versions get logged

This would need a new ssm in aws, and I need to test it in case where no key exists (Which should be the case of env refreshes for the same version!)



def get_linked_pr(commit: str, token: str) -> dict:
pr = get(f"repos/{OWNER_REPO}/commits/{commit}/pulls", token=token)
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically this is should be a paginated get, but if we find a PR with 30 or more linked issues.. Wow

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, the GraphQL query only lists the first 10, so there won't be more than that in the response, which fit in a single page

Copy link
Member

Choose a reason for hiding this comment

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

Can graphql query on label status? I think that finding results that haven't been tagged live might be safer and easier on humans to find if it goes wrong, instead of having to look inside all the comments inside each PR

bin/lib/cli/environment.py Outdated Show resolved Hide resolved
bin/lib/cli/environment.py Outdated Show resolved Hide resolved
bin/lib/notify.py Outdated Show resolved Hide resolved
bin/lib/cli/environment.py Show resolved Hide resolved
@RubenRBS RubenRBS marked this pull request as ready for review May 4, 2022 21:10
Copy link
Member Author

@RubenRBS RubenRBS 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 now ready for review. Needs some aws backend work to get the ssm and such

bin/lib/notify.py Show resolved Hide resolved


def get_linked_pr(commit: str, token: str) -> dict:
pr = get(f"repos/{OWNER_REPO}/commits/{commit}/pulls", token=token)
Copy link
Member Author

Choose a reason for hiding this comment

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

Also, the GraphQL query only lists the first 10, so there won't be more than that in the response, which fit in a single page

Copy link
Member

@mattgodbolt mattgodbolt left a comment

Choose a reason for hiding this comment

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

Some comments here - looks amazing; happy to discuss further. Thanks for this! Relatively small amount of code too, which is amazing :)

bin/lib/amazon.py Show resolved Hide resolved
bin/lib/amazon.py Outdated Show resolved Hide resolved
bin/lib/amazon.py Outdated Show resolved Hide resolved
bin/lib/cli/builds.py Show resolved Hide resolved
bin/lib/cli/environment.py Outdated Show resolved Hide resolved
bin/lib/notify.py Show resolved Hide resolved


def get_linked_pr(commit: str, token: str) -> dict:
pr = get(f"repos/{OWNER_REPO}/commits/{commit}/pulls", token=token)
Copy link
Member

Choose a reason for hiding this comment

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

Can graphql query on label status? I think that finding results that haven't been tagged live might be safer and easier on humans to find if it goes wrong, instead of having to look inside all the comments inside each PR

bin/lib/notify.py Outdated Show resolved Hide resolved
@RubenRBS
Copy link
Member Author

The failing test comes from the branch being a bit outdated, nothing to worry about

@RubenRBS
Copy link
Member Author

RubenRBS commented Aug 17, 2022

Just ran ce notify set_base 16b176235a67f5b31f5657e2bf76e2e85d84d0f7 which is a commit from 3 days ago so we don't get spammed in case this runs unexpectedly

In case of error, the program will break either way,
but we make sure we hide the token secret
@OfekShilon
Copy link
Member

This could be awesome. Any chance of resurrecting this @RubenRBS ?

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

Successfully merging this pull request may close these issues.

Label PRs as "now live" and tag them automatically on successful deploy
4 participants