codeclimate-services 1.11.3 → 1.11.4

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: 9857632046cf9409d85f8ff2429efabf13c6eb5ab1300023d52407dc381deac0
4
- data.tar.gz: 65fd4acdcc300cf00472ac8c8df740d0ec75dd382014a8963117680393629578
3
+ metadata.gz: e49ecbb12d3d95c5fcf279a4d5a66042fff2349a034f864ca361c7b575e498b4
4
+ data.tar.gz: 1564c19d8878e7982e9a18fb66cc4ae954ec26a7cabaebf4e0e4f0f919316b49
5
5
  SHA512:
6
- metadata.gz: 51e15698f1fbe51598067be6452db4b19ff6c4f913392ef172a772d58cb2c548805f569d34f11c74cb9ab486937cc75395104ffc082966b3a2edd7ee5866d832
7
- data.tar.gz: 758fea2bc59978563b7a133affb1c8fd1d63d94250e88bbcabcd1d945a406c76845065abe7f249bd4ba33c4249b6620dd129d7ccfb8288a00297aa2309426b0a
6
+ metadata.gz: 2e6a1864050ea867c58dfc8432f44a853f9563cba2bbf3a2bd9d33fee0bffcbf823115cd11811fc268bfec2049e3e002e594e916455a3a4a1839a2e52d4e34e7
7
+ data.tar.gz: c266bbdd933ed408284569eef1f628353dfc38f07b0d585bd85b3704396a924f0f1e01ab9018e4aee59d45afc8ec2a39cb6bd3e1ab45713eef5985f80f205153
data/.circleci/config.yml CHANGED
@@ -1,4 +1,10 @@
1
1
  version: 2.0
2
+ init: &init
3
+ run:
4
+ name: init
5
+ command: |
6
+ echo '. .circleci/shared.bash' >> "$BASH_ENV"
7
+
2
8
  jobs:
3
9
  test:
4
10
  environment:
@@ -19,8 +25,33 @@ jobs:
19
25
  - coverage
20
26
  - run: ./cc-test-reporter after-build --exit-code $? || echo "Send coverage skipped..."
21
27
 
28
+ publish:
29
+ machine: true
30
+ steps:
31
+ - checkout
32
+ - *init
33
+ - run:
34
+ name: Install Hub dependency
35
+ command: install_hub
36
+ - run:
37
+ name: Login on RubyGems
38
+ command: login_to_rubygems
39
+ - run:
40
+ name: Publish new version
41
+ command: |
42
+ if [ `git diff --quiet HEAD~ VERSION; echo $?` -eq 1 ]; then
43
+ publish_new_version
44
+ fi
45
+
22
46
  workflows:
23
47
  version: 2
24
48
  test:
25
49
  jobs:
26
50
  - test
