kender 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/kender.rb +3 -0
- data/lib/kender/configuration.rb +11 -0
- data/lib/kender/github.rb +55 -0
- data/lib/kender/railtie.rb +9 -0
- data/lib/kender/tasks.rb +1 -0
- data/lib/kender/tasks/ci.rake +58 -0
- data/lib/kender/version.rb +3 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjQ4OWIyMjllZjEzMjA3ZjRhMDYzYjE5M2FmMjg1ODE0MzU0MDJjZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZGVmM2U0NTEwMzU0M2ZiYzQzYmFkOWM3Njc5ZDM3ZmVjYjVmZmUyMQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZGFjY2Y4ZjU5MjlhMjZiYzM5YmQ3YjYwYzI5MTA3YjY2MmVmNzU0NjE3MmEx
|
10
|
+
NWQ3MWIwZWE1OTNiYmQyOTBhNDc5NDIwOTAzZGRjN2Y0OGQwMWEyNDdiNzVi
|
11
|
+
MGMxODFjM2FjZDc1M2FlMTFkNTMwYjkwZjAxZmMxODM1NTY1Zjc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YjQwMzAwZThkMTFkMTAyZGU1MWExNDBkZDRjZTg2YmNjZmZiZjBlMDZmZmJm
|
14
|
+
OGI2MzQ2NzMwZmUzZTUxZmJkOTNjZjY5Njk4MjUzMTMxOThmZDQ1YmYzZTk5
|
15
|
+
MDkxMTBjNTFkN2Q5MjA2OGJiZjIyYzc5Y2ZkOGI2YjE5ODE4MmQ=
|
data/lib/kender.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
|
3
|
+
module Kender
|
4
|
+
|
5
|
+
# This module abstracts access to GitHub. It's current, sole purpose is to
|
6
|
+
# allow commit statuses to be created.
|
7
|
+
#
|
8
|
+
# See: https://github.com/blog/1227-commit-status-api
|
9
|
+
#
|
10
|
+
module GitHub
|
11
|
+
extend self
|
12
|
+
|
13
|
+
# Update the commit status for the current HEAD commit. Assumes the working
|
14
|
+
# directory is a git repo and the "origin" remote points to a GitHub repo.
|
15
|
+
# The +state+ variable must be one of :pending, :success or :failure. The
|
16
|
+
# +config+ object must respond to +build_number+, +build_url+ and
|
17
|
+
# +github_auth_token+.
|
18
|
+
#
|
19
|
+
def update_commit_status(state, config)
|
20
|
+
|
21
|
+
# TODO: Refactor the following code to use gems like git/grit/rugged and
|
22
|
+
# octokit. ~asmith
|
23
|
+
|
24
|
+
body = %Q({
|
25
|
+
"state": "#{state.to_s}",
|
26
|
+
"target_url": "#{config.build_url}",
|
27
|
+
"description": "Continuous integration run #{config.build_number}"
|
28
|
+
})
|
29
|
+
commit = `git log -1 --format=format:%H`
|
30
|
+
remotes = `git remote --verbose`
|
31
|
+
|
32
|
+
unless repo = /^origin\s+git@github.com:(\w+\/\w+)\b/.match(remotes)[1]
|
33
|
+
put "Could not establish GitHub repo name from 'origin' remote"
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
37
|
+
uri = URI("https://api.github.com/repos/#{repo}/statuses/#{commit}?access_token=#{config.github_auth_token}")
|
38
|
+
|
39
|
+
if config.github_auth_token
|
40
|
+
puts "Setting #{repo} commit #{commit} status to '#{state}' on GitHub"
|
41
|
+
else
|
42
|
+
puts "Skipping setting #{repo} commit #{commit} status to '#{state}' on GitHub because access token not configured"
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
|
47
|
+
response = http.post(uri.request_uri, body)
|
48
|
+
unless response.is_a?(Net::HTTPCreated)
|
49
|
+
puts "Setting commit status FAILED", response
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
data/lib/kender/tasks.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
load 'kender/tasks/ci.rake'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'kender/configuration'
|
2
|
+
require 'kender/github'
|
3
|
+
|
4
|
+
desc "Configure and run continuous integration tests then clean up"
|
5
|
+
task :ci => ['ci:status:pending'] do
|
6
|
+
begin
|
7
|
+
Rake::Task["ci:config"].invoke
|
8
|
+
Rake::Task["ci:run"].invoke
|
9
|
+
Rake::Task["ci:status:success"].invoke
|
10
|
+
rescue
|
11
|
+
Rake::Task["ci:status:failure"].invoke
|
12
|
+
ensure
|
13
|
+
Rake::Task["ci:clean"].invoke
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :ci do
|
18
|
+
|
19
|
+
desc "Configure the app to run continuous integration tests"
|
20
|
+
# Could depend on 'db:schema:load' or 'db:setup' here instead of 'db:migrate'
|
21
|
+
# if the 'db/schema.rb' file was committed to the repo (as per Rails
|
22
|
+
# recommendations).
|
23
|
+
task :config => ['ci:env', 'config:all', 'db:create', 'db:migrate']
|
24
|
+
|
25
|
+
desc "Run continuous integration tests with the current configuration"
|
26
|
+
task :run => ['ci:env', 'ci:shamus', 'ci:brakeman']
|
27
|
+
|
28
|
+
desc "Destroy resources created externally for the continuous integration run, e.g. drops databases"
|
29
|
+
task :clean => ['ci:env', 'db:drop']
|
30
|
+
|
31
|
+
task :env do
|
32
|
+
ENV['RAILS_ENV'] ||= 'test'
|
33
|
+
end
|
34
|
+
|
35
|
+
task :shamus do
|
36
|
+
sh('bundle exec shamus')
|
37
|
+
end
|
38
|
+
|
39
|
+
task :brakeman do
|
40
|
+
# Make warnings fail the build with the '--exit-on-warn' switch.
|
41
|
+
sh('bundle exec brakeman --quiet --exit-on-warn')
|
42
|
+
end
|
43
|
+
|
44
|
+
namespace :status do
|
45
|
+
|
46
|
+
config = Kender::Configuration.new
|
47
|
+
|
48
|
+
task :pending do
|
49
|
+
Kender::GitHub.update_commit_status(:pending, config)
|
50
|
+
end
|
51
|
+
task :success do
|
52
|
+
Kender::GitHub.update_commit_status(:success, config)
|
53
|
+
end
|
54
|
+
task :failure do
|
55
|
+
Kender::GitHub.update_commit_status(:failure, config)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kender
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Smith
|
8
|
+
- Jordi Polo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- asmith@mdsol.com
|
17
|
+
- jcarres@mdsol.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/kender.rb
|
23
|
+
- lib/kender/configuration.rb
|
24
|
+
- lib/kender/github.rb
|
25
|
+
- lib/kender/railtie.rb
|
26
|
+
- lib/kender/tasks.rb
|
27
|
+
- lib/kender/tasks/ci.rake
|
28
|
+
- lib/kender/version.rb
|
29
|
+
homepage:
|
30
|
+
licenses: []
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.2.2
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: Kender is a library of rake tasks that provides a consistent framework for
|
52
|
+
continuous integration (CI).
|
53
|
+
test_files: []
|
54
|
+
has_rdoc:
|