roper 1.0.0.rc5 → 1.0.0.rc6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/README.md +2 -2
- data/README.rdoc +3 -3
- data/lib/roper/cli.rb +25 -5
- data/lib/roper/driver.rb +5 -0
- data/lib/roper/hub.rb +17 -0
- data/lib/roper/repo.rb +7 -0
- data/lib/roper/version.rb +1 -1
- data/roper.gemspec +2 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae2dd0a9db8c1fc093de8d10d0a8e159d6bfd944
|
4
|
+
data.tar.gz: 4d7f4611065d473c3cf344ae822ba0820f002617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a06ee8fb77587bbad566ae10859fd95145989f29b3ab725f5334ce072d120ba7732cd324199c755eb529a464c44c1395d25338b6ad9abf90c8d4ce7f0702241
|
7
|
+
data.tar.gz: be17270fc88ed8a459c7142be393c14b1ec86b85337f76079246af3f1d357d951789ffb8080b8c8bb41659862450333c893e42ab36ed05a438a7f7bcb08fea50
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Roper [](https://travis-ci.org/tulibraries/roper)
|
1
|
+
# Roper [](https://travis-ci.org/tulibraries/roper) [](https://coveralls.io/github/tulibraries/roper?branch=master) [](http://www.rubydoc.info/github/tulibraries/roper/master)
|
2
2
|
|
3
3
|
Roper is a cli tool used to help stage a dockerized web app. There are some
|
4
4
|
assumptions made about the environment that roper runs in. The main one is
|
@@ -20,7 +20,7 @@ Once Roper is configured it knows how to:
|
|
20
20
|
status. (TODO: make optinal)
|
21
21
|
* When a PR is merged or closed the resources can be released/recovered.
|
22
22
|
|
23
|
-
|
23
|
+
Currently, Roper only defines a cli interface so there is no way for GitHub
|
24
24
|
to communicate with it direclty via a webhook or whatnot. It's assumed that it
|
25
25
|
will be used in conjuction with a service like jenkins ci to handle the webook
|
26
26
|
part of the communication and trigger a roper staging on a desired Github event
|
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Roper {<img src="https://travis-ci.org/tulibraries/roper.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/tulibraries/roper]
|
1
|
+
= Roper {<img src="https://travis-ci.org/tulibraries/roper.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/tulibraries/roper] {<img src="https://coveralls.io/repos/github/tulibraries/roper/badge.svg?branch=master" alt="Coverage Status" />}[https://coveralls.io/github/tulibraries/roper?branch=master] {<img src="https://img.shields.io/badge/docs-rubydoc-blue.svg" alt="Docs" />}[http://www.rubydoc.info/github/tulibraries/roper/master]
|
2
2
|
|
3
3
|
Roper is a cli tool used to help stage a dockerized web app. There are some
|
4
4
|
assumptions made about the environment that roper runs in. The main one is
|
@@ -20,8 +20,8 @@ Once Roper is configured it knows how to:
|
|
20
20
|
status.
|
21
21
|
* When a PR is merged or closed the resources can be released/recovered.
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
Currently, Roper only defines a cli interface so there is no way for GitHub to
|
24
|
+
communicate with it direclty via a webhook or whatnot. It's assumed that it
|
25
25
|
will be used in conjuction with a service like jenkins ci to handle the webook
|
26
26
|
part of the communication and trigger a roper staging on a desired Github event
|
27
27
|
(PR creation, update to PR, merge of PR).
|
data/lib/roper/cli.rb
CHANGED
@@ -6,24 +6,47 @@ require "roper/hub"
|
|
6
6
|
require "roper/driver"
|
7
7
|
|
8
8
|
module Roper
|
9
|
+
# This is a controller, and the main entry point into the rest of the
|
10
|
+
# library. It composes Hub, Repo and Driver to define the main entry
|
11
|
+
# methods, lasso and release.
|
9
12
|
class CLI
|
13
|
+
# @param [String] repo A GitHub reposiory in the form <user>/<name>
|
14
|
+
# @param [branch] the name of a branch in the reposiory
|
15
|
+
# @param options [Hash] A customizable set of options
|
16
|
+
#
|
17
|
+
# @options :context [String] A context to differentiate this status from others (default: "roper")
|
18
|
+
# @options :status_url [String] A link to more details about this status
|
19
|
+
# @options :sha [String] ref The sha for a commit
|
20
|
+
# @options :protocol [String] https or http
|
21
|
+
# @options :domain [String] domain for traefik server
|
10
22
|
def initialize(repo, branch, options = {})
|
23
|
+
@repo = repo
|
11
24
|
@branch = branch
|
12
25
|
@options = options
|
13
26
|
@git = Roper::Repo.new(repo, branch)
|
14
27
|
@driver = Roper::Driver.new(repo, branch)
|
15
|
-
@hub = Roper::Hub.new(repo, ref)
|
16
28
|
end
|
17
29
|
|
30
|
+
# Creates an instance of CLI and runs release
|
31
|
+
#
|
32
|
+
# @see initialize
|
33
|
+
# @see release
|
18
34
|
def self.lasso(repo, branch, options = {})
|
19
35
|
self.new(repo, branch, options).lasso
|
20
36
|
end
|
21
37
|
|
38
|
+
# Creates an instance of CLI and runs lasso
|
39
|
+
#
|
40
|
+
# @see initialize
|
41
|
+
# @see lasso
|
22
42
|
def self.release(repo, branch, options = {})
|
23
43
|
self.new(repo, branch, options).release
|
24
44
|
end
|
25
45
|
|
46
|
+
# Update the GitHub PR with a pending status, then pull in the repository
|
47
|
+
# and build it by running docker-compose up on it
|
26
48
|
def lasso
|
49
|
+
@hub ||= Roper::Hub.new(@repo, ref)
|
27
50
|
@hub.create_status("pending", status_pending.merge(status_url))
|
28
51
|
begin
|
29
52
|
@git.mount || @git.update
|
@@ -34,6 +57,7 @@ module Roper
|
|
34
57
|
end
|
35
58
|
end
|
36
59
|
|
60
|
+
# Run docker-compose down on the project and delete the assets
|
37
61
|
def release
|
38
62
|
@driver.down
|
39
63
|
@git.unmount
|
@@ -62,10 +86,6 @@ module Roper
|
|
62
86
|
{ description: "The build process is in progress." }
|
63
87
|
end
|
64
88
|
|
65
|
-
def status_error
|
66
|
-
{ description: "The build process had irrecoverrable error." }
|
67
|
-
end
|
68
|
-
|
69
89
|
def status_failure
|
70
90
|
{ description: "The PR branch failed to build." }
|
71
91
|
end
|
data/lib/roper/driver.rb
CHANGED
@@ -3,7 +3,10 @@
|
|
3
3
|
require "docker/compose"
|
4
4
|
|
5
5
|
module Roper
|
6
|
+
# This class is concerned with docker-compose process
|
6
7
|
class Driver
|
8
|
+
# @param [String] repo A GitHub reposiory in the form <user>/<name>
|
9
|
+
# @param [branch] the name of a branch in the reposiory
|
7
10
|
def initialize(repo, branch)
|
8
11
|
@repo = Octokit::Repository.new(repo)
|
9
12
|
@branch = branch
|
@@ -11,11 +14,13 @@ module Roper
|
|
11
14
|
@compose = Docker::Compose::Session.new(dir: @mount_path)
|
12
15
|
end
|
13
16
|
|
17
|
+
# Runs docker-compose up in detached mode with a forced rebuild
|
14
18
|
def up
|
15
19
|
set_env_variables
|
16
20
|
@compose.up(detached: true, build: true)
|
17
21
|
end
|
18
22
|
|
23
|
+
# Runs docker-compose down
|
19
24
|
def down
|
20
25
|
@compose.down
|
21
26
|
end
|
data/lib/roper/hub.rb
CHANGED
@@ -5,13 +5,30 @@ require "netrc"
|
|
5
5
|
require "json"
|
6
6
|
|
7
7
|
module Roper
|
8
|
+
# This class is concerned with GitHub API communications.
|
8
9
|
class Hub
|
10
|
+
# Create and instance of the Hub class
|
11
|
+
#
|
12
|
+
# @param [String] repo A GitHub reposiory in the form <user>/<name>
|
13
|
+
# @param [String] ref The sha for a commit
|
9
14
|
def initialize(repo, ref)
|
10
15
|
@repo = repo
|
11
16
|
@ref = ref
|
12
17
|
@client = Octokit::Client.new(netrc: true)
|
13
18
|
end
|
14
19
|
|
20
|
+
# Changes the status on a GitHub PR
|
21
|
+
#
|
22
|
+
# @see https://octokit.github.io/octokit.rb/Octokit/Client/Statuses.html
|
23
|
+
#
|
24
|
+
# @param state [String] The state: pending, success, failure
|
25
|
+
# @param options [Hash] A customizable set of options
|
26
|
+
#
|
27
|
+
# @options :context [String] A context to differentiate this status from others (default: "roper")
|
28
|
+
# @options :target_url [String] A link to more details about this status
|
29
|
+
# @options :description [String] A short human-readable description of this status
|
30
|
+
#
|
31
|
+
# @return [Sawyer::Resource] A short human-readable description of this status
|
15
32
|
def create_status(state, options = {})
|
16
33
|
@client.create_status(@repo, @ref, state, options.merge(context: "roper"))
|
17
34
|
end
|
data/lib/roper/repo.rb
CHANGED
@@ -5,27 +5,34 @@ require "octokit"
|
|
5
5
|
require "fileutils"
|
6
6
|
|
7
7
|
module Roper
|
8
|
+
# This class is concerned with the repository resource itself
|
8
9
|
class Repo
|
10
|
+
# @param [String] repo A GitHub reposiory in the form <user>/<name>
|
11
|
+
# @param [branch] the name of a branch in the reposiory
|
9
12
|
def initialize(repo, branch)
|
10
13
|
@branch = branch
|
11
14
|
@repo = Octokit::Repository.new(repo)
|
12
15
|
@mount_path = Roper::mount_path(repo, branch)
|
13
16
|
end
|
14
17
|
|
18
|
+
# Pulls in the initialized repository and checkout the initialized branch
|
15
19
|
def mount
|
16
20
|
Git.clone(@repo.url, @mount_path)
|
17
21
|
.checkout(@branch) rescue nil
|
18
22
|
end
|
19
23
|
|
24
|
+
# Pulls the latest commit to branch from origin
|
20
25
|
def update
|
21
26
|
Git.open(@mount_path)
|
22
27
|
.pull("origin", @branch)
|
23
28
|
end
|
24
29
|
|
30
|
+
# Deletes the local copy of the reposiory
|
25
31
|
def unmount
|
26
32
|
FileUtils.rm_r(@mount_path)
|
27
33
|
end
|
28
34
|
|
35
|
+
# Helper function to get HEAD commit sha for the initialized branch
|
29
36
|
def ref
|
30
37
|
Git.open(@mount_path).object("HEAD").sha
|
31
38
|
end
|
data/lib/roper/version.rb
CHANGED
data/roper.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
|
33
33
|
spec.add_development_dependency "binding_of_caller"
|
34
34
|
spec.add_development_dependency "bundler", "~> 1.15"
|
35
|
+
spec.add_development_dependency "coveralls"
|
35
36
|
spec.add_development_dependency "guard"
|
36
37
|
spec.add_development_dependency "guard-rspec"
|
37
38
|
spec.add_development_dependency "multi_json"
|
@@ -42,4 +43,5 @@ Gem::Specification.new do |spec|
|
|
42
43
|
spec.add_development_dependency "rubocop"
|
43
44
|
spec.add_development_dependency "vcr"
|
44
45
|
spec.add_development_dependency "webmock"
|
46
|
+
|
45
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Kinzer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-compose
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.15'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: guard
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -257,6 +271,7 @@ executables:
|
|
257
271
|
extensions: []
|
258
272
|
extra_rdoc_files: []
|
259
273
|
files:
|
274
|
+
- ".coveralls.yml"
|
260
275
|
- ".gitignore"
|
261
276
|
- ".rspec"
|
262
277
|
- ".rubocop.yml"
|