omg_pull_request 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  # See http://help.github.com/ignore-files/ for more about ignoring files.
2
2
  #
3
+
3
4
  # If you find yourself ignoring temporary files generated by your text editor
4
5
  # or operating system, you probably want to add a global ignore instead:
5
6
  # git config --global core.excludesfile ~/.gitignore_global
@@ -45,3 +46,5 @@ config/initializers/activeresource_debug.rb
45
46
  tags
46
47
  .rbenv-version
47
48
  test/omg_pull_request/config.yml
49
+ test/integrations/config.yml
50
+ test/integrations/.stage
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omg_pull_request (0.0.6)
4
+ omg_pull_request (0.0.7)
5
5
  activesupport (>= 3.2.8)
6
6
  aws-s3 (>= 0.6.3)
7
7
  faraday (>= 0.8.4)
data/README.md CHANGED
@@ -27,11 +27,11 @@ On running the test suite an animated gif can be generated of the lolcommits tha
27
27
 
28
28
  ## Installation
29
29
 
30
- 1. In a rails project, add `omg_pull_request` to the Gemfile.
31
- 2. Make an `omg_pull_request` directory in the project's `test` directory.
32
- 3. Add a `database.yml` file in the `omg_pull_request` dir. This will drop databases, so it is suggested this points to different databases than the main `config/database.yml` file
33
- 4. Create a github user to run the tests as. This user will need to have access to the repo the test is run on. It can be your developer account, or a new account specifically for this.
34
- 5. Add a `config.yml` file in the `omg_pull_request` dir. It follows this template:
30
+ * In a rails project, add `omg_pull_request` to the Gemfile.
31
+ * Make an `omg_pull_request` directory in the project's `test` directory.
32
+ * Add a `database.yml` file in the `omg_pull_request` dir. This will drop databases, so it is suggested this points to different databases than the main `config/database.yml` file
33
+ * Create a github user to run the tests as. This user will need to have access to the repo the test is run on. It can be your developer account, or a new account specifically for this.
34
+ * Add a `config.yml` file in the `omg_pull_request` dir. It follows this template:
35
35
 
