{"action":"created","comment":{"url":"https://api.github.com/repos/gooddata/zuul/pulls/comments/52445889","id":52445889,"diff_hunk":"@@ -0,0 +1,102 @@\n+## Assumptions\n+# there's a repository user/repo\n+# zuul is configured to run a check pipeline with some job(s) on user/repo\n+# zuul is configured to run a gate pipeline with some job(s) on user/repo\n+\n+## Configurables\n+# user\n+# repo\n+# API token for user\n+\n+require 'rubygems'\n+\n+require 'fileutils'\n+require 'git'\n+require 'octokit'\n+require 'rspec'\n+require 'timeout'\n+\n+describe 'Github pull reqeust' do\n+  before(:all) do\n+    required_vars = %w(GITHUB_API_TOKEN GITHUB_USER GITHUB_REPO\n+                       GITHUB_TARGET_BRANCH)\n+    missing_vars = required_vars.select do |var|\n+      ENV[var].nil?\n+    end\n+    unless missing_vars.empty?\n+      raise(\"Undefined variables: #{missing_vars.join(' ')}\")\n+    end\n+    @api_token = ENV['GITHUB_API_TOKEN']\n+    @user = ENV['GITHUB_USER']\n+    @repo = ENV['GITHUB_REPO']\n+    @target_branch = ENV['GITHUB_TARGET_BRANCH']\n+  end\n+\n+  it 'runs check and gate pipelines' do\n+    repo_fqn = \"#{@user}/#{@repo}\"\n+    rand_string = rand(36**6).to_s(36)\n+    test_branch = \"test_#{rand_string}\"\n+\n+    # clone the repo\n+    FileUtils.rm_rf @repo\n+    g = Git.clone(\"ssh://git@github.com/#{@user}/#{@repo}.git\", @repo)\n+\n+    # create new branch based on target branch\n+    g.branch(test_branch).checkout\n+    g.reset_hard(\"origin/#{@target_branch}\")\n+\n+    # add new content and commit\n+    new_file = File.join(g.dir.path, 'test.txt')\n+    File.open(new_file, 'w') { |f| f.write(rand_string) }\n+    g.add(new_file)\n+    commit_msg = \"Add content to test.txt - #{rand_string}\"\n+    g.commit(commit_msg)\n+\n+    # push and create a pull request\n+    g.push('origin', test_branch, :force => true)\n+    gh = Octokit::Client.new(:access_token => @api_token)\n+    pr = gh.create_pull_request(repo_fqn, @target_branch, test_branch,\n+                                commit_msg)\n+\n+    puts \"opening pull request #{pr.html_url}\"\n+\n+    # poll on the pull request commit status named 'check'\n+    puts \"waiting for check status\\n\"\n+    wait_successful_pr_status(gh, repo_fqn, pr, 'check')\n+\n+    # Add a 'merge' label to the pull request\n+    puts \"adding a merge label\\n\"","path":"integration/spec/github_workflow_spec.rb","position":68,"original_position":68,"commit_id":"4eceb7eb0ad41ddd12801a899b508229163fecdc","original_commit_id":"4eceb7eb0ad41ddd12801a899b508229163fecdc","user":{"login":"ytsarev","id":518532,"avatar_url":"https://avatars.githubusercontent.com/u/518532?v=3","gravatar_id":"","url":"https://api.github.com/users/ytsarev","html_url":"https://github.com/ytsarev","followers_url":"https://api.github.com/users/ytsarev/followers","following_url":"https://api.github.com/users/ytsarev/following{/other_user}","gists_url":"https://api.github.com/users/ytsarev/gists{/gist_id}","starred_url":"https://api.github.com/users/ytsarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ytsarev/subscriptions","organizations_url":"https://api.github.com/users/ytsarev/orgs","repos_url":"https://api.github.com/users/ytsarev/repos","events_url":"https://api.github.com/users/ytsarev/events{/privacy}","received_events_url":"https://api.github.com/users/ytsarev/received_events","type":"User","site_admin":false},"body":"`puts` adds newline automatically","created_at":"2016-02-10T11:33:00Z","updated_at":"2016-02-10T11:33:00Z","html_url":"https://github.com/gooddata/zuul/pull/3#discussion_r52445889","pull_request_url":"https://api.github.com/repos/gooddata/zuul/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/gooddata/zuul/pulls/comments/52445889"},"html":{"href":"https://github.com/gooddata/zuul/pull/3#discussion_r52445889"},"pull_request":{"href":"https://api.github.com/repos/gooddata/zuul/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/gooddata/zuul/pulls/3","id":58747637,"html_url":"https://github.com/gooddata/zuul/pull/3","diff_url":"https://github.com/gooddata/zuul/pull/3.diff","patch_url":"https://github.com/gooddata/zuul/pull/3.patch","issue_url":"https://api.github.com/repos/gooddata/zuul/issues/3","number":3,"state":"open","locked":false,"title":"Integration test for GitHub","user":{"login":"hrubi","id":1828904,"avatar_url":"https://avatars.githubusercontent.com/u/1828904?v=3","gravatar_id":"","url":"https://api.github.com/users/hrubi","html_url":"https://github.com/hrubi","followers_url":"https://api.github.com/users/hrubi/followers","following_url":"https://api.github.com/users/hrubi/following{/other_user}","gists_url":"https://api.github.com/users/hrubi/gists{/gist_id}","starred_url":"https://api.github.com/users/hrubi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrubi/subscriptions","organizations_url":"https://api.github.com/users/hrubi/orgs","repos_url":"https://api.github.com/users/hrubi/repos","events_url":"https://api.github.com/users/hrubi/events{/privacy}","received_events_url":"https://api.github.com/users/hrubi/received_events","type":"User","site_admin":false},"body":"Create a pull request, wait for the check pipeline, add merge label and\r\nwait for the gate queue.\r\n\r\nChange-Id: I094b9712c6e8bb768c0f71b0448cda4990723b9b","created_at":"2016-02-09T13:35:50Z","updated_at":"2016-02-10T11:33:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"630808b47789fb9fb81c97537579ffa7ae98fd2c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gooddata/zuul/pulls/3/commits","review_comments_url":"https://api.github.com/repos/gooddata/zuul/pulls/3/comments","review_comment_url":"https://api.github.com/repos/gooddata/zuul/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gooddata/zuul/issues/3/comments","statuses_url":"https://api.github.com/repos/gooddata/zuul/statuses/4eceb7eb0ad41ddd12801a899b508229163fecdc","head":{"label":"hrubi:gd-patches-integration","ref":"gd-patches-integration","sha":"4eceb7eb0ad41ddd12801a899b508229163fecdc","user":{"login":"hrubi","id":1828904,"avatar_url":"https://avatars.githubusercontent.com/u/1828904?v=3","gravatar_id":"","url":"https://api.github.com/users/hrubi","html_url":"https://github.com/hrubi","followers_url":"https://api.github.com/users/hrubi/followers","following_url":"https://api.github.com/users/hrubi/following{/other_user}","gists_url":"https://api.github.com/users/hrubi/gists{/gist_id}","starred_url":"https://api.github.com/users/hrubi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrubi/subscriptions","organizations_url":"https://api.github.com/users/hrubi/orgs","repos_url":"https://api.github.com/users/hrubi/repos","events_url":"https://api.github.com/users/hrubi/events{/privacy}","received_events_url":"https://api.github.com/users/hrubi/received_events","type":"User","site_admin":false},"repo":{"id":46268182,"name":"zuul","full_name":"hrubi/zuul","owner":{"login":"hrubi","id":1828904,"avatar_url":"https://avatars.githubusercontent.com/u/1828904?v=3","gravatar_id":"","url":"https://api.github.com/users/hrubi","html_url":"https://github.com/hrubi","followers_url":"https://api.github.com/users/hrubi/followers","following_url":"https://api.github.com/users/hrubi/following{/other_user}","gists_url":"https://api.github.com/users/hrubi/gists{/gist_id}","starred_url":"https://api.github.com/users/hrubi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrubi/subscriptions","organizations_url":"https://api.github.com/users/hrubi/orgs","repos_url":"https://api.github.com/users/hrubi/repos","events_url":"https://api.github.com/users/hrubi/events{/privacy}","received_events_url":"https://api.github.com/users/hrubi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hrubi/zuul","description":null,"fork":true,"url":"https://api.github.com/repos/hrubi/zuul","forks_url":"https://api.github.com/repos/hrubi/zuul/forks","keys_url":"https://api.github.com/repos/hrubi/zuul/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hrubi/zuul/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hrubi/zuul/teams","hooks_url":"https://api.github.com/repos/hrubi/zuul/hooks","issue_events_url":"https://api.github.com/repos/hrubi/zuul/issues/events{/number}","events_url":"https://api.github.com/repos/hrubi/zuul/events","assignees_url":"https://api.github.com/repos/hrubi/zuul/assignees{/user}","branches_url":"https://api.github.com/repos/hrubi/zuul/branches{/branch}","tags_url":"https://api.github.com/repos/hrubi/zuul/tags","blobs_url":"https://api.github.com/repos/hrubi/zuul/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hrubi/zuul/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hrubi/zuul/git/refs{/sha}","trees_url":"https://api.github.com/repos/hrubi/zuul/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hrubi/zuul/statuses/{sha}","languages_url":"https://api.github.com/repos/hrubi/zuul/languages","stargazers_url":"https://api.github.com/repos/hrubi/zuul/stargazers","contributors_url":"https://api.github.com/repos/hrubi/zuul/contributors","subscribers_url":"https://api.github.com/repos/hrubi/zuul/subscribers","subscription_url":"https://api.github.com/repos/hrubi/zuul/subscription","commits_url":"https://api.github.com/repos/hrubi/zuul/commits{/sha}","git_commits_url":"https://api.github.com/repos/hrubi/zuul/git/commits{/sha}","comments_url":"https://api.github.com/repos/hrubi/zuul/comments{/number}","issue_comment_url":"https://api.github.com/repos/hrubi/zuul/issues/comments{/number}","contents_url":"https://api.github.com/repos/hrubi/zuul/contents/{+path}","compare_url":"https://api.github.com/repos/hrubi/zuul/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hrubi/zuul/merges","archive_url":"https://api.github.com/repos/hrubi/zuul/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hrubi/zuul/downloads","issues_url":"https://api.github.com/repos/hrubi/zuul/issues{/number}","pulls_url":"https://api.github.com/repos/hrubi/zuul/pulls{/number}","milestones_url":"https://api.github.com/repos/hrubi/zuul/milestones{/number}","notifications_url":"https://api.github.com/repos/hrubi/zuul/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hrubi/zuul/labels{/name}","releases_url":"https://api.github.com/repos/hrubi/zuul/releases{/id}","deployments_url":"https://api.github.com/repos/hrubi/zuul/deployments","created_at":"2015-11-16T10:35:10Z","updated_at":"2015-11-16T10:35:12Z","pushed_at":"2016-02-09T15:22:05Z","git_url":"git://github.com/hrubi/zuul.git","ssh_url":"git@github.com:hrubi/zuul.git","clone_url":"https://github.com/hrubi/zuul.git","svn_url":"https://github.com/hrubi/zuul","homepage":"http://openstack.org","size":2674,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gooddata:gd-patches","ref":"gd-patches","sha":"575ff6c41024f18e5fad78503e8e818d4b97755f","user":{"login":"gooddata","id":291394,"avatar_url":"https://avatars.githubusercontent.com/u/291394?v=3","gravatar_id":"","url":"https://api.github.com/users/gooddata","html_url":"https://github.com/gooddata","followers_url":"https://api.github.com/users/gooddata/followers","following_url":"https://api.github.com/users/gooddata/following{/other_user}","gists_url":"https://api.github.com/users/gooddata/gists{/gist_id}","starred_url":"https://api.github.com/users/gooddata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gooddata/subscriptions","organizations_url":"https://api.github.com/users/gooddata/orgs","repos_url":"https://api.github.com/users/gooddata/repos","events_url":"https://api.github.com/users/gooddata/events{/privacy}","received_events_url":"https://api.github.com/users/gooddata/received_events","type":"Organization","site_admin":false},"repo":{"id":40302139,"name":"zuul","full_name":"gooddata/zuul","owner":{"login":"gooddata","id":291394,"avatar_url":"https://avatars.githubusercontent.com/u/291394?v=3","gravatar_id":"","url":"https://api.github.com/users/gooddata","html_url":"https://github.com/gooddata","followers_url":"https://api.github.com/users/gooddata/followers","following_url":"https://api.github.com/users/gooddata/following{/other_user}","gists_url":"https://api.github.com/users/gooddata/gists{/gist_id}","starred_url":"https://api.github.com/users/gooddata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gooddata/subscriptions","organizations_url":"https://api.github.com/users/gooddata/orgs","repos_url":"https://api.github.com/users/gooddata/repos","events_url":"https://api.github.com/users/gooddata/events{/privacy}","received_events_url":"https://api.github.com/users/gooddata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gooddata/zuul","description":null,"fork":true,"url":"https://api.github.com/repos/gooddata/zuul","forks_url":"https://api.github.com/repos/gooddata/zuul/forks","keys_url":"https://api.github.com/repos/gooddata/zuul/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gooddata/zuul/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gooddata/zuul/teams","hooks_url":"https://api.github.com/repos/gooddata/zuul/hooks","issue_events_url":"https://api.github.com/repos/gooddata/zuul/issues/events{/number}","events_url":"https://api.github.com/repos/gooddata/zuul/events","assignees_url":"https://api.github.com/repos/gooddata/zuul/assignees{/user}","branches_url":"https://api.github.com/repos/gooddata/zuul/branches{/branch}","tags_url":"https://api.github.com/repos/gooddata/zuul/tags","blobs_url":"https://api.github.com/repos/gooddata/zuul/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gooddata/zuul/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gooddata/zuul/git/refs{/sha}","trees_url":"https://api.github.com/repos/gooddata/zuul/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gooddata/zuul/statuses/{sha}","languages_url":"https://api.github.com/repos/gooddata/zuul/languages","stargazers_url":"https://api.github.com/repos/gooddata/zuul/stargazers","contributors_url":"https://api.github.com/repos/gooddata/zuul/contributors","subscribers_url":"https://api.github.com/repos/gooddata/zuul/subscribers","subscription_url":"https://api.github.com/repos/gooddata/zuul/subscription","commits_url":"https://api.github.com/repos/gooddata/zuul/commits{/sha}","git_commits_url":"https://api.github.com/repos/gooddata/zuul/git/commits{/sha}","comments_url":"https://api.github.com/repos/gooddata/zuul/comments{/number}","issue_comment_url":"https://api.github.com/repos/gooddata/zuul/issues/comments{/number}","contents_url":"https://api.github.com/repos/gooddata/zuul/contents/{+path}","compare_url":"https://api.github.com/repos/gooddata/zuul/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gooddata/zuul/merges","archive_url":"https://api.github.com/repos/gooddata/zuul/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gooddata/zuul/downloads","issues_url":"https://api.github.com/repos/gooddata/zuul/issues{/number}","pulls_url":"https://api.github.com/repos/gooddata/zuul/pulls{/number}","milestones_url":"https://api.github.com/repos/gooddata/zuul/milestones{/number}","notifications_url":"https://api.github.com/repos/gooddata/zuul/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gooddata/zuul/labels{/name}","releases_url":"https://api.github.com/repos/gooddata/zuul/releases{/id}","deployments_url":"https://api.github.com/repos/gooddata/zuul/deployments","created_at":"2015-08-06T11:51:45Z","updated_at":"2015-08-06T11:51:46Z","pushed_at":"2016-02-09T13:35:51Z","git_url":"git://github.com/gooddata/zuul.git","ssh_url":"git@github.com:gooddata/zuul.git","clone_url":"https://github.com/gooddata/zuul.git","svn_url":"https://github.com/gooddata/zuul","homepage":"http://openstack.org","size":2695,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gooddata/zuul/pulls/3"},"html":{"href":"https://github.com/gooddata/zuul/pull/3"},"issue":{"href":"https://api.github.com/repos/gooddata/zuul/issues/3"},"comments":{"href":"https://api.github.com/repos/gooddata/zuul/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/gooddata/zuul/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/gooddata/zuul/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gooddata/zuul/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/gooddata/zuul/statuses/4eceb7eb0ad41ddd12801a899b508229163fecdc"}}}}