51
+ - publish:
52
+ requires:
53
+ - test
54
+ filters:
55
+ branches:
56
+ only:
57
+ - master
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+
3
+ set -exuo pipefail
4
+
5
+ VERSION=$(cat VERSION)
6
+
7
+ function install_hub() {
8
+ sudo apt update && sudo apt install -y git wget
9
+ url="$(wget -qO- https://api.github.com/repos/github/hub/releases/latest | tr '"' '\n' | grep '.*/download/.*/hub-linux-amd64-.*.tgz')"
10
+ wget -qO- "$url" | sudo tar -xzvf- -C /usr/bin --strip-components=2 --wildcards "*/bin/hub"
11
+ }
12
+
13
+ function login_to_rubygems() {
14
+ mkdir -p "$HOME/.gem"
15
+ touch "$HOME/.gem/credentials"
16
+ chmod 0600 "$HOME/.gem/credentials"
17
+ printf -- "---\n:rubygems_api_key: %s\n" "$GEM_HOST_API_KEY" > "$HOME/.gem/credentials"
18
+ }
19
+
20
+ function tag_version() {
21
+ GITHUB_TOKEN="${GITHUB_TOKEN}" hub release create -m "v${VERSION}" "v${VERSION}"
22
+ }
23
+
24
+
25
+ function publish_new_version() {
26
+ set +x
27
+ # Build and push gem
28
+ gem build ./*.gemspec
29
+ gem push ./*.gem
30
+
31
+ # Create gh tag
32
+ tag_version
33
+
34
+ set -x
35
+ }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.11.4
@@ -5,7 +5,7 @@ require "cc/services/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "codeclimate-services"
8
- spec.version = CC::Services::VERSION
8
+ spec.version = CC::Services.version
9
9
  spec.authors = ["Bryan Helmkamp"]
10
10
  spec.email = ["bryan@brynary.com"]
11
11
  spec.summary = "Service classes for Code Climate"
@@ -14,7 +14,11 @@ class CC::PullRequests < CC::Service
14
14
  end
15
15
 
16
16
  def receive_pull_request_diff_coverage
17
- receive_request("skipped", :update_diff_coverage_status)
17
+ receive_request(%w[pending skipped], :update_diff_coverage_status)
18
+ end
19
+
20
+ def receive_pull_request_total_coverage
21
+ receive_request(%w[pending skipped], :update_total_coverage_status)
18
22
  end
19
23
 
20
24
  private
@@ -47,6 +51,18 @@ class CC::PullRequests < CC::Service
47
51
  raise NotImplementedError
48
52
  end
49
53
 
54
+ def update_diff_coverage_status_pending
55
+ raise NotImplementedError
56
+ end
57
+
58
+ def update_total_coverage_status_skipped
59
+ raise NotImplementedError
60
+ end
61
+
62
+ def update_total_coverage_status_pending
63
+ raise NotImplementedError
64
+ end
65
+
50
66
  def update_status_failure
51
67
  raise NotImplementedError
52
68
  end
data/lib/cc/service.rb CHANGED
@@ -37,6 +37,7 @@ module CC
37
37
  pull_request
38
38
  pull_request_coverage
39
39
  pull_request_diff_coverage
40
+ pull_request_total_coverage
40
41
  quality
41
42
  snapshot
42
43
  test
@@ -73,9 +73,29 @@ class CC::Service::GitHubPullRequests < CC::PullRequests
73
73
 
74
74
  def update_diff_coverage_status_skipped
75
75
  update_status("success", presenter.skipped_message, "#{config.context}/diff-coverage")
76
+
77
+ end
78
+
79
+ def update_total_coverage_status_skipped
76
80
  update_status("success", presenter.skipped_message, "#{config.context}/total-coverage")
77
81
  end
78
82
 
83
+ def update_diff_coverage_status_pending
84
+ update_status(
85
+ "pending",
86
+ @payload["message"] || presenter.pending_message,
87
+ "#{config.context}/diff-coverage"
88
+ )
89
+ end
90
+
91
+ def update_total_coverage_status_pending
92
+ update_status(
93
+ "pending",
94
+ @payload["message"] || presenter.pending_message,
95
+ "#{config.context}/total-coverage"
96
+ )
97
+ end
98
+
79
99
  def update_status_failure
80
100
  update_status("failure", presenter.success_message)
81
101
  end
@@ -1,5 +1,9 @@
1
1
  module CC
2
2
  module Services
3
- VERSION = "1.11.3".freeze
3
+ def version
4
+ path = File.expand_path("../../../../VERSION", __FILE__)
5
+ @version ||= File.read(path).strip
6
+ end
7
+ module_function :version
4
8
  end
5
9
  end
@@ -120,4 +120,12 @@ describe CC::PullRequests do
120
120
 
121
121
  it_behaves_like "receive method"
122
122
  end
123
+
124
+ describe "#receive_pull_request_total_coverage" do
125
+ let(:payload_status) { "skipped" }
126
+ let(:expected_method_name) { :update_total_coverage_status_skipped }
127
+ let(:method_to_call) { :receive_pull_request_total_coverage }
128
+
129
+ it_behaves_like "receive method"
130
+ end
123
131
  end
@@ -85,8 +85,6 @@ describe CC::Service::GitHubPullRequests, type: :service do
85
85
  it "pull request diff coverage skipped" do
86
86
  expect_status_update("pbrisbin/foo", "abc123", "state" => "success",
87
87
  "description" => /skipped analysis/, "context" => /diff-coverage/)
88
- expect_status_update("pbrisbin/foo", "abc123", "state" => "success",
89
- "description" => /skipped analysis/, "context" => /total-coverage/)
90
88
 
91
89
  receive_pull_request_diff_coverage({},
92
90
  github_slug: "pbrisbin/foo",
@@ -94,6 +92,38 @@ describe CC::Service::GitHubPullRequests, type: :service do
94
92
  state: "skipped")
95
93
  end
96
94
 
95
+ it "pull request total coverage skipped" do
96
+ expect_status_update("pbrisbin/foo", "abc123", "state" => "success",
97
+ "description" => /skipped analysis/, "context" => /total-coverage/)
98
+
99
+ receive_pull_request_total_coverage({},
100
+ github_slug: "pbrisbin/foo",
101
+ commit_sha: "abc123",
102
+ state: "skipped")
103
+ end
104
+
105
+ it "pull request diff coverage pending" do
106
+ expect_status_update("pbrisbin/foo", "abc123", "state" => "pending",
107
+ "description" => /a test message/, "context" => /diff-coverage/)
108
+
109
+ receive_pull_request_diff_coverage({},
110
+ github_slug: "pbrisbin/foo",
111
+ commit_sha: "abc123",
112
+ state: "pending",
113
+ message: "a test message")
114
+ end
115
+
116
+ it "pull request total coverage skipped" do
117
+ expect_status_update("pbrisbin/foo", "abc123", "state" => "pending",
118
+ "description" => /a test message/, "context" => /total-coverage/)
119
+
120
+ receive_pull_request_total_coverage({},
121
+ github_slug: "pbrisbin/foo",
122
+ commit_sha: "abc123",
123
+ state: "pending",
124
+ message: "a test message")
125
+ end
126
+
97
127
  it "pull request status test success" do
98
128
  http_stubs.post("/repos/pbrisbin/foo/statuses/#{"0" * 40}") { |_env| [422, {}, ""] }
99
129
 
@@ -233,6 +263,14 @@ describe CC::Service::GitHubPullRequests, type: :service do
233
263
  )
234
264
  end
235
265
 
266
+ def receive_pull_request_total_coverage(config, event_data)
267
+ service_receive(
268
+ CC::Service::GitHubPullRequests,
269
+ { oauth_token: "123" }.merge(config),
270
+ { name: "pull_request_total_coverage" }.merge(event_data),
271
+ )
272
+ end
273
+
236
274
  def receive_test(config, event_data = {})
237
275
  service_receive(
238
276
  CC::Service::GitHubPullRequests,
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.11.3
4
+ version: 1.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-30 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -130,6 +130,7 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".circleci/config.yml"
133
+ - ".circleci/shared.bash"
133
134
  - ".codeclimate.yml"
134
135
  - ".gitignore"
135
136
  - ".rspec"
@@ -139,6 +140,7 @@ files:
139
140
  - LICENSE.txt
140
141
  - README.md
141
142
  - Rakefile
143
+ - VERSION
142
144
  - base_rubocop.yml
143
145
  - bin/bundler
144
146
  - bin/coderay