36
36
  ```
37
37
  repo_owner: kenmazaika
@@ -43,7 +43,8 @@ github_credentials:
43
43
  login: github_user
44
44
  password: github_password
45
45
 
46
- aws:
46
+ storage:
47
+ provider: Aws
47
48
  access_token: s3_token
48
49
  secret_token: s3_secret
49
50
  bucket: s3_bucket
@@ -57,10 +58,35 @@ prowl:
57
58
 
58
59
  This is a sample config, with sensitive data scrubbed for running tests on the repo: https://github.com/kenmazaika/pictures. One important note is for the prowl integration it should contain a key for both the github user_name and the email address that can be pulled from git.
59
60
 
60
- 6. On a server someplace clone the repo. This cloned repo will be managed by the daemon, and the tests will run on it from now on.
61
- 7. In a screen session run `omg_pull_request`.
62
- 8. Enjoy.
61
+ * On a server someplace clone the repo. This cloned repo will be managed by the daemon, and the tests will run on it from now on.
62
+ * In a screen session run `omg_pull_request`.
63
+ * Enjoy.
64
+
65
+ ### Configuration
66
+
67
+ A detailed specification of the available configuration options can be found in the markdown file located docs/configuration.md.
63
68
 
64
69
  ### Example
65
70
 
66
- You can see an example of a successful pull request that has been `omg_pull_request`ified here: https://github.com/where/omg_pull_request/pull/1.
71
+ You can see an example of a successful pull request that has been `omg_pull_request`ified here: https://github.com/where/omg_pull_request/pull/1. And an example of a failed pull request that has been `omg_pull_request`ified here: https://github.com/where/omg_pull_request/pull/2.
72
+
73
+ ### Future Features
74
+
75
+ Got an idea for a future feature? Know of a cool service that you think omg_pull_request integration with would be nice? Open up a github issue.
76
+
77
+ #### Current Thoughts
78
+
79
+ * Twilio Integration would be a cool feature. Getting a text message when tests pass would be nice.
80
+ * Monitoring the pull requests and sending the author a notification when the pull request has been closed (either merged, or just closed) would be useful.
81
+
82
+ #### Running Integration Tests
83
+
84
+ Integration Tests call the github api, and verify the full flow works. Before you run, you'll need to authenticate with a github profile that the tests can run on. To do this run `rake test:setup`.
85
+
86
+ ### Contributors
87
+
88
+ * Ken Mazaika
89
+ * Jean-Charles Sisk
90
+ * Master William Desmarais
91
+ * Ian Asaff
92
+ * Jack Thorne
data/Rakefile CHANGED
@@ -4,9 +4,28 @@ require 'rake/testtask'
4
4
 
5
5
  include Rake::DSL
6
6
 
7
- Rake::TestTask.new do |t|
8
- t.pattern = 'test/**/*_test.rb'
7
+ Rake::TestTask.new("test:units") do |t|
8
+ t.pattern = 'test/units/**/*_test.rb'
9
9
  end
10
- task :default => [:test]
10
+
11
+ Rake::TestTask.new("test:integration") do |t|
12
+ t.pattern = 'test/integrations/**/*test.rb'
13
+ end
14
+
15
+ namespace :test do
16
+ task :setup do
17
+ print "Github Login: "
18
+ login = STDIN.gets.strip
19
+
20
+ print "Github Password: "
21
+ password = STDIN.gets.strip
22
+
23
+ config = {:login => login, :password => password}
24
+ File.open("test/integrations/config.yml", 'w') {|f| f.write(config.to_yaml) }
25
+ end
26
+ end
27
+
28
+ task :default => ["test:units", "test:integration"]
29
+
11
30
 
12
31
 
@@ -0,0 +1,120 @@
1
+ ## Omg! Pull Request! Configuration
2
+
3
+ The daemon is configured based upon the configuration yaml file that is loaded. The location, and more general information about the file can be found in the README. This file is designed to give a detailed description of the different configuration options that are available.
4
+
5
+ ### Github Configuration
6
+
7
+ `repo_owner` should be set to the github user, or organization where the repository is listed. For example, if we wanted to run the daemon against this project, since the github url is: [https://github.com/where/omg_pull_request](https://github.com/where/omg_pull_request), the repo owner would be set to `where`.
8
+
9
+ `repo` should be set to the github repo name. For example, if we wanted to run the daemon against this project, since the github url is: [https://github.com/where/omg_pull_request](https://github.com/where/omg_pull_request), the repo would be set to `omg_pull_request`.
10
+
11
+ `github_credentials` should be set to the login and password of the user who wishes to make comments on the pull request with the status of the tests. This user will need to have read access to the repo. This field accepts two sub-parameters of `login` and `password`.
12
+
13
+ Example:
14
+
15
+ ```
16
+ repo_owner: kenmazaika
17
+ repo: pictures
18
+ github_credentials:
19
+ login: username
20
+ password: password
21
+ ```
22
+
23
+ ### Localization
24
+ `locale` sets which localization file should be used for the messages that get generated. The list of valid locales is: `"en"`. If you wish to add support for a different locale, fork this project, and add the i18n yml file to the locales directory and add the file to the i18n load path.
25
+
26
+ Example:
27
+
28
+ ```
29
+ locale: en
30
+ ```
31
+
32
+ ### Storage
33
+
34
+ `storage` is the section of the config file that describes where the test output will be stored. This accepts the subparameter of `provider`. Since the full test output is more than we want to display on the comment for the test result, we want to link to a file where it can be accessed. The provider can be set to use Amazon S3, or Github Gists.
35
+
36
+ #### Gist
37
+
38
+ Gist is the simplest type to configure. The Gist provider will store the result in a Github Gist under the user whose `github_credentials` are stored for. If set to Gist no other parameters are required.
39
+
40
+ Example:
41
+
42
+ ```
43
+ storage:
44
+ provider: Gist
45
+ ```
46
+
47
+ #### Amazon S3
48
+
49
+ Amazon S3 requires information about the access token, secret, and bucket to be added to the yaml file.
50
+
51
+ Example:
52
+
53
+ ```
54
+ storage:
55
+ provider: Aws
56
+ bucket: omg_bucket
57
+ access_token: s3_access_token
58
+ secret_token: s3_secret_token
59
+ ```
60
+
61
+ ### Test Runner Configuration
62
+
63
+ The test runner that is selected describes how to run the tests. If you wish to add support for a non ruby or an altered ruby test runner, you'll want to fork the project and add a new runner.
64
+
65
+ The test is treated as passing if the execute_tests method of the runner returns a `true` value.
66
+
67
+ #### Rails
68
+
69
+ This has a basic setup, teardown, and execution path that should work for most modern rails applications that use bundler. The implementation of which commands are run can be seen: lib/omg_pull_request/test_runner/rails.rb.
70
+
71
+ Example:
72
+
73
+ ```
74
+ runner: Rails
75
+ ```
76
+
77
+ #### Ruby
78
+
79
+ This has the basic execution path that should work for non rails ruby projects. This will be valid for most gems, and ruby libraries. The implementation is to simply run rake. The full implementation can be seen: lib/omg_pull_request/test_runner/ruby.rb.
80
+
81
+ Example:
82
+
83
+ ```
84
+ runner: Ruby
85
+ ```
86
+
87
+ #### RailsTestFast
88
+
89
+ RailsTestFast uses the `parallel_tests` gem to allow running the tests in parallel for as many cores as the machine that is running the tests has. If it's being run on a box with many cores, it can greatly improve the speed of the tests.
90
+
91
+ For this mode to work, your project must be ready to run with parallel_tests first. This requires some modification to the database.yml file, and fixing any concurrency bugs that exist in your codebase.
92
+
93
+ There are a number of helper rake tasks that need to be included. You can see details about how to set that up: in this gist.
94
+
95
+ Assuming that's up and running, you should be able to run faster rails tests.
96
+
97
+ Example:
98
+
99
+ ```
100
+ runner: RailsTestFast
101
+ ```
102
+
103
+ ### Prowl Notifications
104
+
105
+ Prowl is a service that integrates with most modern smart phones to push alerts to. This can allow a smart phone to be alerted when the tests pass or fail.
106
+
107
+ You will need to create a prowl api key and application at the [official prowl website](https://www.prowlapp.com).
108
+
109
+ Since the identify of a commiter can be found either by the user's github handle (in the case of comments) or based off the actual git commit history (obtained through the git shortlog), it requires you to add the same key for the same user's two keys. In the case of me, my github handle is `kenmazaika` and my email address is `kenmazaika@gmail.com`, so I'd add both.
110
+
111
+ Example:
112
+
113
+ ```
114
+ prowl:
115
+ application: OMG_PULL_REQUEST
116
+ keys:
117
+ kenmazaika: OMG_OMG
118
+ kenmazaika@gmail.com: OMG_OMG
119
+ regular_dude@yahoo.com: REG_DUDE
120
+ ```
@@ -1,17 +1,20 @@
1
1
  module OmgPullRequest
2
2
  class Configuration
3
- attr_reader :config
3
+ attr_accessor :config
4
4
 
5
5
  def initialize(attributes={})
6
6
  attributes.each do |attr, value|
7
7
  self.send("#{attr}=", value)
8
8
  end
9
- @config = YAML.load(File.open(self.config_file))
9
+
10
+ if File.exists?(self.config_file)
11
+ @config = YAML.load(File.open(self.config_file))
12
+ end
10
13
  end
11
14
 
12
15
 
13
16
  [:repo_owner, :repo, :database_yml, :aws, :github_credentials,
14
- :lolcommits_server_url, :prowl, :locale].each do |attr|
17
+ :lolcommits_server_url, :prowl, :locale, :storage].each do |attr|
15
18
  define_method attr do
16
19
  self.config[attr.to_s]
17
20
  end
@@ -42,6 +45,10 @@ module OmgPullRequest
42
45
  "OmgPullRequest::TestRunner::#{config['runner'] || 'Rails'}".constantize
43
46
  end
44
47
 
48
+ def storage_class
49
+ "OmgPullRequest::Storage::#{(config['storage'] || Hash.new)['provider'] || 'Gist'}".constantize
50
+ end
51
+
45
52
  module Helpers
46
53
  def delegate_config_to(config, *attrs)
47
54
  attrs.each do |attr|
@@ -13,11 +13,11 @@ module OmgPullRequest
13
13
  end
14
14
 
15
15
  def checkout!(sha)
16
- logger.log `cd #{local_repo} && git reset --hard && git fetch && git checkout #{sha}`
16
+ logger.log `cd #{local_repo} && git reset --hard && git fetch && git checkout #{sha} 2>&1`
17
17
  end
