{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/comments/118773124","pull_request_review_id":40600555,"id":118773124,"diff_hunk":"@@ -0,0 +1,106 @@\n+require \"spec_helper\"\n+\n+RSpec.describe StaleIssueMarker do\n+  let(:fq_repo_name) { \"foo/bar\" }\n+\n+  let(:already_stale_issue) do\n+    double(\"already_stale_issue\",\n+           :updated_at    => 8.months.ago,\n+           :fq_repo_name  => fq_repo_name,\n+           :number        => 3,\n+           :pull_request? => false,\n+           :labels        => %w(stale bug))\n+  end\n+\n+  let(:stale_issue) do\n+    double(\"stale_issue\",\n+           :updated_at    => 7.months.ago,\n+           :fq_repo_name  => fq_repo_name,\n+           :number        => 4,\n+           :pull_request? => false,\n+           :labels        => [\"bug\"])\n+  end\n+\n+  let(:stale_pr) do\n+    double(\"stale_pr\",\n+           :updated_at    => 7.months.ago,\n+           :fq_repo_name  => fq_repo_name,\n+           :number        => 2,\n+           :pull_request? => true,\n+           :labels        => [])\n+  end\n+\n+  let(:fresh_issue) do\n+    double(\"fresh_issue\",\n+           :updated_at    => 2.months.ago,\n+           :fq_repo_name  => fq_repo_name,\n+           :number        => 5,\n+           :pull_request? => false,\n+           :labels        => [\"bug\"])\n+  end\n+\n+  let(:fresh_pr) do\n+    double(\"fresh_pr\",\n+           :updated_at    => 2.months.ago,\n+           :fq_repo_name  => fq_repo_name,\n+           :number        => 6,\n+           :pull_request? => true,\n+           :labels        => [\"bug\"])\n+  end\n+\n+  let(:stale_but_pinned_issue) do\n+    double(\"stale_but_pinned_issue\",\n+           :updated_at    => 9.months.ago,\n+           :fq_repo_name  => fq_repo_name,\n+           :number        => 1,\n+           :pull_request? => true,\n+           :labels        => %w(bug pinned))\n+  end\n+\n+  let(:issues) do\n+    [already_stale_issue,\n+     stale_issue,\n+     stale_pr,\n+     fresh_issue,\n+     fresh_pr,\n+     stale_but_pinned_issue]\n+  end\n+\n+  before do\n+    allow(GithubService).to receive(:issues)\n+      .with(fq_repo_name, :state => :open, :sort => :updated, :direction => :asc)\n+      .and_return(issues)\n+    allow(GithubService).to receive(:valid_label?).with(fq_repo_name, \"stale\").and_return(true)\n+    allow(Sidekiq).to receive(:logger).and_return(double(:info => nil))\n+  end\n+\n+  after do\n+    described_class.new.perform(fq_repo_name)","path":"spec/workers/stale_issue_marker_spec.rb","position":78,"original_position":78,"commit_id":"6b2e9f08682c63f0b626dfed4868090aab6c803c","original_commit_id":"6b2e9f08682c63f0b626dfed4868090aab6c803c","user":{"login":"bdunne","id":651659,"avatar_url":"https://avatars2.githubusercontent.com/u/651659?v=3","gravatar_id":"","url":"https://api.github.com/users/bdunne","html_url":"https://github.com/bdunne","followers_url":"https://api.github.com/users/bdunne/followers","following_url":"https://api.github.com/users/bdunne/following{/other_user}","gists_url":"https://api.github.com/users/bdunne/gists{/gist_id}","starred_url":"https://api.github.com/users/bdunne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdunne/subscriptions","organizations_url":"https://api.github.com/users/bdunne/orgs","repos_url":"https://api.github.com/users/bdunne/repos","events_url":"https://api.github.com/users/bdunne/events{/privacy}","received_events_url":"https://api.github.com/users/bdunne/received_events","type":"User","site_admin":false},"body":"shouldn't this live inside the test?","created_at":"2017-05-26T19:21:54Z","updated_at":"2017-05-26T19:21:54Z","html_url":"https://github.com/ManageIQ/miq_bot/pull/331#discussion_r118773124","pull_request_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/331","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/comments/118773124"},"html":{"href":"https://github.com/ManageIQ/miq_bot/pull/331#discussion_r118773124"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/331"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/331","id":108854461,"html_url":"https://github.com/ManageIQ/miq_bot/pull/331","diff_url":"https://github.com/ManageIQ/miq_bot/pull/331.diff","patch_url":"https://github.com/ManageIQ/miq_bot/pull/331.patch","issue_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues/331","number":331,"state":"open","locked":false,"title":"Stale issue/PR marker","user":{"login":"chrisarcand","id":2430490,"avatar_url":"https://avatars1.githubusercontent.com/u/2430490?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisarcand","html_url":"https://github.com/chrisarcand","followers_url":"https://api.github.com/users/chrisarcand/followers","following_url":"https://api.github.com/users/chrisarcand/following{/other_user}","gists_url":"https://api.github.com/users/chrisarcand/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisarcand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisarcand/subscriptions","organizations_url":"https://api.github.com/users/chrisarcand/orgs","repos_url":"https://api.github.com/users/chrisarcand/repos","events_url":"https://api.github.com/users/chrisarcand/events{/privacy}","received_events_url":"https://api.github.com/users/chrisarcand/received_events","type":"User","site_admin":false},"body":"Inspired by rails-bot (which in this case is nothing more than [a manual script](https://github.com/rafaelfranca/rails-tools/blob/master/bin/mark_stale_issues) run by Rafael every few months), this worker takes out the trash over the weekend and helps clean up old issues and pull requests in every enabled repo.\r\n\r\n![](http://screenshots.chrisarcand.com/4zbep.jpg)\r\n\r\n### Details\r\n\r\n* A pull request or issue that hasn't been updated (commented on, whatever) in the last **6 months** is considered stale.\r\n* Stale *issues* are marked with the 'stale' label and commented on.\r\n* Stale *pull requests* are closed and commented on. \r\n* As with rails-bot, issues/pull requests can be 'pinned' - that is, if the label 'pinned' (or any other label that we deem worthy) is present on the issue, it will not be marked as stale or closed even if it's extremely old. This is useful for longstanding things that we know are a continuing issue but take a really long time to fix. \r\n* The StaleIssueMarker is run every Saturday, specifically, as it potentially uses a fair number of queries and not many people are working on a Saturday. Freshens up the repos for a lovely Monday morning 🌅 ☕️ \r\n* This worker is a little different in that I've split the concept of 'the worker that does the thing' and 'the worker that schedules the action to be taken with multiple workers'. That is, there's a `StaleIssueMarker` and a `Schedulers::StaleIssueMarker`. We should probably follow a pattern more like this with other things we do to do more things asynchronously. Thoughts?\r\n\r\n*Why are you labeling issues but closing PRs?*  \r\n* As assumed with rails-bot, issues should probably be at least glanced at before actually closed. If an issue is marked as 'stale', the finder of the issue should assume that unless they reproduce the issue soon, a committer can come along and just close it without having to spend the time to explain themselves too much. \r\n* Pull requests, on the other hand, have a true shelf life. If a PR isn't touched for months, there's a *very high* probability that it isn't even mergable and the contributor will probably just close it anyway - and even if it were to be eventually worked on again, it will probably be changed enough that the contributor should just make a brand new pull request anyway.\r\n\r\n### Deployment\r\n\r\nThis includes tests, but even still, changing the state of hundreds of issues/PRs on the core repo is scary stuff 👻  Therefore, I'll run this on the miq_bot repo first to make sure it doesn't cause a chaos monkey 🐒 ","created_at":"2017-03-02T21:24:57Z","updated_at":"2017-05-26T19:21:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6eccb9ebad287d77602a74f42c5ac19f5e3e7b15","assignee":{"login":"Fryguy","id":52120,"avatar_url":"https://avatars0.githubusercontent.com/u/52120?v=3","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"assignees":[{"login":"Fryguy","id":52120,"avatar_url":"https://avatars0.githubusercontent.com/u/52120?v=3","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/331/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/331/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues/331/comments","statuses_url":"https://api.github.com/repos/ManageIQ/miq_bot/statuses/6b2e9f08682c63f0b626dfed4868090aab6c803c","head":{"label":"chrisarcand:stale-issue-marker","ref":"stale-issue-marker","sha":"6b2e9f08682c63f0b626dfed4868090aab6c803c","user":{"login":"chrisarcand","id":2430490,"avatar_url":"https://avatars1.githubusercontent.com/u/2430490?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisarcand","html_url":"https://github.com/chrisarcand","followers_url":"https://api.github.com/users/chrisarcand/followers","following_url":"https://api.github.com/users/chrisarcand/following{/other_user}","gists_url":"https://api.github.com/users/chrisarcand/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisarcand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisarcand/subscriptions","organizations_url":"https://api.github.com/users/chrisarcand/orgs","repos_url":"https://api.github.com/users/chrisarcand/repos","events_url":"https://api.github.com/users/chrisarcand/events{/privacy}","received_events_url":"https://api.github.com/users/chrisarcand/received_events","type":"User","site_admin":false},"repo":{"id":48196294,"name":"miq_bot","full_name":"chrisarcand/miq_bot","owner":{"login":"chrisarcand","id":2430490,"avatar_url":"https://avatars1.githubusercontent.com/u/2430490?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisarcand","html_url":"https://github.com/chrisarcand","followers_url":"https://api.github.com/users/chrisarcand/followers","following_url":"https://api.github.com/users/chrisarcand/following{/other_user}","gists_url":"https://api.github.com/users/chrisarcand/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisarcand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisarcand/subscriptions","organizations_url":"https://api.github.com/users/chrisarcand/orgs","repos_url":"https://api.github.com/users/chrisarcand/repos","events_url":"https://api.github.com/users/chrisarcand/events{/privacy}","received_events_url":"https://api.github.com/users/chrisarcand/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chrisarcand/miq_bot","description":"ManageIQ Bot","fork":true,"url":"https://api.github.com/repos/chrisarcand/miq_bot","forks_url":"https://api.github.com/repos/chrisarcand/miq_bot/forks","keys_url":"https://api.github.com/repos/chrisarcand/miq_bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chrisarcand/miq_bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chrisarcand/miq_bot/teams","hooks_url":"https://api.github.com/repos/chrisarcand/miq_bot/hooks","issue_events_url":"https://api.github.com/repos/chrisarcand/miq_bot/issues/events{/number}","events_url":"https://api.github.com/repos/chrisarcand/miq_bot/events","assignees_url":"https://api.github.com/repos/chrisarcand/miq_bot/assignees{/user}","branches_url":"https://api.github.com/repos/chrisarcand/miq_bot/branches{/branch}","tags_url":"https://api.github.com/repos/chrisarcand/miq_bot/tags","blobs_url":"https://api.github.com/repos/chrisarcand/miq_bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chrisarcand/miq_bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chrisarcand/miq_bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/chrisarcand/miq_bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chrisarcand/miq_bot/statuses/{sha}","languages_url":"https://api.github.com/repos/chrisarcand/miq_bot/languages","stargazers_url":"https://api.github.com/repos/chrisarcand/miq_bot/stargazers","contributors_url":"https://api.github.com/repos/chrisarcand/miq_bot/contributors","subscribers_url":"https://api.github.com/repos/chrisarcand/miq_bot/subscribers","subscription_url":"https://api.github.com/repos/chrisarcand/miq_bot/subscription","commits_url":"https://api.github.com/repos/chrisarcand/miq_bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/chrisarcand/miq_bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/chrisarcand/miq_bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/chrisarcand/miq_bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/chrisarcand/miq_bot/contents/{+path}","compare_url":"https://api.github.com/repos/chrisarcand/miq_bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chrisarcand/miq_bot/merges","archive_url":"https://api.github.com/repos/chrisarcand/miq_bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chrisarcand/miq_bot/downloads","issues_url":"https://api.github.com/repos/chrisarcand/miq_bot/issues{/number}","pulls_url":"https://api.github.com/repos/chrisarcand/miq_bot/pulls{/number}","milestones_url":"https://api.github.com/repos/chrisarcand/miq_bot/milestones{/number}","notifications_url":"https://api.github.com/repos/chrisarcand/miq_bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chrisarcand/miq_bot/labels{/name}","releases_url":"https://api.github.com/repos/chrisarcand/miq_bot/releases{/id}","deployments_url":"https://api.github.com/repos/chrisarcand/miq_bot/deployments","created_at":"2015-12-17T20:19:50Z","updated_at":"2016-01-20T01:24:08Z","pushed_at":"2017-05-24T21:43:28Z","git_url":"git://github.com/chrisarcand/miq_bot.git","ssh_url":"git@github.com:chrisarcand/miq_bot.git","clone_url":"https://github.com/chrisarcand/miq_bot.git","svn_url":"https://github.com/chrisarcand/miq_bot","homepage":null,"size":852,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"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":"ManageIQ:master","ref":"master","sha":"532396e4810a5eec97b8e74f04e29d8a8a7b0ce5","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars3.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":23851775,"name":"miq_bot","full_name":"ManageIQ/miq_bot","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars3.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/miq_bot","description":"ManageIQ Bot","fork":false,"url":"https://api.github.com/repos/ManageIQ/miq_bot","forks_url":"https://api.github.com/repos/ManageIQ/miq_bot/forks","keys_url":"https://api.github.com/repos/ManageIQ/miq_bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/miq_bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/miq_bot/teams","hooks_url":"https://api.github.com/repos/ManageIQ/miq_bot/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/miq_bot/events","assignees_url":"https://api.github.com/repos/ManageIQ/miq_bot/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/miq_bot/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/miq_bot/tags","blobs_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/miq_bot/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/miq_bot/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/miq_bot/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/miq_bot/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/miq_bot/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/miq_bot/subscription","commits_url":"https://api.github.com/repos/ManageIQ/miq_bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/miq_bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/miq_bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/miq_bot/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/miq_bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/miq_bot/merges","archive_url":"https://api.github.com/repos/ManageIQ/miq_bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/miq_bot/downloads","issues_url":"https://api.github.com/repos/ManageIQ/miq_bot/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/miq_bot/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/miq_bot/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/miq_bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/miq_bot/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/miq_bot/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/miq_bot/deployments","created_at":"2014-09-09T22:02:14Z","updated_at":"2017-03-29T18:26:02Z","pushed_at":"2017-05-25T18:36:49Z","git_url":"git://github.com/ManageIQ/miq_bot.git","ssh_url":"git@github.com:ManageIQ/miq_bot.git","clone_url":"https://github.com/ManageIQ/miq_bot.git","svn_url":"https://github.com/ManageIQ/miq_bot","homepage":null,"size":835,"stargazers_count":10,"watchers_count":10,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":62,"forks":24,"open_issues":62,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/331"},"html":{"href":"https://github.com/ManageIQ/miq_bot/pull/331"},"issue":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/issues/331"},"comments":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/issues/331/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/331/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/pulls/331/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/miq_bot/statuses/6b2e9f08682c63f0b626dfed4868090aab6c803c"}}}}
{"actor":{"display_login":"bdunne"}}