slather 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 650160f33d5e86eca751efa9a24c33a532ee9b88651dd7e854537b8cd513badb
4
- data.tar.gz: cc54b5a1c8f6702bcc16e21cd4aa013d138d6c03df1f3d66993d5df7acf0dfd1
3
+ metadata.gz: eeaf99ed5212bdc90e8098dfde877452af7f074ecfd41fc577d46f90b1ee65eb
4
+ data.tar.gz: 5dbd0db5223f26990c2bfd3ab02f4ed36a15d8088a0b5c393f522a785a0176cd
5
5
  SHA512:
6
- metadata.gz: 29bc765b62d0bd6e61719d8f27c18d0ab4e071eeada2cfb784f3d7877d13ec1477579b0271c1042e34d02f3e68788cd6d057c55abb17082c6c82d63cba4008e3
7
- data.tar.gz: 92bad0129f231ebda10ab8ab87d6339bcde04655cdc8b2e9c4d7455277436d00d1739f465c211c408971a8e811d6534183f74a4b3255d910fb099073471ebea1
6
+ metadata.gz: 6802b4ef28cfb856bf68d214416d6a455de715723327dc7167600bc9cae705dacbdbffb0b8d154b2027dde6d5b2f6baec719f69a81e5293a437da1e260461e73
7
+ data.tar.gz: c6b95c762eaa1d5260da5de5910e7f429a79e45556a3b32568ba8c7c9f3ed173ed514330793c39babc767e4f021dda7fc83971750d16407d0149050286495b95
@@ -1,10 +1,10 @@
1
1
  language: objective-c
2
2
  script: bundle exec rake
3
- osx_image: xcode9.2
3
+ osx_image: xcode12.2
4
4
 
5
5
  before_install:
6
6
  - curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/share/cacert.pem
7
- - gem install bundler -v "~> 1.0" --no-ri --no-rdoc
7
+ - gem install bundler -v "~> 2.0" --no-document
8
8
 
9
9
  install:
10
10
  - bundle install --without=documentation
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v2.6.0
4
+
5
+ * Added GitHub actions support
6
+ [martin-key](https://github.com/martin-key), [troyfontaine](https://github.com/troyfontaine)
7
+ [#468](https://github.com/SlatherOrg/slather/pull/468)
8
+
3
9
  ## v2.5.0
4
10
 
5
11
  * Fixed activesupport and cocoapods dependencies
data/README.md CHANGED
@@ -149,7 +149,7 @@ ignore:
149
149
  - ProjectTestsGroup/*
150
150
  ```
151
151
 
152
- And then in your `.travis.yml` or `circle.yml`, call `slather` after a successful build:
152
+ And then in your `.travis.yml` or `circle.yml` or `github-action.yml`, call `slather` after a successful build:
153
153
 
154
154
  ```yml
155
155
  # .travis.yml
@@ -168,6 +168,25 @@ test:
168
168
 
169
169
  ```
170
170
 
171
+ ```yml
172
+ # github-action.yml
173
+ myjob:
174
+ steps:
175
+ - run: |
176
+ bundle config path vendor/bundle
177
+ bundle install --without=documentation --jobs 4 --retry 3
178
+ - name: Extract branch name
179
+ shell: bash
180
+ run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
181
+ id: get_branch
182
+ - run: bundle exec slather
183
+ env:
184
+ GIT_BRANCH: ${{ steps.get_branch.outputs.branch }}
185
+ CI_PULL_REQUEST: ${{ github.event.number }}
186
+ COVERAGE_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187
+
188
+ ```
189
+
171
190
  #### Usage with Travis CI Pro
172
191
 
173
192
  To use Coveralls with Travis CI Pro (for private repos), add following lines along with other settings to `.slather.yml`:
@@ -265,3 +284,4 @@ Please make sure to follow our general coding style and add test coverage for ne
265
284
  * [@jhersh](https://github.com/jhersh), CircleCI support.
266
285
  * [@tarbrain](https://github.com/tarbrain), Cobertura support and bugfixing.
267
286
  * [@ikhsan](https://github.com/ikhsan), html support.
287
+ * [@martin-key](https://github.com/martin-key) and [@troyfontaine](https://github.com/troyfontaine), Github Actions support.
@@ -8,6 +8,7 @@ class CoverageCommand < Clamp::Command
8
8
  option ["--jenkins"], :flag, "Indicate that the builds are running on Jenkins"
9
9
  option ["--buildkite"], :flag, "Indicate that the builds are running on Buildkite"
10
10
  option ["--teamcity"], :flag, "Indicate that the builds are running on TeamCity"
11
+ option ["--github"], :flag, "Indicate that the builds are running on Github Actions"
11
12
 
12
13
  option ["--coveralls", "-c"], :flag, "Post coverage results to coveralls"
13
14
  option ["--simple-output", "-s"], :flag, "Output coverage results to the terminal"
@@ -91,6 +92,8 @@ class CoverageCommand < Clamp::Command
91
92
  project.ci_service = :buildkite
92
93
  elsif teamcity?
93
94
  project.ci_service = :teamcity
95
+ elsif github?
96
+ project.ci_service = :github
94
97
  end
95
98
  end
96
99
 
@@ -43,18 +43,23 @@ module Slather
43
43
 
44
44
  def gcov_data
45
45
  @gcov_data ||= begin
46
- gcov_output = `gcov "#{source_file_pathname}" --object-directory "#{gcno_file_pathname.parent}" --branch-probabilities --branch-counts`
47
- # Sometimes gcov makes gcov files for Cocoa Touch classes, like NSRange. Ignore and delete later.
48
- gcov_files_created = gcov_output.scan(/creating '(.+\..+\.gcov)'/)
46
+ gcov_data = ""
47
+
48
+ Dir.chdir(project.project_dir) do
49
+ gcov_output = `gcov "#{source_file_pathname}" --object-directory "#{gcno_file_pathname.parent}" --branch-probabilities --branch-counts`
50
+ # Sometimes gcov makes gcov files for Cocoa Touch classes, like NSRange. Ignore and delete later.
51
+ gcov_files_created = gcov_output.scan(/creating '(.+\..+\.gcov)'/)
52
+
53
+ gcov_file_name = "./#{source_file_pathname.basename}.gcov"
54
+ if File.exists?(gcov_file_name)
55
+ gcov_data = File.new(gcov_file_name).read
56
+ else
57
+ gcov_data = ""
58
+ end
49
59
 
50
- gcov_file_name = "./#{source_file_pathname.basename}.gcov"
51
- if File.exists?(gcov_file_name)
52
- gcov_data = File.new(gcov_file_name).read
53
- else
54
- gcov_data = ""
60
+ gcov_files_created.each { |file| FileUtils.rm_f(file) }
55
61
  end
56
62
 
57
- gcov_files_created.each { |file| FileUtils.rm_f(file) }
58
63
  gcov_data
59
64
  end
60
65
  end
@@ -36,6 +36,21 @@ module Slather
36
36
  end
37
37
  private :jenkins_job_id
38
38
 
39
+ def github_job_id
40
+ ENV['GITHUB_RUN_ID']
41
+ end
42
+ private :github_job_id
43
+
44
+ def github_pull_request
45
+ ENV['CI_PULL_REQUEST'] || ""
46
+ end
47
+ private :github_pull_request
48
+
49
+ def github_repo_name
50
+ ENV['GITHUB_REPOSITORY'] || ""
51
+ end
52
+ private :github_repo_name
53
+
39
54
  def jenkins_branch_name
40
55
  branch_name = ENV['GIT_BRANCH'] || ENV['BRANCH_NAME']
41
56
  if branch_name.include? 'origin/'
@@ -51,6 +66,11 @@ module Slather
51
66
  end
52
67
  private :teamcity_branch_name
53
68
 
69
+ def github_branch_name
70
+ ENV['GIT_BRANCH'] || `git ls-remote --heads origin | grep $(git rev-parse HEAD) | cut -d / -f 3-`.chomp
71
+ end
72
+ private :github_branch_name
73
+
54
74
  def buildkite_job_id
55
75
  ENV['BUILDKITE_BUILD_NUMBER']
56
76
  end
@@ -119,6 +139,23 @@ module Slather
119
139
  "https://buildkite.com/" + ENV['BUILDKITE_PROJECT_SLUG'] + "/builds/" + ENV['BUILDKITE_BUILD_NUMBER'] + "#"
120
140
  end
121
141
 
142
+ def github_git_info
143
+ {
144
+ :head => {
145
+ :id => ENV['GITHUB_SHA'],
146
+ :author_name => ENV['GITHUB_ACTOR'],
147
+ :message => (`git log --format=%s -n 1 HEAD`.chomp || "")
148
+ },
149
+ :branch => github_branch_name
150
+ }
151
+ end
152
+ private :github_git_info
153
+
154
+ def github_build_url
155
+ "https://github.com/" + ENV['GITHUB_REPOSITORY'] + "/actions/runs/" + ENV['GITHUB_RUN_ID']
156
+ end
157
+ private :github_build_url
158
+
122
159
  def coveralls_coverage_data
123
160
  if ci_service == :travis_ci || ci_service == :travis_pro
124
161
  if travis_job_id
@@ -206,6 +243,26 @@ module Slather
206
243
  else
207
244
  raise StandardError, "Environment variable `TC_BUILD_NUMBER` not set. Is this running on a teamcity build?"
208
245
  end
246
+ elsif ci_service == :github
247
+
248
+ if coverage_access_token.to_s.strip.length == 0
249
+ raise StandardError, "Access token is not set. Uploading coverage data for private repositories requires an access token."
250
+ end
251
+
252
+ if github_job_id
253
+ {
254
+ :service_job_id => github_job_id,
255
+ :service_name => "github",
256
+ :repo_token => coverage_access_token,
257
+ :repo_name => github_repo_name,
258
+ :source_files => coverage_files.map(&:as_json),
259
+ :service_build_url => github_build_url,
260
+ :service_pull_request => github_pull_request,
261
+ :git => github_git_info
262
+ }.to_json
263
+ else
264
+ raise StandardError, "Environment variable `GITHUB_RUN_ID` not set. Is this running on github build?"
265
+ end
209
266
  else
210
267
  raise StandardError, "No support for ci named #{ci_service}"
211
268
  end
@@ -1,3 +1,3 @@
1
1
  module Slather
2
- VERSION = '2.5.0' unless defined?(Slather::VERSION)
2
+ VERSION = '2.6.0' unless defined?(Slather::VERSION)
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency 'bundler', '~> 1.17'
20
+ spec.add_development_dependency 'bundler', '~> 2.0'
21
21
  spec.add_development_dependency 'coveralls', '~> 0.8'
22
22
  spec.add_development_dependency 'simplecov', '~> 0'
23
23
  spec.add_development_dependency 'rake', '~> 12.3'
@@ -151,6 +151,26 @@ describe Slather::CoverageService::Coveralls do
151
151
  ENV['GIT_BRANCH'] = git_branch
152
152
  end
153
153
  end
154
+
155
+ context "coverage_service is :github" do
156
+ before(:each) { fixtures_project.ci_service = :github }
157
+
158
+ it "should return valid json for coveralls coverage data" do
159
+ allow(fixtures_project).to receive(:github_job_id).and_return("9182")
160
+ allow(fixtures_project).to receive(:coverage_access_token).and_return("abc123")
161
+ allow(fixtures_project).to receive(:github_pull_request).and_return("1")
162
+ allow(fixtures_project).to receive(:github_build_url).and_return("https://github.com/Bruce/Wayne/actions/runs/1")
163
+ allow(fixtures_project).to receive(:github_git_info).and_return({ :head => { :id => "ababa123", :author_name => "bwayne", :message => "hello" }, :branch => "master" })
164
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql("{\"service_job_id\":\"9182\",\"service_name\":\"github\",\"repo_name\":\"\",\"repo_token\":\"abc123\",\"service_pull_request\":\"1\",\"service_build_url\":\"https://github.com/Bruce/Wayne/actions/runs/1\",\"git\":{\"head\":{\"id\":\"ababa123\",\"author_name\":\"bwayne\",\"message\":\"hello\"},\"branch\":\"master\"}}").excluding("source_files")
165
+ expect(fixtures_project.send(:coveralls_coverage_data)).to be_json_eql(fixtures_project.coverage_files.map(&:as_json).to_json).at_path("source_files")
166
+ end
167
+
168
+ it "should raise an error if there is no GITHUB_RUN_ID" do
169
+ allow(fixtures_project).to receive(:github_job_id).and_return(nil)
170
+ expect { fixtures_project.send(:coveralls_coverage_data) }.to raise_error(StandardError)
171
+ end
172
+ end
173
+
154
174
  end
155
175
 
156
176
  describe '#coveralls_coverage_data' do
@@ -653,8 +653,8 @@ describe Slather::Project do
653
653
  it "should find relevant source files" do
654
654
  source_files = fixtures_project.find_source_files
655
655
  expect(source_files.count).to eq(2)
656
- expect(source_files.first.to_s).to include("fixtures.m")
657
- expect(source_files.last.to_s).to include("fixturesTwo.m")
656
+ expect(source_files.first.to_s).to include("fixturesTwo.m")
657
+ expect(source_files.last.to_s).to include("fixtures.m")
658
658
  end
659
659
 
660
660
  it "should print out the coverage for each file, and then total coverage" do
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: 2.5.0
4
+ version: 2.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: 2020-08-17 00:00:00.000000000 Z
11
+ date: 2020-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: coveralls
29
29
  requirement: !ruby/object:Gem::Requirement