Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Don't Be a Robot; Build the Bot

Mariatta
October 17, 2018

Don't Be a Robot; Build the Bot

DjangoCon US 2018 Keynote

Mariatta

October 17, 2018
Tweet

More Decks by Mariatta

Other Decks in Technology

Transcript

  1. Python Core Developer Platform Engineer @mariatta mariatta.ca #IceCreamSelfie WHO AM

    I? Mariatta Wijaya ! DjangoCon US 2018
 @mariatta https://zapier.com/jobs/
  2. Problem: We’re outnumbered Source: Stephane Wirtel, CPython loves your pull

    request https://speakerdeck.com/matrixise/ python-loves-your-contributions DjangoCon US 2018
 @mariatta
  3. Problem: Complicated Workflow Bug or feature? CLA signed? Tests passed?

    Needs an issue? Needs news entry? News entry added? Needs backport? How? Who? When? First time contributor? Commit message? DjangoCon US 2018
 @mariatta
  4. Problem: Complicated Workflow Bug or feature? CLA signed? Tests passed?

    Needs an issue? Needs news entry? News entry added? Needs backport? How? Who? When? First time contributor? Commit message? DjangoCon US 2018
 @mariatta
  5. Problem: Complicated Workflow Bug or feature? CLA signed? Tests passed?

    Needs an issue? Needs news entry? News entry added? Needs backport? How? Who? When? First time contributor? Commit message? DjangoCon US 2018
 @mariatta
  6. • master (3.8.0a1, due January 2019) • 3.7 (3.7.1, due

    October 2018) • 3.6 (3.6.7, due October 2018) • 2.7 (EOL, January 2020) Current maintained versions DjangoCon US 2018
 @mariatta
  7. SCENARIO: BUG IN 3.6 Bug in f-strings 3.6 3.7 3.8

    DjangoCon US 2018
 @mariatta
  8. SCENARIO: BUG IN 3.6 Bug in f-strings 3.8 3.6 3.7

    3.8 DjangoCon US 2018
 @mariatta
  9. SCENARIO: BUG IN 3.6 Bug in f-strings 3.8 3.6 3.7

    3.8 DjangoCon US 2018
 @mariatta
  10. SCENARIO: BUG IN 3.6 Bug in f-strings 3.8 3.6 3.7

    3.8 3.6 3.7 DjangoCon US 2018
 @mariatta
  11. SCENARIO: BUG IN 3.6 Bug in f-strings 3.8 3.6 3.7

    3.8 3.6 3.7 DjangoCon US 2018
 @mariatta
  12. CHERRY-PICKING $ git fetch upstream $ git checkout -b backport-3384d38d-3.7

    upstream/3.7 $ git cherry-pick -x 3384d38d51a2c3450e742175db5d6d638fa5d2eb $ git push origin backport-3384d38d-3.7 $ git checkout master $ git branch -D backport-3384d38d-3.7 $ git checkout -b backport-3384d38d-3.6 upstream/3.6 $ git cherry-pick -x 3384d38d51a2c3450e742175db5d6d638fa5d2eb $ git push origin backport-3384d38d-3.6 $ git checkout master $ git branch -D backport-3384d38d-3.6 3.7 3.6 DjangoCon US 2018
 @mariatta
  13. GITHUB WEBHOOKS Pull request (opened, closed, labeled) Status (pending, success,

    failure) Pull request review (submitted, dismissed) … Events GitHub Webservice Docs: https://developer.github.com/webhooks DjangoCon US 2018
 @mariatta
  14. GITHUB APIS Create a pull request Merge a pull request

    Comment on a pull request Apply labels to pull request … APIs Webservice GitHub Docs: https://developer.github.com/v3 DjangoCon US 2018
 @mariatta
  15. PR merged event (webhook) Open pull request (REST API) Run

    cherry_picker.py DjangoCon US 2018
 @mariatta
  16. PR merged event (webhook) Open pull request (REST API) Run

    cherry_picker.py Clone CPython repo DjangoCon US 2018
 @mariatta
  17. PR merged event (webhook) Open pull request (REST API) Run

    cherry_picker.py Clone CPython repo 2 minutes 12-15 seconds DjangoCon US 2018
 @mariatta
  18. PR merged event (webhook) Open pull request (REST API) Run

    cherry_picker.py Clone CPython repo 2 minutes 12-15 seconds timesout after 30 seconds DjangoCon US 2018
 @mariatta
  19. PR merged event (webhook) Open pull request (REST API) Run

    cherry_picker.py Clone CPython repo 2 minutes 12-15 seconds timesout after 30 seconds DjangoCon US 2018
 @mariatta
  20. PR merged event (webhook) Open pull request (REST API) Run

    cherry_picker.py Clone CPython repo Webservice (aiohttp) Background task (celery) Start a task DjangoCon US 2018
 @mariatta
  21. PR merged event (webhook) Open pull request (REST API) Run

    cherry_picker.py Clone CPython repo Webservice (aiohttp) Background task (celery) miss-islington Start a task DjangoCon US 2018
 @mariatta
  22. miss-islington • open-source https://github.com/python/miss-islington • Python 3.6 (because f-strings) •

    aiohttp: async web server/client • gidgethub: async Python library for GitHub DjangoCon US 2018
 @mariatta
  23. miss-islington @router.register("pull_request", action="closed") async def backport_pr(event, gh, *args, **kwargs): if

    event.data["pull_request"]["merged"]: commit_hash = event.data["pull_request"]["merge_commit_sha"] ... branches = [ label["name"].split()[-1] for label in pr_labels if label["name"].startswith("needs backport to”) ] for branch in branches: ... tasks.backport_task.delay(commit_hash, branch, ...) source: https://github.com/python/miss-islington/blob/master/miss_islington/backport_pr.py DjangoCon US 2018
 @mariatta
  24. Problem: Complicated Workflow Bug or feature? CLA signed? Tests passed?

    Needs an issue? Needs news entry? News entry added? Needs backport? How? Who? When? First time contributor? Commit message? DjangoCon US 2018
 @mariatta
  25. PR status event (webhook) Get the combined status for a

    ref (REST API) (status of a Git commit changes) Post a comment in PR (REST API) 2. https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref 2 1 3 1. https://developer.github.com/v3/activity/events/types/#statusevent 3. https://developer.github.com/v3/issues/comments/#create-a-comment DjangoCon US 2018
 @mariatta
  26. PR status event (webhook) Get the combined status for a

    ref (REST API) (status of a Git commit changes) Post a comment in PR (REST API) Which PR is this? 2. https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref 2 1 3 1. https://developer.github.com/v3/activity/events/types/#statusevent 3. https://developer.github.com/v3/issues/comments/#create-a-comment DjangoCon US 2018
 @mariatta
  27. GITHUB SEARCH ISSUES API async def get_pr_for_commit(gh, sha): prs_for_commit =

    await gh.getitem( f"/search/issues/?q=type:pr+repo:python/cpython+sha:{sha}" ) source: https://github.com/python/miss-islington/blob/master/miss_islington/util.py https://developer.github.com/v3/search/#search-issues DjangoCon US 2018
 @mariatta
  28. PR status event (webhook) Get the combined status for a

    ref (REST API) Post a comment in PR (REST API) Search PR containing commit (REST API) DjangoCon US 2018
 @mariatta
  29. Problem: Complicated Workflow Bug or feature? CLA signed? Tests passed?

    Needs an issue? Needs news entry? News entry added? Needs backport? How? Who? When? First time contributor? Commit message? DjangoCon US 2018
 @mariatta
  30. Merge the PR pr_number = 5590 await gh.put(f"/repos/python/cpython/pulls/{pr_number}/merge", data={"commit_title": "Fix

    typo in f-strings docs", "commit_message": "Shorten the comment to: 'using integer format specifier'"), "sha": sha, "merge_method": "squash" } ) DjangoCon US 2018
 @mariatta
  31. Merge the PR pr_number = 5590 await gh.put(f"/repos/python/cpython/pulls/{pr_number}/merge", data={"commit_title": "Fix

    typo in f-strings docs", "commit_message": "Shorten the comment to: 'using integer format specifier'"), "sha": sha, "merge_method": "squash" } ) DjangoCon US 2018
 @mariatta
  32. Automatically add CoC Automatically add CoC to newly created repo

    in organization DjangoCon US 2018
 @mariatta
  33. RHYMES WITH HAPPIER! OOOS bot Out of open source auto

    reply bot DjangoCon US 2018
 @mariatta
  34. Close all PRs PR opened/reopened event Close pull request @router.register("pull_request",

    action="opened") @router.register("pull_request", action="reopened") async def close_pr(event, gh, *args, **kwargs): await gh.patch(event.data["pull_request"]["url"], data= {"state": "closed"} ) Source: https://github.com/Mariatta/close-all-pr/blob/master/close-all-pr/close_pr.py DjangoCon US 2018
 @mariatta
  35. Contact [email protected]
 Follow on twitter @mariatta Thank you! DjangoCon US

    2018
 @mariatta PS: Please fill in Python Developers Survey http://bit.ly/pds2018-django