cyclid 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cyclid/controllers/organizations.rb +1 -1
- data/app/cyclid/controllers/organizations/config.rb +23 -2
- data/app/cyclid/job/runner.rb +1 -1
- data/app/cyclid/log_buffer.rb +1 -1
- data/app/cyclid/plugins.rb +10 -0
- data/app/cyclid/plugins/action/email.rb +6 -1
- data/app/cyclid/plugins/action/slack.rb +5 -0
- data/app/cyclid/plugins/api.rb +42 -49
- data/app/cyclid/plugins/api/github.rb +28 -15
- data/app/cyclid/plugins/api/github/README.md +62 -0
- data/app/cyclid/plugins/api/github/callback.rb +19 -4
- data/app/cyclid/plugins/api/github/config.rb +45 -0
- data/app/cyclid/plugins/api/github/helpers.rb +139 -0
- data/app/cyclid/plugins/api/github/methods.rb +16 -138
- data/app/cyclid/plugins/api/github/oauth.rb +117 -0
- data/app/cyclid/plugins/api/github/pull_request.rb +134 -0
- data/app/cyclid/plugins/api/github/push.rb +121 -0
- data/app/cyclid/plugins/dispatcher/local.rb +3 -3
- data/app/cyclid/plugins/provisioner/debian.rb +15 -14
- data/app/cyclid/plugins/provisioner/ubuntu.rb +15 -14
- data/app/cyclid/plugins/source/git.rb +1 -1
- data/app/cyclid/plugins/transport/ssh.rb +3 -1
- data/app/cyclid/sinatra/api_helpers.rb +6 -0
- data/lib/cyclid/version.rb +1 -1
- metadata +22 -3
- data/app/cyclid/plugins/api/github/status.rb +0 -67
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright 2016 Liqwyd Ltd.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
|
16
|
-
require 'net/http'
|
17
|
-
|
18
|
-
# Top level module for the core Cyclid code.
|
19
|
-
module Cyclid
|
20
|
-
# Module for the Cyclid API
|
21
|
-
module API
|
22
|
-
# Module for Cyclid Plugins
|
23
|
-
module Plugins
|
24
|
-
# Container for the Sinatra related controllers modules
|
25
|
-
module ApiExtension
|
26
|
-
# Wrapper for a static method to push a status update to Github
|
27
|
-
module GithubStatus
|
28
|
-
# Call the Github statuses API to update the status
|
29
|
-
def self.set_status(statuses, auth_token, state, description)
|
30
|
-
# Update the PR status
|
31
|
-
|
32
|
-
statuses_url = URI(statuses)
|
33
|
-
status = { state: state,
|
34
|
-
target_url: 'http://cyclid.io',
|
35
|
-
description: description,
|
36
|
-
context: 'continuous-integration/cyclid' }
|
37
|
-
|
38
|
-
# Post the status to the statuses endpoint
|
39
|
-
request = Net::HTTP::Post.new(statuses_url)
|
40
|
-
request.content_type = 'application/json'
|
41
|
-
request.add_field 'Authorization', "token #{auth_token}" \
|
42
|
-
unless auth_token.nil?
|
43
|
-
request.body = status.to_json
|
44
|
-
|
45
|
-
http = Net::HTTP.new(statuses_url.hostname, statuses_url.port)
|
46
|
-
http.use_ssl = (statuses_url.scheme == 'https')
|
47
|
-
response = http.request(request)
|
48
|
-
|
49
|
-
case response
|
50
|
-
when Net::HTTPSuccess, Net::HTTPRedirection
|
51
|
-
Cyclid.logger.info "updated PR status to #{state}"
|
52
|
-
when Net::HTTPNotFound
|
53
|
-
Cyclid.logger.error 'update PR status failed; possibly an auth failure'
|
54
|
-
raise
|
55
|
-
else
|
56
|
-
Cyclid.logger.error "update PR status failed: #{response}"
|
57
|
-
raise
|
58
|
-
end
|
59
|
-
rescue StandardError => ex
|
60
|
-
Cyclid.logger.error "couldn't set status for PR: #{ex}"
|
61
|
-
raise
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|