Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into onering/22650
Browse files Browse the repository at this point in the history
  • Loading branch information
ibmdevops committed May 19, 2015
2 parents 9f4d938 + 447a100 commit c3732fa
Show file tree
Hide file tree
Showing 25 changed files with 240 additions and 147 deletions.
121 changes: 18 additions & 103 deletions CONTRIBUTING.md
@@ -1,113 +1,28 @@
# Contributing

GitHub will accept service hooks for the following types of services:
**NOTE**: GitHub no longer accepts new services that are based on HTTP. If you'd like to integrate
your application or service with GitHub, you should use [webhooks][webhooks] which will `POST` a
payload to your server for each event.

* Production web applications
* Popular internet protocols (Email, IRC, etc).
## Creating a new service

In order to provide quality service and support for our users, we require the
following:
GitHub will only accept new services that add functionality for a non-HTTP based endpoint (e.g.,
XMPP MUC, IRC, or email services).

* Implement endpoints that take [the new payload](https://github.com/github/github-services/blob/56baa4ce03e64ebf67105ee22f752bf7c2383274/lib/services/http_post.rb#L13-L16), completely unmodified.
* Good example: [Simperium](https://github.com/github/github-services/blob/master/lib/services/simperium.rb)
has minimal logic (just config parameters, an HTTP header, and a custom url).
* Bad Example: [Campfire](https://github.com/github/github-services/blob/master/lib/services/campfire.rb)
modifies the payload to make multiple calls to the Campfire service.
* Thorough documentation about what the hook does, and what the options do.
* Tested code that works. If we have to make changes to the Services infrastructure,
it helps a lot to have passing tests so we know we're not breaking things.
If you'd like to create a new service, please open an issue describing your proposed service. We
will review your proposal and let you know if it meets requirements described above.

Any new hooks that don't meet the above criteria will be rejected.
## Updating an existing service

We'd also like the following information to help provide quality service and
support to our users:
GitHub will only accept pull requests to existing services that implement bug fixes or security
improvements. We no longer accept substantial feature changes to existing services.

* A URL for the service (if applicable).
* A URL to a logo for the service (png or gif preferred).
* A maintainer. Someone that GitHub can contact in the event of bugs. We prefer
GitHub users, so that we can file issues directly to the github/github-services
Repository.
* A support contact for our users that have problems. This can be a GitHub user,
an email address, or link to a contact form.
We strongly encourage existing services to move to an [OAuth based webhook integration][webhooks]
if possible. You will better be able to control the complete integration including installation
and updates.

If we need support from any hooks without this data, we will look for the most
active contributor to the hook file itself.
All pull requests will be reviewed by multiple GitHub staff members before being merged.
To allow ample time for review, there may be a substantial delay between the pull request being created and the pull requested
being merged by GitHub's staff.

You can annotate this directly in the hook like so:

```ruby
class Service::MyService < Service::HttpPost
string :project
password :api_token

# only include 'project' in the debug logs, skip the api token.
white_list :project

default_events :push, :issues, :pull_request

url "http://myservice.com"
logo_url "http://myservice.com/logo.png"

# Technoweenie on GitHub is pinged for any bugs with the Hook code.
maintained_by :github => 'technoweenie'

# Support channels for user-level Hook problems (service failure,
# misconfigured
supported_by :web => 'http://my-service.com/support',
:email => 'support@my-service.com'
end
```

You can annotate Supporters and Maintainers by the following methods:

* `:github` - a GitHub login.
* `:web` - A URL to a contact form.
* `:email` - An email address.
* `:twitter` - A Twitter handle.

How to test your service
------------------------

You can test your service in a ruby irb console:

0. Cache gems and install them to `vendor/gems` by doing:
`script/bootstrap`
1. Start a console: `script/console`
2. Instantiate your Service:

```ruby
svc = Service::MyService.new(:push,
# Hash of configuration information.
{'token' => 'abc'},
# Hash of payload.
{'blah' => 'payload!'})

svc.receive_event
```

3. The third argument is optional if you just want to use the sample
payload.

```ruby
svc = Service::MyService.new(:push,
# Hash of configuration information.
{'token' => 'abc'})

svc.receive_event
```

Other hook types
----------------

The default hook for a service is `push`. You may wish to have services respond
to other event types, like `pull_request` or `issues`. The full list may be
found in [service.rb](https://github.com/github/github-services/blob/master/lib/service.rb#L79-L83).
Unless your service specifies `default_events <list_of_types>`, only the `push`
hook will be called, see
[service.rb#default_events](https://github.com/github/github-services/blob/55a1fb10a44a80dec6a744d0828c769b00d97ee2/lib/service.rb#L122-L133).

To make use of these additional types, your service will either need to define
`receive_<type>` (like `receive_pull_request_review_comment`) or a generic
`receive_event`.

You can read more about Hooks in the [API Documentation](http://developer.github.com/v3/repos/hooks/).
[webhooks]: https://developer.github.com/webhooks/
6 changes: 1 addition & 5 deletions Gemfile.lock
@@ -1,13 +1,12 @@
PATH
remote: .
specs:
github-services (1.0.0.f39cad6)
github-services (1.0.0.e6759b3)
activeresource (~> 4.0.0)
addressable (~> 2.2.7)
aws-sdk (~> 1.27)
aws-sdk-core (~> 2.0.8)
faraday (= 0.9.0)
httparty (= 0.7.4)
mail (~> 2.3)
mash (~> 0.1.1)
maxcdn (~> 0.2.0)
Expand Down Expand Up @@ -50,7 +49,6 @@ GEM
json (~> 1.4)
nokogiri (>= 1.4.4)
builder (3.2.2)
crack (0.1.8)
curb (0.8.6)
curb-fu (0.6.2)
curb (>= 0.5.4.0)
Expand All @@ -62,8 +60,6 @@ GEM
faraday (>= 0.7.4, < 0.10)
hashie (2.1.2)
http_parser.rb (0.5.3)
httparty (0.7.4)
crack (= 0.1.8)
i18n (0.6.11)
jmespath (1.0.1)
multi_json (~> 1.0)
Expand Down
2 changes: 1 addition & 1 deletion README.mkdn
Expand Up @@ -8,4 +8,4 @@ for instructions on contributing a service.

Current Status
==============
![Build Status](https://travis-ci.org/github/github-services.svg)
[![Build Status](https://travis-ci.org/github/github-services.svg?branch=master)](https://travis-ci.org/github/github-services)
2 changes: 1 addition & 1 deletion docs/autodeploy
Expand Up @@ -2,7 +2,7 @@ This service automatically creates deployments based on your [workflow](http://w

By enabling this hook, GitHub will request a [GitHub Deployment][1] when the default branch is pushed to or your tests suite passes certain criteria.

If you use Continous Integration and GitHub you can select to "Deploy on Status" which will only create deployments when the default branch receives a "success" status for a commit.
If you use Continuous Integration and GitHub you can select to "Deploy on Status" which will only create deployments when the default branch receives a "success" status for a commit.

Install Notes
-------------
Expand Down
18 changes: 15 additions & 3 deletions docs/codeclimate
@@ -1,8 +1,20 @@
Install Notes
-------------

1. Create an account at https://codeclimate.com
2. Enter your Token (see instructions below)
To set up this service hook, follow these steps:

To get your Token: Log into your Code Climate account, click the gear icon at the top-right, then click the Integration tab.
1. Browse to your Code Climate [Dashboard](https://codeclimate.com/dashboard).
2. Click **Organization** in the top-right corner of the page. If this link isn't visible, see below.
3. Select the **Integrations** tab.
4. Copy the **GitHub Service Token** to your clipboard. Note that you do not want to copy the **API Token**.
5. Back in GitHub, paste the token into the text box below.

### Why don't I see the Organization link in Code Climate?

Few possible reasons:

* You're trying to set up a service hook for a repository that lives in the **Open Source** section of your **Dashboard**. Unfortunately we don't yet support service hooks for these repositories.
* Your Code Climate user is not a member of any organizations.
* You're in an organization but not in its **Owners** group. In this case, you unfortunately won't have administrative-rights to view this token.

For more detailed info, see our [help article](http://docs.codeclimate.com/article/222-how-do-i-install-code-climates-github-service-hook).
10 changes: 5 additions & 5 deletions docs/codeship
Expand Up @@ -9,9 +9,9 @@ Codeship will install this hook automatically on sign up. However, if creating t

1. Sign up at https://www.codeship.io/ (you can sign in with GitHub)
2. If the service wasn't set: Go to your project's settings and copy the project uuid.
3. Paste the project uuid into the text field above.
4. Make sure the "Active" checkbox is ticked, and click "Update Settings".
5. Click on the "Codeship" service name and then click the "Test Hook" link.
6. Now there's a running build on your Codeship dashboard.
3. Paste the project uuid into the text field below.
4. Make sure the "Active" checkbox is ticked, and click "Update service".
5. Click on the "Codeship" service name and then click the "Test service" link.
6. Now there should be a running build on your Codeship dashboard.

Check out more details on Codeship at https://www.codeship.io/.
Check out more details on Codeship at https://www.codeship.io/.
2 changes: 1 addition & 1 deletion docs/landscape
Expand Up @@ -12,4 +12,4 @@ To install:
1. Create an account at https://landscape.io (you can sign in with GitHub)
2. Enable checking on a repository. The hook will be automatically installed.

For more information about Landscape, see https://landscape.io/docs/
For more information about Landscape, see https://docs.landscape.io/
10 changes: 5 additions & 5 deletions docs/packagist
Expand Up @@ -6,11 +6,11 @@ Install Notes
1. Create an account on packagist.org
2. Enter your credentials
- The token which you can find on the Packagist profile page
Optional steps:
- Enter the username who the API token belongs to (defaults to the repository owner)
- Enter the host of your Packagist installation (defaults to http://packagist.org), the protocol-prefix is optional and defaults to "http://".

3. Check the "Active" checkbox and click "Update Settings".
Optional steps:
- Enter the username who the API token belongs to (defaults to the repository owner)
- Enter the host of your Packagist installation (defaults to https://packagist.org), the protocol-prefix is optional and defaults to "http://".

For more details about Packagist, visit http://packagist.org/
3. Check the "Active" checkbox and click "Update Service".

For more details about Packagist, visit https://packagist.org/
2 changes: 1 addition & 1 deletion docs/pivotaltracker
Expand Up @@ -2,5 +2,5 @@ Install Notes
-------------

1. "token" is your Pivotal Tracker API Token. This is at the bottom of your 'My Profile' page.
2. "branch" is the name of the branch you want to listen for commits on. If none is provided it will listen on all branches.
2. "branch" is a space-separated list of the branches you want to listen for commits on. If none is provided it will listen on all branches.
3. "endpoint" is an optional endpoint for a custom Pivotal Tracker installation. Leave this blank to use "https://www.pivotaltracker.com".
2 changes: 2 additions & 0 deletions docs/xmpp_im
Expand Up @@ -8,6 +8,8 @@ This service will connect to an XMPP account with the provided details and then
2. **Password** - Password
3. **Receivers** - The JIDs (bare or full) that you'd like to send updates to. JIDS are whitespace separated
4. **Restrict to Branch** - List of branches which will be inspected.
5. **Host** - If you need to set a custom host enter here, otherwise leave blank for DNS lookup.
6. **Port** - If ou need to use a custom port (default: 5222) enter value here.

### Options

Expand Down
2 changes: 2 additions & 0 deletions docs/xmpp_muc
Expand Up @@ -11,6 +11,8 @@ This service will connect to an XMPP MUC room with the provided details and then
5. **Nickname** - The nickname that should be used (defaults to __github__)
6. **Room password** - The password (if required) to join the MUC room
7. **Restrict to Branch** - List of branches which will be inspected.
8. **Host** - If you need to set a custom host enter here, otherwise leave blank for DNS lookup.
9. **Port** - If ou need to use a custom port (default: 5222) enter value here.

### Options

Expand Down
1 change: 0 additions & 1 deletion github-services.gemspec
Expand Up @@ -59,7 +59,6 @@ Gem::Specification.new do |spec|

# Amazon SNS, Amazon SQS, AWS OpsWorks
spec.add_dependency "aws-sdk", "~> 1.27"
spec.add_dependency "httparty", "0.7.4"

# AWS CodeDeploy
spec.add_dependency "aws-sdk-core", "~>2.0.8"
Expand Down
10 changes: 8 additions & 2 deletions lib/services/bamboo.rb
Expand Up @@ -46,8 +46,14 @@ def handle_response(response)
when 404, 301 then raise_config_error("Invalid Bamboo project URL")
else
maybe_xml = response.body
msg = (XmlSimple.xml_in(maybe_xml) if maybe_xml =~ /<?xml/) || {}
raise_config_error msg["message"] if msg["message"]
msg = if maybe_xml =~ /<?xml/
xml_simple = XmlSimple.new
xml_simple.send(:collapse, xml_simple.send(:parse, maybe_xml))
end
msg ||= {}
if msg["status"] && msg["status"]["message"]
raise_config_error msg["status"]["message"]
end
end
end

Expand Down
8 changes: 3 additions & 5 deletions lib/services/packagist.rb
Expand Up @@ -5,7 +5,6 @@ class Service::Packagist < Service
white_list :domain, :user

def receive_push
http.ssl[:verify] = false
http_post packagist_url, :payload => generate_json(payload), :username => user, :apiToken => token
end

Expand Down Expand Up @@ -37,14 +36,13 @@ def domain

def full_domain
if data['domain'].to_s == ''
'http://packagist.org'
'https://packagist.org'
else
data['domain']
end.lstrip.sub(/[\/\s]+$/,'')
data['domain'].lstrip.sub(/[\/\s]+\z/,'').sub(/\Ahttp:\/\/packagist.org/, 'https://packagist.org')
end
end

def domain_parts
@domain_parts ||= full_domain.split('://')
end
end

4 changes: 2 additions & 2 deletions lib/services/smartling.rb
Expand Up @@ -15,7 +15,7 @@ class Service::Smartling < Service

def receive_push
check_config
if data["master_only"] == false || payload["ref"] == "refs/heads/master"
if config_boolean_false?("master_only") || payload["ref"] == "refs/heads/master"
payload["projectId"] = data["project_id"]
payload["apiKey"] = data["api_key"]
payload["resourceFile"] = data["config_path"]
Expand All @@ -36,4 +36,4 @@ def check_config
raise_config_error "Missing path to the project configuration" if data["config_path"].to_s.empty?
end

end
end
14 changes: 14 additions & 0 deletions lib/services/xmpp_base.rb
Expand Up @@ -22,6 +22,20 @@ def receive_event
return true
end

def check_port(data)
return 5222 if data['port'].to_s.empty?
begin
return Integer(data['port'])
rescue Exception => e
raise_config_error 'XMPP port must be numeric'
end
end

def check_host(data)
return nil if data['host'].to_s.empty?
return data['host'].to_s
end

def build_message(event, payload)
case event
when :push
Expand Down
8 changes: 5 additions & 3 deletions lib/services/xmpp_im.rb
Expand Up @@ -5,9 +5,9 @@ class Service::XmppIm < XmppHelper
self.title = 'XMPP IM'
self.hook_name = 'xmpp_im'

string :JID, :receivers
string :JID, :receivers, :host, :port
password :password
boolean :active, :notify_fork, :notify_wiki, :notify_comments,
boolean :notify_fork, :notify_wiki, :notify_comments,
:notify_issue, :notify_watch, :notify_pull

white_list :filter_branch, :JID, :receivers
Expand All @@ -32,7 +32,7 @@ def setup_connection
if (@client.nil?)
begin
@client = ::Jabber::Client.new(::Jabber::JID::new(@data['JID']))
@client.connect
@client.connect(@data['host'], @data['port'])
@client.auth(@data['password'])
::Jabber::debug = true
rescue ::Jabber::ErrorResponse
Expand Down Expand Up @@ -64,6 +64,8 @@ def check_config(data)
raise_config_error 'Illegal receiver JID'
end
end
data['port'] = check_port(data)
data['host'] = check_host(data)
@data = data
end

Expand Down

0 comments on commit c3732fa

Please sign in to comment.