18
18
 
19
19
  def merge!(sha)
20
- merge_response = `cd #{local_repo} && git merge #{sha}`
20
+ merge_response = `cd #{local_repo} && git merge #{sha} 2>&1`
21
21
  self.logger.log merge_response
22
22
  merge_response.match(/CONFLICT/) ? :conflict : :success
23
23
  end
@@ -38,6 +38,20 @@ module OmgPullRequest
38
38
  github_client.pull_requests.list(repo_owner, repo)
39
39
  end
40
40
 
41
+ def make_gist(data, file_name)
42
+ gist = github_client.gists.create(
43
+ 'description' => 'Omg! Pull Request!',
44
+ 'public' => false,
45
+ 'files' => {
46
+ file_name => {
47
+ 'content' => data
48
+ }
49
+ }
50
+ )
51
+
52
+ gist.files[file_name].raw_url
53
+ end
54
+
41
55
  private
42
56
 
43
57
  extend Configuration::Helpers
@@ -1,7 +1,7 @@
1
1
  module OmgPullRequest
2
- module Aws
3
- class Store
4
- attr_accessor :storage_config
2
+ module Storage
3
+ class Aws
4
+ attr_accessor :configuration, :github_wrapper
5
5
  def initialize(attributes={})
6
6
  attributes.each do |attr, value|
