slather 1.5.5 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2701d4033f375990f4d6eb90a473f3f1fabea04e
4
- data.tar.gz: 6b1317d447b3b63b2ad0232ed153810f9bed870e
3
+ metadata.gz: caeff7a74b6123adedb9180290935d8167a1a86e
4
+ data.tar.gz: aeccfc1fea76689b142d40649cd5afc28acdef86
5
5
  SHA512:
6
- metadata.gz: 372f7891468ece01c6f1531d96f75580d1e5674e3efeddc7f4015fec5d4f306efb26d048ce438e3547e32f65895d380a2c4ab41d4664c7bc204323c6529ef8e6
7
- data.tar.gz: 42b15f0ad5f3bcd3ae2fbea1caa49527afedd247fa70660783f6323568f12de61170648b96375dd7bd180aff29344058f24b085b9b49cad85e9e3a9f437b20f6
6
+ metadata.gz: 56d7b2b8bd006e5177094a531944c977d0479c53c63f295b7317526901675483d1d45b776e5f06d9f63f11be79160f7808f6c18d6951a04ed473270fedfa096a
7
+ data.tar.gz: ecd84dbaa23314124826e78d24446e78d38649cf1bef11101b213f2787ab4a5bc3c546f9cfa412ed3144870fdf9f4dd1ba5d1e30f985d7bd9315b4f80c50a012
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## v1.6.0
6
+ * Add CircleCI support
7
+ [Jonathan Hersh](https://github.com/jhersh)
8
+ [#55](https://github.com/venmo/slather/pull/55)
9
+
5
10
  ## v1.5.4
6
11
 
7
12
  * Fix calculation of branch coverage when a class has no branches
data/README.md CHANGED
@@ -112,9 +112,15 @@ $ slather coverage -x --output-directory path/to/xml_report
112
112
 
113
113
  ### Coverage for code included via CocoaPods
114
114
 
115
- If youre trying to compute the coverage of code that has been included via
116
- CocoaPods, you will need to tell slather where to find the source files for
117
- your Pod.
115
+ If you're trying to compute the coverage of code that has been included via
116
+ CocoaPods, you will need to tell CocoaPods to use the slather plugin by
117
+ adding the following to your `Podfile`.
118
+
119
+ ```ruby
120
+ plugin 'slather'
121
+ ```
122
+
123
+ You will also need to tell slather where to find the source files for your Pod.
118
124
 
119
125
  ```yml
120
126
  # .slather.yml
data/bin/slather CHANGED
@@ -12,6 +12,7 @@ Clamp do
12
12
  parameter "[xcodeproj]", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
13
13
 
14
14
  option ["--travis", "-t"], :flag, "Indicate that the builds are running on Travis CI"
15
+ option ["--circleci"], :flag, "Indicate that the builds are running on CircleCI"
15
16
 
16
17
  option ["--coveralls", "-c"], :flag, "Post coverage results to coveralls"
17
18
  option ["--simple-output", "-s"], :flag, "Output coverage results to the terminal"
@@ -57,6 +58,8 @@ Clamp do
57
58
  def setup_service_name
58
59
  if travis?
59
60
  project.ci_service = :travis_ci
61
+ elsif circleci?
62
+ project.ci_service = :circleci
60
63
  end
61
64
  end
62
65
 
@@ -1,6 +1,6 @@
1
1
  require 'slather'
2
2
 
3
- Pod::HooksManager.register(:post_install) do |installer_context|
3
+ Pod::HooksManager.register('slather', :post_install) do |installer_context|
4
4
  sandbox_root = installer_context.sandbox_root
5
5
  sandbox = Pod::Sandbox.new(sandbox_root)
6
6
  project = Xcodeproj::Project.open(sandbox.project_path)
@@ -11,6 +11,28 @@ module Slather
11
11
  ENV['TRAVIS_JOB_ID']
12
12
  end
13
13
  private :travis_job_id
14
+
15
+ def circleci_job_id
16
+ ENV['CIRCLE_BUILD_NUM']
17
+ end
18
+ private :circleci_job_id
19
+
20
+ def circleci_pull_request
21
+ ENV['CI_PULL_REQUEST']
22
+ end
23
+ private :circleci_pull_request
24
+
25
+ def circleci_git_info
26
+ {
27
+ :head => {
28
+ :id => (ENV['CIRCLE_SHA1'] || ""),
29
+ :author_name => (ENV['CIRCLE_USERNAME'] || ""),
30
+ :message => (`git log --format=%B -n 1 HEAD`.chomp || "")
31
+ },
32
+ :branch => (ENV['CIRCLE_BRANCH'] || "")
33
+ }
34
+ end
35
+ private :circleci_git_info
14
36
 
15
37
  def coveralls_coverage_data
16
38
  if ci_service == :travis_ci || ci_service == :travis_pro
@@ -32,6 +54,24 @@ module Slather
32
54
  else
33
55
  raise StandardError, "Environment variable `TRAVIS_JOB_ID` not set. Is this running on a travis build?"
34
56
  end
57
+ elsif ci_service == :circleci
58
+ if circleci_job_id
59
+ coveralls_hash = {
60
+ :service_job_id => circleci_job_id,
61
+ :service_name => "circleci",
62
+ :repo_token => ci_access_token,
63
+ :source_files => coverage_files.map(&:as_json),
64
+ :git => circleci_git_info
65
+ }
66
+
67
+ if circleci_pull_request != nil && circleci_pull_request.length > 0
68
+ coveralls_hash[:service_pull_request] = circleci_pull_request.split("/").last
69
+ end
70
+
71
+ coveralls_hash.to_json
72
+ else
73
+ raise StandardError, "Environment variable `CIRCLE_BUILD_NUM` not set. Is this running on a circleci build?"
74
+ end
35
75
  else
36
76
  raise StandardError, "No support for ci named #{ci_service}"
37
77
  end
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = "1.5.5"
2
+ VERSION = "1.6.0"
3
3
  end
data/slather.gemspec CHANGED
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.3"
23
23
  spec.add_development_dependency "rspec", "~> 2.14"
24
24
  spec.add_development_dependency "pry", "~> 0.9"
25
- spec.add_development_dependency "cocoapods", "~> 0.34"
25
+ spec.add_development_dependency "cocoapods", "~> 0.36.0"
26
26
  spec.add_development_dependency "json_spec", "~> 1.1.4"
27
27
 
28
28
  spec.add_dependency "clamp", "~> 0.6"
29
- spec.add_dependency "xcodeproj", "~> 0.20.0"
29
+ spec.add_dependency "xcodeproj", "~> 0.23.0"
30
30
  spec.add_dependency "nokogiri", "~> 1.6.3"
31
31
  end
@@ -14,7 +14,7 @@ describe Slather do
14
14
  sandbox_root = 'Pods'
15
15
  sandbox = Pod::Sandbox.new(sandbox_root)
16
16
  context = Pod::Installer::HooksContext.generate(sandbox, [])
17
- Pod::HooksManager.run(:post_install, context)
17
+ Pod::HooksManager.run(:post_install, context, {'slather' => nil})
18
18
  end
19
19
  end
20
20
  end
@@ -54,6 +54,24 @@ describe Slather::CoverageService::Coveralls do
54
54
  expect { fixtures_project.send(:coveralls_coverage_data) }.to raise_error(StandardError)
55
55
  end
56
56
  end
57
+
58
+ context "coverage_service is :circleci" do
59
+ before(:each) { fixtures_project.ci_service = :circleci }
60
+
61
+ it "should return valid json for coveralls coverage data" do
62
+ fixtures_project.stub(:circleci_job_id).and_return("9182")
63
+ fixtures_project.stub(:ci_access_token).and_return("abc123")
64
+ fixtures_project.stub(:circleci_pull_request).and_return("1")
65
+ fixtures_project.stub(:circleci_git_info).and_return({ :head => { :id => "ababa123", :author_name => "bwayne", :message => "hello" }, :branch => "master" })
66
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql("{\"service_job_id\":\"9182\",\"service_name\":\"circleci\",\"repo_token\":\"abc123\",\"service_pull_request\":\"1\",\"git\":{\"head\":{\"id\":\"ababa123\",\"author_name\":\"bwayne\",\"message\":\"hello\"},\"branch\":\"master\"}}").excluding("source_files")
67
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql(fixtures_project.send(:coverage_files).map(&:as_json).to_json).at_path("source_files")
68
+ end
69
+
70
+ it "should raise an error if there is no CIRCLE_BUILD_NUM" do
71
+ fixtures_project.stub(:circleci_job_id).and_return(nil)
72
+ expect { fixtures_project.send(:coveralls_coverage_data) }.to raise_error(StandardError)
73
+ end
74
+ end
57
75
 
58
76
  it "should raise an error if it does not recognize the ci_service" do
59
77
  fixtures_project.ci_service = :jenkins_ci
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slather
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.34'
89
+ version: 0.36.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.34'
96
+ version: 0.36.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: json_spec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.20.0
131
+ version: 0.23.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.20.0
138
+ version: 0.23.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: nokogiri
141
141
  requirement: !ruby/object:Gem::Requirement