codeclimate-services 1.10.1 → 1.11.2

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
- SHA1:
3
- metadata.gz: 28a587b7b4dfdf431800b17380549e44b0f9c500
4
- data.tar.gz: 65102446840ccaa599271b4875a9be8836c95934
2
+ SHA256:
3
+ metadata.gz: 96ac3fb2929dbad8aadc4a01e46ae15dfdbd0f624da568dd171349b664cb9da2
4
+ data.tar.gz: de09b581fb3a7ec8c7d597d65f06d832acc8f00ecbbde05cc2a4a340ea6e75b2
5
5
  SHA512:
6
- metadata.gz: 2a8d21f29a3a24b42f59c47f3edac13a1fdc25736249d58582b7dabf2d47484c36bed3c6d6b0166ecf5e1f26be3b7c763460d3ec1b132fbcd67669e7329afe1e
7
- data.tar.gz: e7e3e23b0698d345fb32cf4bd545ca8f8370ee6de25bd8b64c228e5947c0d024beeb90935bbdf31171aa7d30590a0c233c1f87bab935ae041051c1222baf4602
6
+ metadata.gz: 9e75e38ea1dbcda5c960c5310a98ab6cade92b8ec51a54a3a4dfb43249ef04f35d318f2733f51e80920d337ed36c77cfbae14ca60ac5efbcafae68da6e3f1df5
7
+ data.tar.gz: 5ef15601e7864fd5a4287ac48658bd9e2e60847939e19c1a16f9bacc4836ee1d5eec9363b9648708edffdfa0678f662747e0b80b70792321572c52d0f3cc99ca
@@ -0,0 +1,26 @@
1
+ version: 2.0
2
+ jobs:
3
+ test:
4
+ environment:
5
+ CC_TEST_REPORTER_ID: ad21bc049a323138b0a88086069115e9df6dba417912095b7bb17b7a65fc6182
6
+ docker:
7
+ - image: "circleci/ruby:2.7.5"
8
+ working_directory: ~/codeclimate/codeclimate-services
9
+ steps:
10
+ - checkout
11
+ - run:
12
+ name: Setup Coverage
13
+ command: |
14
+ (curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > cc-test-reporter && chmod +x ./cc-test-reporter) || echo "Couldn't download test reporter"
15
+ - run: bundle install && bundle exec rake
16
+ - persist_to_workspace:
17
+ root: .
18
+ paths:
19
+ - coverage
20
+ - run: ./cc-test-reporter after-build --exit-code $? || echo "Send coverage skipped..."
21
+
22
+ workflows:
23
+ version: 2
24
+ test:
25
+ jobs:
26
+ - test
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.2
1
+ 2.7.5
data/Gemfile CHANGED
@@ -7,5 +7,4 @@ gem "pry"
7
7
 
8
8
  group :test do
9
9
  gem "simplecov"
10
- gem "codeclimate-test-reporter", "~> 1.0.0"
11
10
  end
data/README.md CHANGED
@@ -131,6 +131,18 @@ and always return a hash of `{ ok: true|false, message: "String (HTML ok)" }`.
131
131
 
132
132
  When you open your PR, please include an image for your service.
133
133
 