7
7
  self.send("#{attr}=", value)
@@ -22,7 +22,7 @@ module OmgPullRequest
22
22
 
23
23
  [:access_token, :secret_token, :bucket].each do |attr|
24
24
  define_method attr do
25
- storage_config[attr]
25
+ configuration.storage[attr.to_s]
26
26
  end
27
27
  end
28
28
  end
@@ -0,0 +1,19 @@
1
+ module OmgPullRequest
2
+ module Storage
3
+ class Gist
4
+ attr_accessor :configuration, :github_wrapper
5
+
6
+ def initialize(attributes={})
7
+ attributes.each do |attr, value|
8
+ self.send("#{attr}=", value)
9
+ end
10
+ end
11
+
12
+ # TODO test
13
+ def store(data, file_name)
14
+ self.github_wrapper.make_gist(data, file_name)
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module OmgPullRequest
2
+ module TestRunner
3
+ class RailsTestFast < TestRunner::Base
4
+ def setup
5
+ execute!("cd #{local_repo} && cp #{database_yml} config/database.yml && bundle")
6
+ execute!("cd #{local_repo} && bundle exec rake db:drop:all && rake db:create:all && bundle exec rake db:schema:load")
7
+ end
8
+
9
+ def execute_tests
10
+ return execute!("cd #{local_repo} && bundle exec rake test:fast:prepare test:fast")
11
+ end
12
+
13
+ def teardown
14
+ execute!("rm #{local_repo}/log/test.log")
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module OmgPullRequest
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -9,13 +9,15 @@ require 'aws/s3'
9
9
  require 'i18n'
10
10
  require 'omg_pull_request/configuration'
11
11
  require 'omg_pull_request/test_logger'
12
- require 'omg_pull_request/aws/store'
12
+ require 'omg_pull_request/storage/aws'
13
+ require 'omg_pull_request/storage/gist'
13
14
  require 'omg_pull_request/github_wrapper'
14
15
  require 'omg_pull_request/notifications'
15
16
  require 'omg_pull_request/test_runner'
16
17
  require 'omg_pull_request/test_runner/base'
17
18
  require 'omg_pull_request/test_runner/rails'
18
19
  require 'omg_pull_request/test_runner/ruby'
20
+ require 'omg_pull_request/test_runner/rails_test_fast'
19
21
  require 'omg_pull_request/context'
20
22
  require 'omg_pull_request/git_client'
21
23
  require 'omg_pull_request/prowl'
@@ -24,9 +26,11 @@ require 'omg_pull_request/version'
24
26
 
25
27
  module OmgPullRequest
26
28
  CONFIGURATION = Configuration.new
27
- STORE = Aws::Store.new(:storage_config => CONFIGURATION.aws.symbolize_keys)
28
29
  CONTEXT = Context.new
29
30
  GITHUB_WRAPPER = GithubWrapper.new(:configuration => CONFIGURATION)
