{"action":"created","comment":{"url":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/comments/224046288","pull_request_review_id":163317780,"id":224046288,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDA0NjI4OA==","diff_hunk":"@@ -114,3 +160,94 @@ def _merge(pull, method):\n                 \"The pull request has been automatically merged\",\n                 \"The pull request has been automatically \"\n                 \"merged at *%s*\" % pull.g_pull.merge_commit_sha)\n+\n+    @staticmethod\n+    def _get_cache_key(pull):\n+        return \"strict-merge-queues~%s~%s~%s~%s\" % (\n+            pull.installation_id,\n+            pull.g_pull.base.repo.owner.login.lower(),\n+            pull.g_pull.base.repo.name.lower(),\n+            pull.g_pull.base.ref\n+        )\n+\n+\n+def update_pull_base_branch(pull, subscription):\n+    updated = branch_updater.update(pull, subscription[\"token\"])\n+    if updated:\n+        # NOTE(sileht): We update g_pull to have the new head.sha,\n+        # so future created checks will be post on the new sha.\n+        # Otherwise the checks will be lost the GitHub UI on the\n+        # old sha.\n+        pull.wait_for_sha_change()\n+        return (None, \"Base branch updates done\",\n+                \"The pull request has been automatically \"\n+                \"updated to follow its base branch and will be \"\n+                \"merged soon\")\n+    else:  # pragma: no cover\n+        return (\"failure\", \"Base branch update has failed\", \"\")\n+\n+\n+def update_next_pull(installation_id, installation_token, subscription,\n+                     owner, reponame, key, cur_key):\n+    redis = utils.get_redis_for_cache()\n+    pull_number = redis.srandmember(key)\n+    if not pull_number:\n+        return\n+\n+    pull = mergify_pull.MergifyPull.from_number(\n+        installation_id, installation_token,\n+        owner, reponame, int(pull_number))\n+    old_checks = [c for c in check_api.get_checks(pull.g_pull)\n+                  if (c.name.endswith(\" (merge)\") and\n+                      c._rawData['app']['id'] == config.INTEGRATION_ID)]\n+\n+    conclusion, title, summary = update_pull_base_branch(pull, subscription)\n+    redis.set(cur_key, pull_number)\n+\n+    status = \"completed\" if conclusion else \"in_progress\"\n+    for c in old_checks:\n+        check_api.set_check_run(\n+            pull.g_pull, c.name, status, conclusion,\n+            output={\"title\": title, \"summary\": summary})\n+\n+\n+@app.task\n+def smart_strict_workflow_periodic_task():\n+    integration = github.GithubIntegration(config.INTEGRATION_ID,\n+                                           config.PRIVATE_KEY)\n+    redis = utils.get_redis_for_cache()\n+    LOG.debug(\"smart strict workflow loop start\")\n+    for key in redis.keys(\"strict-merge-queues~*\"):\n+        _, installation_id, owner, reponame, branch = key.split(\"~\")\n+        try:\n+            installation_token = integration.get_access_token(\n+                installation_id).token\n+        except github.UnknownObjectException:  # pragma: no cover\n+            LOG.error(\"token for install %d does not exists anymore (%s/%s)\",\n+                      installation_id, owner, reponame)\n+            continue\n+\n+        cur_key = \"current-%s\" % key\n+        redis = utils.get_redis_for_cache()\n+        pull_number = redis.get(cur_key)\n+        if pull_number and redis.sismember(key, pull_number):\n+            # NOTE(sileht): Pull request have not been merged or cancelled yet\n+            # wait next loop\n+            LOG.debug(\"pull CIs still in progress\",\n+                      installation_id=installation_id,\n+                      pull_number=pull_number,\n+                      repo=owner + \"/\" + reponame, branch=branch)\n+            continue\n+\n+        subscription = utils.get_subscription(redis, installation_id)\n+        if not subscription[\"token\"]:  # pragma: no cover\n+            # TODO(sileht): add logging ?","path":"mergify_engine/actions/merge.py","position":196,"original_position":196,"commit_id":"c35e9f065dba1db5a18cc9e3c555dd4d8b1edeec","original_commit_id":"c35e9f065dba1db5a18cc9e3c555dd4d8b1edeec","user":{"login":"jd","id":2644,"node_id":"MDQ6VXNlcjI2NDQ=","avatar_url":"https://avatars0.githubusercontent.com/u/2644?v=4","gravatar_id":"","url":"https://api.github.com/users/jd","html_url":"https://github.com/jd","followers_url":"https://api.github.com/users/jd/followers","following_url":"https://api.github.com/users/jd/following{/other_user}","gists_url":"https://api.github.com/users/jd/gists{/gist_id}","starred_url":"https://api.github.com/users/jd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jd/subscriptions","organizations_url":"https://api.github.com/users/jd/orgs","repos_url":"https://api.github.com/users/jd/repos","events_url":"https://api.github.com/users/jd/events{/privacy}","received_events_url":"https://api.github.com/users/jd/received_events","type":"User","site_admin":false},"body":"isn't what L45 does?","created_at":"2018-10-10T12:02:05Z","updated_at":"2018-10-10T12:02:51Z","html_url":"https://github.com/Mergifyio/mergify-engine/pull/231#discussion_r224046288","pull_request_url":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/231","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/comments/224046288"},"html":{"href":"https://github.com/Mergifyio/mergify-engine/pull/231#discussion_r224046288"},"pull_request":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/231"}}},"pull_request":{"url":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/231","id":221727779,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxNzI3Nzc5","html_url":"https://github.com/Mergifyio/mergify-engine/pull/231","diff_url":"https://github.com/Mergifyio/mergify-engine/pull/231.diff","patch_url":"https://github.com/Mergifyio/mergify-engine/pull/231.patch","issue_url":"https://api.github.com/repos/Mergifyio/mergify-engine/issues/231","number":231,"state":"open","locked":false,"title":"smart strict","user":{"login":"sileht","id":200878,"node_id":"MDQ6VXNlcjIwMDg3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/200878?v=4","gravatar_id":"","url":"https://api.github.com/users/sileht","html_url":"https://github.com/sileht","followers_url":"https://api.github.com/users/sileht/followers","following_url":"https://api.github.com/users/sileht/following{/other_user}","gists_url":"https://api.github.com/users/sileht/gists{/gist_id}","starred_url":"https://api.github.com/users/sileht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sileht/subscriptions","organizations_url":"https://api.github.com/users/sileht/orgs","repos_url":"https://api.github.com/users/sileht/repos","events_url":"https://api.github.com/users/sileht/events{/privacy}","received_events_url":"https://api.github.com/users/sileht/received_events","type":"User","site_admin":false},"body":"This change implements the smart strict workflow that\nrebase only one pull request per project per branch at a time.","created_at":"2018-10-10T09:59:16Z","updated_at":"2018-10-10T12:02:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8c5925b6d924f7ccd63d56b8d02b2ce37b685d4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/231/commits","review_comments_url":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/231/comments","review_comment_url":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Mergifyio/mergify-engine/issues/231/comments","statuses_url":"https://api.github.com/repos/Mergifyio/mergify-engine/statuses/c35e9f065dba1db5a18cc9e3c555dd4d8b1edeec","head":{"label":"sileht:smart-strict","ref":"smart-strict","sha":"c35e9f065dba1db5a18cc9e3c555dd4d8b1edeec","user":{"login":"sileht","id":200878,"node_id":"MDQ6VXNlcjIwMDg3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/200878?v=4","gravatar_id":"","url":"https://api.github.com/users/sileht","html_url":"https://github.com/sileht","followers_url":"https://api.github.com/users/sileht/followers","following_url":"https://api.github.com/users/sileht/following{/other_user}","gists_url":"https://api.github.com/users/sileht/gists{/gist_id}","starred_url":"https://api.github.com/users/sileht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sileht/subscriptions","organizations_url":"https://api.github.com/users/sileht/orgs","repos_url":"https://api.github.com/users/sileht/repos","events_url":"https://api.github.com/users/sileht/events{/privacy}","received_events_url":"https://api.github.com/users/sileht/received_events","type":"User","site_admin":false},"repo":{"id":131132300,"node_id":"MDEwOlJlcG9zaXRvcnkxMzExMzIzMDA=","name":"mergify-engine","full_name":"sileht/mergify-engine","private":false,"owner":{"login":"sileht","id":200878,"node_id":"MDQ6VXNlcjIwMDg3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/200878?v=4","gravatar_id":"","url":"https://api.github.com/users/sileht","html_url":"https://github.com/sileht","followers_url":"https://api.github.com/users/sileht/followers","following_url":"https://api.github.com/users/sileht/following{/other_user}","gists_url":"https://api.github.com/users/sileht/gists{/gist_id}","starred_url":"https://api.github.com/users/sileht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sileht/subscriptions","organizations_url":"https://api.github.com/users/sileht/orgs","repos_url":"https://api.github.com/users/sileht/repos","events_url":"https://api.github.com/users/sileht/events{/privacy}","received_events_url":"https://api.github.com/users/sileht/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sileht/mergify-engine","description":"Engine for Mergify","fork":true,"url":"https://api.github.com/repos/sileht/mergify-engine","forks_url":"https://api.github.com/repos/sileht/mergify-engine/forks","keys_url":"https://api.github.com/repos/sileht/mergify-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sileht/mergify-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sileht/mergify-engine/teams","hooks_url":"https://api.github.com/repos/sileht/mergify-engine/hooks","issue_events_url":"https://api.github.com/repos/sileht/mergify-engine/issues/events{/number}","events_url":"https://api.github.com/repos/sileht/mergify-engine/events","assignees_url":"https://api.github.com/repos/sileht/mergify-engine/assignees{/user}","branches_url":"https://api.github.com/repos/sileht/mergify-engine/branches{/branch}","tags_url":"https://api.github.com/repos/sileht/mergify-engine/tags","blobs_url":"https://api.github.com/repos/sileht/mergify-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sileht/mergify-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sileht/mergify-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/sileht/mergify-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sileht/mergify-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/sileht/mergify-engine/languages","stargazers_url":"https://api.github.com/repos/sileht/mergify-engine/stargazers","contributors_url":"https://api.github.com/repos/sileht/mergify-engine/contributors","subscribers_url":"https://api.github.com/repos/sileht/mergify-engine/subscribers","subscription_url":"https://api.github.com/repos/sileht/mergify-engine/subscription","commits_url":"https://api.github.com/repos/sileht/mergify-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/sileht/mergify-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/sileht/mergify-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/sileht/mergify-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/sileht/mergify-engine/contents/{+path}","compare_url":"https://api.github.com/repos/sileht/mergify-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sileht/mergify-engine/merges","archive_url":"https://api.github.com/repos/sileht/mergify-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sileht/mergify-engine/downloads","issues_url":"https://api.github.com/repos/sileht/mergify-engine/issues{/number}","pulls_url":"https://api.github.com/repos/sileht/mergify-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/sileht/mergify-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/sileht/mergify-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sileht/mergify-engine/labels{/name}","releases_url":"https://api.github.com/repos/sileht/mergify-engine/releases{/id}","deployments_url":"https://api.github.com/repos/sileht/mergify-engine/deployments","created_at":"2018-04-26T09:26:52Z","updated_at":"2018-07-05T04:37:06Z","pushed_at":"2018-10-10T11:37:27Z","git_url":"git://github.com/sileht/mergify-engine.git","ssh_url":"git@github.com:sileht/mergify-engine.git","clone_url":"https://github.com/sileht/mergify-engine.git","svn_url":"https://github.com/sileht/mergify-engine","homepage":"https://mergify.io","size":47538,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Mergifyio:master","ref":"master","sha":"103c1a4b476158fa7e17fb70de9848fd5f1c24aa","user":{"login":"Mergifyio","id":37838584,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3ODM4NTg0","avatar_url":"https://avatars1.githubusercontent.com/u/37838584?v=4","gravatar_id":"","url":"https://api.github.com/users/Mergifyio","html_url":"https://github.com/Mergifyio","followers_url":"https://api.github.com/users/Mergifyio/followers","following_url":"https://api.github.com/users/Mergifyio/following{/other_user}","gists_url":"https://api.github.com/users/Mergifyio/gists{/gist_id}","starred_url":"https://api.github.com/users/Mergifyio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mergifyio/subscriptions","organizations_url":"https://api.github.com/users/Mergifyio/orgs","repos_url":"https://api.github.com/users/Mergifyio/repos","events_url":"https://api.github.com/users/Mergifyio/events{/privacy}","received_events_url":"https://api.github.com/users/Mergifyio/received_events","type":"Organization","site_admin":false},"repo":{"id":130068404,"node_id":"MDEwOlJlcG9zaXRvcnkxMzAwNjg0MDQ=","name":"mergify-engine","full_name":"Mergifyio/mergify-engine","private":false,"owner":{"login":"Mergifyio","id":37838584,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM3ODM4NTg0","avatar_url":"https://avatars1.githubusercontent.com/u/37838584?v=4","gravatar_id":"","url":"https://api.github.com/users/Mergifyio","html_url":"https://github.com/Mergifyio","followers_url":"https://api.github.com/users/Mergifyio/followers","following_url":"https://api.github.com/users/Mergifyio/following{/other_user}","gists_url":"https://api.github.com/users/Mergifyio/gists{/gist_id}","starred_url":"https://api.github.com/users/Mergifyio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mergifyio/subscriptions","organizations_url":"https://api.github.com/users/Mergifyio/orgs","repos_url":"https://api.github.com/users/Mergifyio/repos","events_url":"https://api.github.com/users/Mergifyio/events{/privacy}","received_events_url":"https://api.github.com/users/Mergifyio/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Mergifyio/mergify-engine","description":"Engine for Mergify","fork":false,"url":"https://api.github.com/repos/Mergifyio/mergify-engine","forks_url":"https://api.github.com/repos/Mergifyio/mergify-engine/forks","keys_url":"https://api.github.com/repos/Mergifyio/mergify-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mergifyio/mergify-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mergifyio/mergify-engine/teams","hooks_url":"https://api.github.com/repos/Mergifyio/mergify-engine/hooks","issue_events_url":"https://api.github.com/repos/Mergifyio/mergify-engine/issues/events{/number}","events_url":"https://api.github.com/repos/Mergifyio/mergify-engine/events","assignees_url":"https://api.github.com/repos/Mergifyio/mergify-engine/assignees{/user}","branches_url":"https://api.github.com/repos/Mergifyio/mergify-engine/branches{/branch}","tags_url":"https://api.github.com/repos/Mergifyio/mergify-engine/tags","blobs_url":"https://api.github.com/repos/Mergifyio/mergify-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mergifyio/mergify-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mergifyio/mergify-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mergifyio/mergify-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mergifyio/mergify-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/Mergifyio/mergify-engine/languages","stargazers_url":"https://api.github.com/repos/Mergifyio/mergify-engine/stargazers","contributors_url":"https://api.github.com/repos/Mergifyio/mergify-engine/contributors","subscribers_url":"https://api.github.com/repos/Mergifyio/mergify-engine/subscribers","subscription_url":"https://api.github.com/repos/Mergifyio/mergify-engine/subscription","commits_url":"https://api.github.com/repos/Mergifyio/mergify-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mergifyio/mergify-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mergifyio/mergify-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mergifyio/mergify-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mergifyio/mergify-engine/contents/{+path}","compare_url":"https://api.github.com/repos/Mergifyio/mergify-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mergifyio/mergify-engine/merges","archive_url":"https://api.github.com/repos/Mergifyio/mergify-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mergifyio/mergify-engine/downloads","issues_url":"https://api.github.com/repos/Mergifyio/mergify-engine/issues{/number}","pulls_url":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/Mergifyio/mergify-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/Mergifyio/mergify-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mergifyio/mergify-engine/labels{/name}","releases_url":"https://api.github.com/repos/Mergifyio/mergify-engine/releases{/id}","deployments_url":"https://api.github.com/repos/Mergifyio/mergify-engine/deployments","created_at":"2018-04-18T13:41:15Z","updated_at":"2018-10-10T11:58:23Z","pushed_at":"2018-10-10T11:58:21Z","git_url":"git://github.com/Mergifyio/mergify-engine.git","ssh_url":"git@github.com:Mergifyio/mergify-engine.git","clone_url":"https://github.com/Mergifyio/mergify-engine.git","svn_url":"https://github.com/Mergifyio/mergify-engine","homepage":"https://mergify.io","size":53530,"stargazers_count":32,"watchers_count":32,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":25,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":8,"open_issues":25,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/231"},"html":{"href":"https://github.com/Mergifyio/mergify-engine/pull/231"},"issue":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/issues/231"},"comments":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/issues/231/comments"},"review_comments":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/231/comments"},"review_comment":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/pulls/231/commits"},"statuses":{"href":"https://api.github.com/repos/Mergifyio/mergify-engine/statuses/c35e9f065dba1db5a18cc9e3c555dd4d8b1edeec"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jd"}}