134
+ ## Release
135
+
136
+ 1. Bump the version on `lib/cc/services/version`
137
+ 2. A gem owner developer should run the following: (check owners here https://rubygems.org/gems/codeclimate-services)
138
+ ```shell
139
+ bundle install
140
+ gem build codeclimate-services.gemspec
141
+ gem push codeclimate-services-<VERSION>.gem
142
+ git tag v<VERSION>
143
+ git push origin master --tags
144
+ ```
145
+
134
146
  ## License
135
147
 
136
148
  See LICENSE.txt. This incorporates code from bugsnag-notification-plugins and
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["bryan@brynary.com"]
11
11
  spec.summary = "Service classes for Code Climate"
12
12
  spec.description = "Service classes for Code Climate"
13
- spec.homepage = ""
13
+ spec.homepage = "https://codeclimate.com/"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -36,9 +36,11 @@ module CC
36
36
  def coverage_message
37
37
  message = "#{formatted_percent(@covered_percent)}%"
38
38
 
39
- if @covered_percent_delta > 0
39
+ return message if @covered_percent_delta.nil?
40
+
41
+ if @covered_percent_delta.round(2) > 0
40
42
  message += " (+#{formatted_percent(@covered_percent_delta)}%)"
41
- elsif @covered_percent_delta < 0
43
+ elsif @covered_percent_delta.round(2) < 0
42
44
  message += " (#{formatted_percent(@covered_percent_delta)}%)"
43
45
  end
44
46
 
@@ -19,7 +19,7 @@ class CC::Service::Formatter < SimpleDelegator
19
19
  end
20
20
 
21
21
  def message_prefix
22
- prefix = options.fetch(:prefix, "").to_s
22
+ prefix = (options[:prefix] || "").to_s
23
23
 
24
24
  if options[:prefix_with_repo]
25
25
  prefix << "[#{repo_name}]"
@@ -58,12 +58,12 @@ class CC::Service::GitlabMergeRequests < CC::PullRequests
58
58
 
59
59
  def setup_http
60
60
  http.headers["Content-Type"] = "application/json"
61
- http.headers["PRIVATE-TOKEN"] = config.access_token
61
+ http.headers["Private-Token"] = config.access_token
62
62
  http.headers["User-Agent"] = "Code Climate"
63
63
  end
64
64
 
65
65
  def base_status_url(commit_sha)
66
- "#{config.base_url}/api/v3/projects/#{CGI.escape(slug)}/statuses/#{commit_sha}"
66
+ "#{config.base_url}/api/v4/projects/#{CGI.escape(slug)}/statuses/#{commit_sha}"
67
67
  end
68
68
 
69
69
  def slug
@@ -3,7 +3,7 @@ require "base64"
3
3
  class CC::Service::Jira < CC::Service
4
4
  class Config < CC::Service::Config
5
5
  attribute :domain, Axiom::Types::String,
6
- description: "Your JIRA host domain (e.g. yourjira.com:PORT, please exclude https://)"
6
+ description: "Your JIRA host domain (e.g. yourjira.com[:PORT], please exclude https:// and only add PORT if you are using a different port number to access your own server that is not the default)"
7
7
 
8
8
  attribute :username, Axiom::Types::String,
9
9
  description: "Must exactly match the 'username' that appears on your JIRA profile page."
@@ -1,5 +1,5 @@
1
1
  module CC
2
2
  module Services
3
- VERSION = "1.10.1".freeze
3
+ VERSION = "1.11.2".freeze
4
4
  end
5
5
  end
@@ -30,12 +30,20 @@ describe CC::Service::PullRequestsPresenter, type: :service do
30
30
  expect("85%").to eq(build_presenter({}, "covered_percent" => 85, "covered_percent_delta" => 0).coverage_message)
31
31
  end
32
32
 
33
+ it "message coverage without delta" do
34
+ expect("85%").to eq(build_presenter({}, "covered_percent" => 85, "covered_percent_delta" => nil).coverage_message)
35
+ end
36
+
37
+ it "message coverage the same when rounded" do
38
+ expect("85%").to eq(build_presenter({}, "covered_percent" => 85, "covered_percent_delta" => 0.0005).coverage_message)
39
+ end
40
+
33
41
  it "message coverage up" do
34
42
  expect("85.5% (+2.46%)").to eq(build_presenter({}, "covered_percent" => 85.5, "covered_percent_delta" => 2.4567).coverage_message)
35
43
  end
36
44
 
37
45
  it "message coverage down" do
38
- expect("85.35% (-3%)").to eq( build_presenter({}, "covered_percent" => 85.348, "covered_percent_delta" => -3.0).coverage_message)
46
+ expect("85.35% (-3%)").to eq(build_presenter({}, "covered_percent" => 85.348, "covered_percent_delta" => -3.0).coverage_message)
39
47
  end
40
48
 
41
49
  it "message approved" do
@@ -0,0 +1,21 @@
1
+ describe CC::Service::Formatter do
2
+
3
+ class TestFormatter < described_class
4
+ def format_test
5
+ message = message_prefix
6
+ message << "This is a test"
7
+ end
8
+ end
9
+
10
+ FakeService = Struct.new(:receive)
11
+
12
+ it "supports passing nil as prefix" do
13
+ formatter = TestFormatter.new(
14
+ FakeService.new(:some_result),
15
+ prefix: nil,
16
+ prefix_with_repo: false,
17
+ )
18
+
19
+ expect(formatter.format_test).to eq("This is a test")
20
+ end
21
+ end
@@ -116,13 +116,13 @@ describe CC::Service::GitlabMergeRequests, type: :service do
116
116
  end
117
117
 
118
118
  it "merge request status test success" do
119
- http_stubs.post("api/v3/projects/hal%2Fhal9000/statuses/#{"0" * 40}") { |_env| [404, {}, ""] }
119
+ http_stubs.post("api/v4/projects/hal%2Fhal9000/statuses/#{"0" * 40}") { |_env| [404, {}, ""] }
120
120
 
121
121
  expect(receive_test({}, git_url: "ssh://git@gitlab.com/hal/hal9000.git")[:ok]).to eq(true)
122
122
  end
123
123
 
124
124
  it "merge request status test failure" do
125
- http_stubs.post("api/v3/projects/hal%2Fhal9000/statuses/#{"0" * 40}") { |_env| [401, {}, ""] }
125
+ http_stubs.post("api/v4/projects/hal%2Fhal9000/statuses/#{"0" * 40}") { |_env| [401, {}, ""] }
126
126
 
127
127
  expect { receive_test({}, git_url: "ssh://git@gitlab.com/hal/hal9000.git") }.to raise_error(CC::Service::HTTPError)
128
128
  end
@@ -134,8 +134,8 @@ describe CC::Service::GitlabMergeRequests, type: :service do
134
134
  end
135
135
 
136
136
  it "different base url" do
137
- http_stubs.post("api/v3/projects/hal%2Fhal9000/statuses/#{"0" * 40}") do |env|
138
- expect(env[:url].to_s).to eq("https://gitlab.hal.org/api/v3/projects/hal%2Fhal9000/statuses/#{"0" * 40}")
137
+ http_stubs.post("api/v4/projects/hal%2Fhal9000/statuses/#{"0" * 40}") do |env|
138
+ expect(env[:url].to_s).to eq("https://gitlab.hal.org/api/v4/projects/hal%2Fhal9000/statuses/#{"0" * 40}")
139
139
  [404, {}, ""]
140
140
  end
141
141
 
@@ -145,8 +145,8 @@ describe CC::Service::GitlabMergeRequests, type: :service do
145
145
  private
146
146
 
147
147
  def expect_status_update(repo, commit_sha, params)
148
- http_stubs.post "api/v3/projects/#{CGI.escape(repo)}/statuses/#{commit_sha}" do |env|
149
- expect(env[:request_headers]["PRIVATE-TOKEN"]).to eq("123")
148
+ http_stubs.post "api/v4/projects/#{CGI.escape(repo)}/statuses/#{commit_sha}" do |env|
149
+ expect(env[:request_headers]["Private-Token"]).to eq("123")
150
150
 
151
151
  body = JSON.parse(env[:body])
152
152
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate-services
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-03 00:00:00.000000000 Z
11
+ date: 2022-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -129,6 +129,7 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".circleci/config.yml"
132
133
  - ".codeclimate.yml"
133
134
  - ".gitignore"
134
135
  - ".rspec"
@@ -144,7 +145,6 @@ files:
144
145
  - bin/nokogiri
145
146
  - bin/pry
146
147
  - bin/rake
147
- - circle.yml
148
148
  - codeclimate-services.gemspec
149
149
  - config/cacert.pem
150
150
  - config/load.rb
@@ -198,6 +198,7 @@ files:
198
198
  - spec/cc/service/asana_spec.rb
199
199
  - spec/cc/service/campfire_spec.rb
200
200
  - spec/cc/service/flowdock_spec.rb
201
+ - spec/cc/service/formatter_spec.rb
201
202
  - spec/cc/service/github_issues_spec.rb
202
203
  - spec/cc/service/github_pull_requests_spec.rb
203
204
  - spec/cc/service/gitlab_merge_requests_spec.rb
@@ -218,7 +219,7 @@ files:
218
219
  - spec/support/fake_logger.rb
219
220
  - spec/support/resolv_helpers.rb
220
221
  - spec/support/service_context.rb
221
- homepage: ''
222
+ homepage: https://codeclimate.com/
222
223
  licenses:
223
224
  - MIT
224
225
  metadata: {}
@@ -237,8 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
238
  - !ruby/object:Gem::Version
238
239
  version: '0'
239
240
  requirements: []
240
- rubyforge_project:
241
- rubygems_version: 2.4.5
241
+ rubygems_version: 3.3.7
242
242
  signing_key:
243
243
  specification_version: 4
244
244
  summary: Service classes for Code Climate
@@ -251,6 +251,7 @@ test_files:
251
251
  - spec/cc/service/asana_spec.rb
252
252
  - spec/cc/service/campfire_spec.rb
253
253
  - spec/cc/service/flowdock_spec.rb
254
+ - spec/cc/service/formatter_spec.rb
254
255
  - spec/cc/service/github_issues_spec.rb
255
256
  - spec/cc/service/github_pull_requests_spec.rb
256
257
  - spec/cc/service/gitlab_merge_requests_spec.rb
data/circle.yml DELETED
@@ -1,3 +0,0 @@
1
- test:
2
- override:
3
- - bundle exec rake && bundle exec codeclimate-test-reporter