31
+
32
+ STORE = CONFIGURATION.storage_class.new(:configuration => CONFIGURATION,
33
+ :github_wrapper => GITHUB_WRAPPER)
30
34
  end
31
35
 
32
36
 
@@ -7,10 +7,8 @@ github_credentials:
7
7
  login: omg
8
8
  password: pull_request
9
9
 
10
- aws:
11
- access_token: ACCESS_TOKEN_HERE
12
- secret_token: SECRET_TOKEN_HERE
13
- bucket: BUCKET_HERE
10
+ storage:
11
+ provider: Gist
14
12
 
15
13
  prowl:
16
14
  application: OMG_PULL_REQUEST
@@ -0,0 +1,69 @@
1
+ HTTP/1.1 201 Created
2
+ Server: nginx/0.8.52
3
+ Date: Fri, 17 Dec 2010 02:02:58 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ Expires: Fri, 17 Dec 2010 02:02:58 UTC
7
+ Cache-Control: no-cache; private; no-store
8
+ Pragma: no-cache
9
+
10
+ {
11
+ "url": "https://api.github.com/gists/1",
12
+ "id": "1",
13
+ "description": "description of gist",
14
+ "public": true,
15
+ "user": {
16
+ "login": "octocat",
17
+ "id": 1,
18
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
19
+ "gravatar_id": "somehexcode",
20
+ "url": "https://api.github.com/users/octocat"
21
+ },
22
+ "files": {
23
+ "file_name": {
24
+ "size": 932,
25
+ "filename": "file_name",
26
+ "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/file_name",
27
+ "content": "contents of gist"
28
+ }
29
+ },
30
+ "comments": 0,
31
+ "html_url": "https://gist.github.com/1",
32
+ "git_pull_url": "git://gist.github.com/1.git",
33
+ "git_push_url": "git@gist.github.com:1.git",
34
+ "created_at": "2010-04-14T02:15:15Z",
35
+ "forks": [
36
+ {
37
+ "user": {
38
+ "login": "octocat",
39
+ "id": 1,
40
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
41
+ "gravatar_id": "somehexcode",
42
+ "url": "https://api.github.com/users/octocat"
43
+ },
44
+ "url": "https://api.github.com/gists/5",
45
+ "created_at": "2011-04-14T16:00:49Z"
46
+ }
47
+ ],
48
+ "history": [
49
+ {
50
+ "url": "https://api.github.com/gists/1/57a7f021a713b1c5a6a199b54cc514735d2d462f",
51
+ "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
52
+ "user": {
53
+ "login": "octocat",
54
+ "id": 1,
55
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
56
+ "gravatar_id": "somehexcode",
57
+ "url": "https://api.github.com/users/octocat"
58
+ },
59
+ "change_status": {
60
+ "deletions": 0,
61
+ "additions": 180,
62
+ "total": 180
63
+ },
64
+ "committed_at": "2010-04-14T02:15:15Z"
65
+ }
66
+ ]
67
+ }
68
+
69
+
@@ -0,0 +1,153 @@
1
+ require "minitest/autorun"
2
+ require 'yaml'
3
+ require './lib/omg_pull_request'
4
+
5
+ locale_dir = File.expand_path("../../../locales", __FILE__)
6
+ I18n.load_path = [
7
+ File.join(locale_dir, "omg.yml"),
8
+ File.join(locale_dir, "en.yml")
9
+ ]
10
+
11
+ class RunnerTest < MiniTest::Unit::TestCase
12
+ # SHHHH
13
+ OmgPullRequest::TestLogger.class_eval do
14
+ def puts(msg); end
15
+ end
16
+ OmgPullRequest::TestRunner::Base.class_eval do
17
+ def puts(msg); end
18
+ end
19
+
20
+ def setup
21
+ repo = github.repos.get(config[:login], "omg") rescue nil
22
+
23
+ unless repo
24
+ github.repos.forks.create('wherebot', 'omg')
25
+ sleep(10)
26
+ repo = github.repos.get(config[:login], "omg")
27
+ end
28
+
29
+ if Dir.exists?("#{stage_dir}/omg")
30
+ `cd #{stage_dir} && git fetch > /dev/null 2>&1`
31
+ else
32
+ `cd #{stage_dir} && git clone https://github.com/#{config[:login]}/omg.git`
33
+ end
34
+
35
+ prs = github.pull_requests.list(config[:login], "omg")
36
+
37
+ prs.each do |pr|
38
+ github.pull_requests.update config[:login], 'omg', pr.number, :state => 'closed'
39
+ end
40
+
41
+ end
42
+
43
+ def test_success
44
+ github.pull_requests.create config[:login], 'omg',
45
+ "head" => "#{config[:login]}:success",
46
+ "base" => "master",
47
+ "title" => 'Success'
48
+
49
+ prs = github.pull_requests.list(config[:login], "omg")
50
+ assert_equal 1, prs.count
51
+ pr = prs.first
52
+
53
+ runner = build_runner(pr)
54
+
55
+ runner.run
56
+
57
+ posts = github.issues.comments.list(config[:login], 'omg', pr.number)
58
+ assert_equal 2, posts.count
59
+ running = posts.first
60
+ pass = posts.last
61
+
62
+ assert running['body'].match(/Running tests/)
63
+ assert pass['body'].match(/Tests Passed/)
64
+ end
65
+
66
+ def test_failure
67
+ github.pull_requests.create config[:login], 'omg',
68
+ "head" => "#{config[:login]}:failure",
69
+ "base" => "master",
70
+ "title" => 'Failure'
71
+
72
+ prs = github.pull_requests.list(config[:login], "omg")
73
+ assert_equal 1, prs.count
74
+ pr = prs.first
75
+
76
+ runner = build_runner(pr)
77
+
78
+ runner.run
79
+
80
+ posts = github.issues.comments.list(config[:login], 'omg', pr.number)
81
+ assert_equal 2, posts.count
82
+ running = posts.first
83
+ pass = posts.last
84
+
85
+ assert running['body'].match(/Running tests/)
86
+ assert pass['body'].match(/Tests Fail/)
87
+ end
88
+
89
+ def test_conflict
90
+ github.pull_requests.create config[:login], 'omg',
91
+ "head" => "#{config[:login]}:conflict",
92
+ "base" => "master",
93
+ "title" => 'Conflict'
94
+
95
+ prs = github.pull_requests.list(config[:login], "omg")
96
+ assert_equal 1, prs.count
97
+ pr = prs.first
98
+
99
+ runner = build_runner(pr)
100
+
101
+ runner.run
102
+
103
+ posts = github.issues.comments.list(config[:login], 'omg', pr.number)
104
+ assert_equal 2, posts.count
105
+ running = posts.first
106
+ conflict = posts.last
107
+
108
+ assert running['body'].match(/Running tests/)
109
+ assert conflict['body'].match(/conflict/)
110
+ end
111
+
112
+ protected
113
+
114
+ def build_runner(pull_request)
115
+ configuration = {"repo_owner"=>config[:login],
116
+ "repo"=>"omg",
117
+ "locale"=>"en",
118
+ "local_repo" => "#{stage_dir}/omg",
119
+ "database_yml" => "#{stage_dir}/database.yml",
120
+ "runner"=>"Ruby",
121
+ "github_credentials"=>{
122
+ "login"=>config[:login],
123
+ "password"=>config[:password]
124
+ },
125
+ "prowl"=>{
126
+ "application"=>"wherebot",
127
+ "keys"=>{
128
+ "kenmazaika"=>"omg",
129
+ "kenmazaika@gmail.com"=>"omg"
130
+ }
131
+ }
132
+ }
133
+
134
+ OmgPullRequest::CONFIGURATION.config = configuration
135
+ OmgPullRequest::TestRunner::Rails.new(
136
+ :configuration => OmgPullRequest::CONFIGURATION,
137
+ :pull_request => pull_request
138
+ )
139
+ end
140
+
141
+ def stage_dir
142
+ @stage_dir ||= File.expand_path("../.stage", __FILE__)
143
+ end
144
+
145
+ def github
146
+ @github ||= Github.new(config)
147
+ end
148
+
149
+ def config
150
+ @config ||= YAML.load(File.open("./test/integrations/config.yml"))
151
+ end
152
+
153
+ end
data/test/test_helper.rb CHANGED
@@ -51,3 +51,9 @@ def fakeweb_pull_requests
51
51
  "https://omg:pull_request@api.github.com/repos/kenmazaika/pictures/pulls",
