{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/pulse_actions/pulls/comments/44978904","id":44978904,"diff_hunk":"@@ -0,0 +1,80 @@\n+import logging\n+\n+from mozci.ci_manager import TaskClusterBuildbotManager\n+from mozci.sources import buildjson, buildbot_bridge\n+from mozci import query_jobs\n+from thclient import TreeherderClient\n+from pulse_actions.publisher import MessageHandler\n+\n+logging.basicConfig(format='%(levelname)s:\\t %(message)s')\n+LOG = logging.getLogger()\n+MEMORY_SAVING_MODE = True\n+\n+\n+def on_runnable_job_stage_event(data, message, dry_run):\n+    return on_runnable_job_event(data, message, dry_run, stage=True)\n+\n+\n+def on_runnable_job_prod_event(data, message, dry_run):\n+    return on_runnable_job_event(data, message, dry_run, stage=False)\n+\n+\n+def on_runnable_job_event(data, message, dry_run, stage):\n+    # Cleaning mozci caches\n+    buildjson.BUILDS_CACHE = {}\n+    query_jobs.JOBS_CACHE = {}\n+    repo_name = data[\"project\"]\n+    requester = data[\"requester\"]\n+    resultset_id = data[\"resultset_id\"]\n+    buildernames = data[\"buildernames\"]\n+\n+    if stage:\n+        treeherder_client = TreeherderClient(host='treeherder.allizom.org')\n+    else:\n+        treeherder_client = TreeherderClient()\n+\n+    mgr = TaskClusterBuildbotManager()\n+\n+    LOG.info(\"New jobs requested by %s on repo_name %s with resultset_id: %s\" %\n+             (data[\"requester\"], data[\"project\"], data[\"resultset_id\"]))\n+    resultset = treeherder_client.get_resultsets(repo_name, id=resultset_id)[0]\n+    revision = resultset[\"revision\"]\n+    author = resultset[\"author\"]\n+    status = None\n+\n+    message_sender = MessageHandler()\n+    # Everyone can press the button, but only authorized users can trigger jobs\n+    # TODO: remove this when proper LDAP identication is set up on TH\n+    if author != requester and not requester.endswith('@mozilla.com'):\n+        message.ack()\n+\n+        # We publish a message saying we will not trigger the job\n+        pulse_message = {\n+            'resultset_id': resultset_id,\n+            'requester': requester,\n+            'status': \"Could not determine if the user is authorized, nothing was triggered.\"}\n+        routing_key = '{}.{}'.format(repo_name, 'runnable')\n+        message_sender.publish_message(pulse_message, routing_key)\n+\n+        raise Exception(\"Requester %s is not allowed to trigger jobs.\" %\n+                        requester)\n+\n+    task_graph = buildbot_bridge.buildbot_graph_builder(buildernames, revision)","path":"pulse_actions/handlers/treeherder_runnable.py","position":62,"original_position":62,"commit_id":"5041666f852212fa9238a72c3e7fe3ac2d407a1e","original_commit_id":"5041666f852212fa9238a72c3e7fe3ac2d407a1e","user":{"login":"armenzg","id":44410,"avatar_url":"https://avatars.githubusercontent.com/u/44410?v=3","gravatar_id":"","url":"https://api.github.com/users/armenzg","html_url":"https://github.com/armenzg","followers_url":"https://api.github.com/users/armenzg/followers","following_url":"https://api.github.com/users/armenzg/following{/other_user}","gists_url":"https://api.github.com/users/armenzg/gists{/gist_id}","starred_url":"https://api.github.com/users/armenzg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armenzg/subscriptions","organizations_url":"https://api.github.com/users/armenzg/orgs","repos_url":"https://api.github.com/users/armenzg/repos","events_url":"https://api.github.com/users/armenzg/events{/privacy}","received_events_url":"https://api.github.com/users/armenzg/received_events","type":"User","site_admin":false},"body":"Can you please call this builders_graph? I used that term internally to mozci to differentiate from a TaskCluster graph to a graph of builders (even though it will become a TC one).","created_at":"2015-11-16T20:35:16Z","updated_at":"2015-11-16T20:35:16Z","html_url":"https://github.com/mozilla/pulse_actions/pull/19#discussion_r44978904","pull_request_url":"https://api.github.com/repos/mozilla/pulse_actions/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/mozilla/pulse_actions/pulls/comments/44978904"},"html":{"href":"https://github.com/mozilla/pulse_actions/pull/19#discussion_r44978904"},"pull_request":{"href":"https://api.github.com/repos/mozilla/pulse_actions/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/pulse_actions/pulls/19","id":46225318,"html_url":"https://github.com/mozilla/pulse_actions/pull/19","diff_url":"https://github.com/mozilla/pulse_actions/pull/19.diff","patch_url":"https://github.com/mozilla/pulse_actions/pull/19.patch","issue_url":"https://api.github.com/repos/mozilla/pulse_actions/issues/19","number":19,"state":"open","locked":false,"title":"Support add new jobs in Treeherder","user":{"login":"adusca","id":8979476,"avatar_url":"https://avatars.githubusercontent.com/u/8979476?v=3","gravatar_id":"","url":"https://api.github.com/users/adusca","html_url":"https://github.com/adusca","followers_url":"https://api.github.com/users/adusca/followers","following_url":"https://api.github.com/users/adusca/following{/other_user}","gists_url":"https://api.github.com/users/adusca/gists{/gist_id}","starred_url":"https://api.github.com/users/adusca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adusca/subscriptions","organizations_url":"https://api.github.com/users/adusca/orgs","repos_url":"https://api.github.com/users/adusca/repos","events_url":"https://api.github.com/users/adusca/events{/privacy}","received_events_url":"https://api.github.com/users/adusca/received_events","type":"User","site_admin":false},"body":"Getting ready for bug 1194830 to land. This assumes that trigger_job is able to schedule a downstream job even if no upstream build is currently finished, so we still need to wait for mozci changes before landing this.\r\n\r\nr? @armenzg ","created_at":"2015-09-29T00:42:24Z","updated_at":"2015-11-16T20:35:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"55828000f74d530b77ecc045f323d3bf425225d1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/pulse_actions/pulls/19/commits","review_comments_url":"https://api.github.com/repos/mozilla/pulse_actions/pulls/19/comments","review_comment_url":"https://api.github.com/repos/mozilla/pulse_actions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/pulse_actions/issues/19/comments","statuses_url":"https://api.github.com/repos/mozilla/pulse_actions/statuses/5041666f852212fa9238a72c3e7fe3ac2d407a1e","head":{"label":"mozilla:try-extender","ref":"try-extender","sha":"5041666f852212fa9238a72c3e7fe3ac2d407a1e","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":36251301,"name":"pulse_actions","full_name":"mozilla/pulse_actions","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/pulse_actions","description":"Listen to pulse messages and take actions from them","fork":false,"url":"https://api.github.com/repos/mozilla/pulse_actions","forks_url":"https://api.github.com/repos/mozilla/pulse_actions/forks","keys_url":"https://api.github.com/repos/mozilla/pulse_actions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/pulse_actions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/pulse_actions/teams","hooks_url":"https://api.github.com/repos/mozilla/pulse_actions/hooks","issue_events_url":"https://api.github.com/repos/mozilla/pulse_actions/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/pulse_actions/events","assignees_url":"https://api.github.com/repos/mozilla/pulse_actions/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/pulse_actions/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/pulse_actions/tags","blobs_url":"https://api.github.com/repos/mozilla/pulse_actions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/pulse_actions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/pulse_actions/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/pulse_actions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/pulse_actions/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/pulse_actions/languages","stargazers_url":"https://api.github.com/repos/mozilla/pulse_actions/stargazers","contributors_url":"https://api.github.com/repos/mozilla/pulse_actions/contributors","subscribers_url":"https://api.github.com/repos/mozilla/pulse_actions/subscribers","subscription_url":"https://api.github.com/repos/mozilla/pulse_actions/subscription","commits_url":"https://api.github.com/repos/mozilla/pulse_actions/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/pulse_actions/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/pulse_actions/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/pulse_actions/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/pulse_actions/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/pulse_actions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/pulse_actions/merges","archive_url":"https://api.github.com/repos/mozilla/pulse_actions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/pulse_actions/downloads","issues_url":"https://api.github.com/repos/mozilla/pulse_actions/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/pulse_actions/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/pulse_actions/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/pulse_actions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/pulse_actions/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/pulse_actions/releases{/id}","created_at":"2015-05-25T19:49:45Z","updated_at":"2015-10-16T21:22:12Z","pushed_at":"2015-11-16T19:41:25Z","git_url":"git://github.com/mozilla/pulse_actions.git","ssh_url":"git@github.com:mozilla/pulse_actions.git","clone_url":"https://github.com/mozilla/pulse_actions.git","svn_url":"https://github.com/mozilla/pulse_actions","homepage":null,"size":99,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":6,"forks":3,"open_issues":6,"watchers":1,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"bff142b52eba440557cab1506fd6d0d8f49ceaa9","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":36251301,"name":"pulse_actions","full_name":"mozilla/pulse_actions","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/pulse_actions","description":"Listen to pulse messages and take actions from them","fork":false,"url":"https://api.github.com/repos/mozilla/pulse_actions","forks_url":"https://api.github.com/repos/mozilla/pulse_actions/forks","keys_url":"https://api.github.com/repos/mozilla/pulse_actions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/pulse_actions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/pulse_actions/teams","hooks_url":"https://api.github.com/repos/mozilla/pulse_actions/hooks","issue_events_url":"https://api.github.com/repos/mozilla/pulse_actions/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/pulse_actions/events","assignees_url":"https://api.github.com/repos/mozilla/pulse_actions/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/pulse_actions/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/pulse_actions/tags","blobs_url":"https://api.github.com/repos/mozilla/pulse_actions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/pulse_actions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/pulse_actions/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/pulse_actions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/pulse_actions/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/pulse_actions/languages","stargazers_url":"https://api.github.com/repos/mozilla/pulse_actions/stargazers","contributors_url":"https://api.github.com/repos/mozilla/pulse_actions/contributors","subscribers_url":"https://api.github.com/repos/mozilla/pulse_actions/subscribers","subscription_url":"https://api.github.com/repos/mozilla/pulse_actions/subscription","commits_url":"https://api.github.com/repos/mozilla/pulse_actions/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/pulse_actions/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/pulse_actions/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/pulse_actions/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/pulse_actions/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/pulse_actions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/pulse_actions/merges","archive_url":"https://api.github.com/repos/mozilla/pulse_actions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/pulse_actions/downloads","issues_url":"https://api.github.com/repos/mozilla/pulse_actions/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/pulse_actions/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/pulse_actions/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/pulse_actions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/pulse_actions/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/pulse_actions/releases{/id}","created_at":"2015-05-25T19:49:45Z","updated_at":"2015-10-16T21:22:12Z","pushed_at":"2015-11-16T19:41:25Z","git_url":"git://github.com/mozilla/pulse_actions.git","ssh_url":"git@github.com:mozilla/pulse_actions.git","clone_url":"https://github.com/mozilla/pulse_actions.git","svn_url":"https://github.com/mozilla/pulse_actions","homepage":null,"size":99,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":6,"forks":3,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/pulse_actions/pulls/19"},"html":{"href":"https://github.com/mozilla/pulse_actions/pull/19"},"issue":{"href":"https://api.github.com/repos/mozilla/pulse_actions/issues/19"},"comments":{"href":"https://api.github.com/repos/mozilla/pulse_actions/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/pulse_actions/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/pulse_actions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/pulse_actions/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/pulse_actions/statuses/5041666f852212fa9238a72c3e7fe3ac2d407a1e"}}}}