52
52
  :response => File.expand_path('test/fixtures/pull_requests'))
53
53
  end
54
+
55
+ def fakeweb_make_gist
56
+ FakeWeb.register_uri(:post,
57
+ "https://omg:pull_request@api.github.com/gists",
58
+ :response => File.expand_path('test/fixtures/make_gist'))
59
+ end
@@ -33,6 +33,12 @@ module OmgPullRequest
33
33
  assert_equal "Omg", pr.title
34
34
  end
35
35
 
36
+ def test_make_gist
37
+ fakeweb_make_gist
38
+ expected_url = "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/file_name"
39
+ assert_equal expected_url, github_wrapper.make_gist("omg", "file_name")
40
+ end
41
+
36
42
  protected
37
43
 
38
44
  def github_wrapper
@@ -0,0 +1,30 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ module Storage
5
+ class AwsTest < MiniTest::Unit::TestCase
6
+ def test_store
7
+ FakeWeb.register_uri(:put, "http://s3.amazonaws.com/rofl/omg", :body => 'mmmkay')
8
+ storage.store("omg", "omg")
9
+ end
10
+
11
+ protected
12
+
13
+ def storage
14
+
15
+ config = Configuration.new
16
+ config.config = {
17
+ 'storage' => {
18
+ 'access_token' => 'omg',
19
+ 'secret_token' => 'lol',
20
+ 'bucket' => 'rofl'
21
+ }
22
+ }
23
+
24
+ @store ||= Aws.new(
25
+ :configuration => config
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ module Storage
5
+ class GistTest < MiniTest::Unit::TestCase
6
+ def test_store
7
+ fakeweb_make_gist
8
+ storage.store("omg", "file_name")
9
+ end
10
+
11
+ protected
12
+
13
+ def storage
14
+ @store ||= Gist.new(
15
+ :configuration => Configuration.new,
16
+ :github_wrapper => GITHUB_WRAPPER
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omg_pull_request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,11 +12,11 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-08-27 00:00:00.000000000Z
15
+ date: 2012-08-28 00:00:00.000000000Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: aws-s3
19
- requirement: &70268856902280 !ruby/object:Gem::Requirement
19
+ requirement: &70205087404820 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 0.6.3
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *70268856902280
27
+ version_requirements: *70205087404820
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: faraday
30
- requirement: &70268856901600 !ruby/object:Gem::Requirement
30
+ requirement: &70205087404320 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: 0.8.4
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *70268856901600
38
+ version_requirements: *70205087404320
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: github_api
41
- requirement: &70268856900880 !ruby/object:Gem::Requirement
41
+ requirement: &70205087403660 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: 0.6.5
47
47
  type: :runtime
48
48
  prerelease: false
49
- version_requirements: *70268856900880
49
+ version_requirements: *70205087403660
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: uuid
52
- requirement: &70268856899660 !ruby/object:Gem::Requirement
52
+ requirement: &70205087402840 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: 2.3.5
58
58
  type: :runtime
59
59
  prerelease: false
60
- version_requirements: *70268856899660
60
+ version_requirements: *70205087402840
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
- requirement: &70268856898380 !ruby/object:Gem::Requirement
63
+ requirement: &70205087401820 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: 0.9.2.2
69
69
  type: :runtime
70
70
  prerelease: false
71
- version_requirements: *70268856898380
71
+ version_requirements: *70205087401820
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: activesupport
74
- requirement: &70268856897400 !ruby/object:Gem::Requirement
74
+ requirement: &70205087400660 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: 3.2.8
80
80
  type: :runtime
81
81
  prerelease: false
82
- version_requirements: *70268856897400
82
+ version_requirements: *70205087400660
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: i18n
85
- requirement: &70268856887140 !ruby/object:Gem::Requirement
85
+ requirement: &70205087399660 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
@@ -90,7 +90,7 @@ dependencies:
90
90
  version: 0.6.0
91
91
  type: :runtime
92
92
  prerelease: false
93
- version_requirements: *70268856887140
93
+ version_requirements: *70205087399660
94
94
  description: Have tests run automatically for your Github Pull Request
95
95
  email:
96
96
  - kenmazaika@gmail.com
@@ -102,12 +102,11 @@ files:
102
102
  - .gitignore
103
103
  - Gemfile
104
104
  - Gemfile.lock
105
- - LICENSE
106
105
  - README.md
107
106
  - Rakefile
108
107
  - bin/omg_pull_request
108
+ - docs/configuration.md
109
109
  - lib/omg_pull_request.rb
110
- - lib/omg_pull_request/aws/store.rb
111
110
  - lib/omg_pull_request/configuration.rb
112
111
  - lib/omg_pull_request/context.rb
113
112
  - lib/omg_pull_request/git_client.rb
@@ -115,10 +114,13 @@ files:
115
114
  - lib/omg_pull_request/lolcommits.rb
116
115
  - lib/omg_pull_request/notifications.rb
117
116
  - lib/omg_pull_request/prowl.rb
117
+ - lib/omg_pull_request/storage/aws.rb
118
+ - lib/omg_pull_request/storage/gist.rb
118
119
  - lib/omg_pull_request/test_logger.rb
119
120
  - lib/omg_pull_request/test_runner.rb
120
121
  - lib/omg_pull_request/test_runner/base.rb
121
122
  - lib/omg_pull_request/test_runner/rails.rb
123
+ - lib/omg_pull_request/test_runner/rails_test_fast.rb
122
124
  - lib/omg_pull_request/test_runner/ruby.rb
123
125
  - lib/omg_pull_request/version.rb
124
126
  - locales/en.yml
@@ -129,16 +131,19 @@ files:
129
131
  - test/fixtures/create_comment
130
132
  - test/fixtures/github_commits
131
133
  - test/fixtures/kenmazaika
134
+ - test/fixtures/make_gist
132
135
  - test/fixtures/pull_requests
136
+ - test/integrations/runner_test.rb
133
137
  - test/mocks/git_client.rb
134
138
  - test/mocks/pull_request.rb
135
139
  - test/omg_pull_request/.gitkeep
136
140
  - test/test_helper.rb
137
- - test/units/omg_pull_request/aws/store_test.rb
138
141
  - test/units/omg_pull_request/github_wrapper_test.rb
139
142
  - test/units/omg_pull_request/lolcommits_test.rb
140
143
  - test/units/omg_pull_request/notifications_test.rb
141
144
  - test/units/omg_pull_request/prowl_test.rb
145
+ - test/units/omg_pull_request/storage/aws_test.rb
146
+ - test/units/omg_pull_request/storage/gist_test.rb
142
147
  - test/units/omg_pull_request/test_runner/base_test.rb
143
148
  homepage: http://github.com/where/omg_pull_request
144
149
  licenses: []
@@ -170,14 +175,17 @@ test_files:
170
175
  - test/fixtures/create_comment
171
176
  - test/fixtures/github_commits
172
177
  - test/fixtures/kenmazaika
178
+ - test/fixtures/make_gist
173
179
  - test/fixtures/pull_requests
180
+ - test/integrations/runner_test.rb
174
181
  - test/mocks/git_client.rb
175
182
  - test/mocks/pull_request.rb
176
183
  - test/omg_pull_request/.gitkeep
177
184
  - test/test_helper.rb
178
- - test/units/omg_pull_request/aws/store_test.rb
179
185
  - test/units/omg_pull_request/github_wrapper_test.rb
180
186
  - test/units/omg_pull_request/lolcommits_test.rb
181
187
  - test/units/omg_pull_request/notifications_test.rb
182
188
  - test/units/omg_pull_request/prowl_test.rb
189
+ - test/units/omg_pull_request/storage/aws_test.rb
190
+ - test/units/omg_pull_request/storage/gist_test.rb
183
191
  - test/units/omg_pull_request/test_runner/base_test.rb
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 Ken Mazaika
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,22 +0,0 @@
1
- require './test/test_helper.rb'
2
-
3
- module OmgPullRequest
4
- module Aws
5
- class StoreTest < MiniTest::Unit::TestCase
6
- def test_store
7
- FakeWeb.register_uri(:put, "http://s3.amazonaws.com/rofl/omg", :body => 'mmmkay')
8
- storage.store("omg", "omg")
9
- end
10
-
11
- protected
12
-
13
- def storage
14
- @store ||= Store.new(:storage_config => {
15
- :access_token => 'omg',
16
- :secret_token => 'lol',
17
- :bucket => 'rofl'
18
- })
19
- end
20
- end
21
- end
22
- end