roper 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e80e50dbaa70895a5a752da19af3f4585ff75ea
4
+ data.tar.gz: 0e13f8c6c36bfe611688ebaa6acec97cd223c3b4
5
+ SHA512:
6
+ metadata.gz: bb4a7422c03f7999b8914e26b7f06211275b548374cc13ab68113a1b1eece4c605a341bfc8b7c42e2c03740070c7b10b7cdc5547328467a37819d98a5bc6b90a
7
+ data.tar.gz: ce449ddfd8ca058598827eca51ddce6c8b94144e46308279ccf1953521ff51f3f0898f85c5c27ec65268c65253f794e9edaafcfc917e83092ba613a8cbad4f78
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,135 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
+ # to ignore them, so only the ones explicitly set in this file are enabled.
5
+ DisabledByDefault: true
6
+ Exclude:
7
+ - '**/templates/**/*'
8
+ - '**/vendor/**/*'
9
+ - 'actionpack/lib/action_dispatch/journey/parser.rb'
10
+ - 'bin/*'
11
+
12
+ # Prefer &&/|| over and/or.
13
+ Style/AndOr:
14
+ Enabled: true
15
+
16
+ # Do not use braces for hash literals when they are the last argument of a
17
+ # method call.
18
+ Style/BracesAroundHashParameters:
19
+ Enabled: true
20
+ EnforcedStyle: context_dependent
21
+
22
+ # Align `when` with `case`.
23
+ Layout/CaseIndentation:
24
+ Enabled: true
25
+
26
+ # Align comments with method definitions.
27
+ Layout/CommentIndentation:
28
+ Enabled: true
29
+
30
+ Layout/EmptyLineAfterMagicComment:
31
+ Enabled: true
32
+
33
+ # In a regular class definition, no empty lines around the body.
34
+ Layout/EmptyLinesAroundClassBody:
35
+ Enabled: true
36
+
37
+ # In a regular method definition, no empty lines around the body.
38
+ Layout/EmptyLinesAroundMethodBody:
39
+ Enabled: true
40
+
41
+ # In a regular module definition, no empty lines around the body.
42
+ Layout/EmptyLinesAroundModuleBody:
43
+ Enabled: true
44
+
45
+ Layout/FirstParameterIndentation:
46
+ Enabled: true
47
+
48
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
49
+ Style/HashSyntax:
50
+ Enabled: true
51
+
52
+ # Method definitions after `private` or `protected` isolated calls need one
53
+ # extra level of indentation.
54
+ Layout/IndentationConsistency:
55
+ Enabled: true
56
+ EnforcedStyle: rails
57
+
58
+ # Two spaces, no tabs (for indentation).
59
+ Layout/IndentationWidth:
60
+ Enabled: true
61
+
62
+ Layout/SpaceAfterColon:
63
+ Enabled: true
64
+
65
+ Layout/SpaceAfterComma:
66
+ Enabled: true
67
+
68
+ Layout/SpaceAroundEqualsInParameterDefault:
69
+ Enabled: true
70
+
71
+ Layout/SpaceAroundKeyword:
72
+ Enabled: true
73
+
74
+ Layout/SpaceAroundOperators:
75
+ Enabled: true
76
+
77
+ Layout/SpaceBeforeFirstArg:
78
+ Enabled: true
79
+
80
+ # Defining a method with parameters needs parentheses.
81
+ Style/MethodDefParentheses:
82
+ Enabled: true
83
+
84
+ Style/FrozenStringLiteralComment:
85
+ Enabled: true
86
+ EnforcedStyle: always
87
+ Exclude:
88
+ - 'app/models/traject_indexer.rb'
89
+ - 'db/schema.rb'
90
+
91
+ # Use `foo {}` not `foo{}`.
92
+ Layout/SpaceBeforeBlockBraces:
93
+ Enabled: true
94
+
95
+ # Use `foo { bar }` not `foo {bar}`.
96
+ Layout/SpaceInsideBlockBraces:
97
+ Enabled: true
98
+
99
+ # Use `{ a: 1 }` not `{a:1}`.
100
+ Layout/SpaceInsideHashLiteralBraces:
101
+ Enabled: true
102
+
103
+ Layout/SpaceInsideParens:
104
+ Enabled: true
105
+
106
+ # Check quotes usage according to lint rule below.
107
+ Style/StringLiterals:
108
+ Enabled: true
109
+ EnforcedStyle: double_quotes
110
+
111
+ # Detect hard tabs, no hard tabs.
112
+ Layout/Tab:
113
+ Enabled: true
114
+
115
+ # Blank lines should not have any spaces.
116
+ Layout/TrailingBlankLines:
117
+ Enabled: true
118
+
119
+ # No trailing whitespace.
120
+ Layout/TrailingWhitespace:
121
+ Enabled: true
122
+
123
+ # Use quotes for string literals when they are enough.
124
+ Style/UnneededPercentQ:
125
+ Enabled: true
126
+
127
+ # Align `end` with the matching keyword or starting expression except for
128
+ # assignments, where it should be aligned with the LHS.
129
+ Lint/EndAlignment:
130
+ Enabled: true
131
+ EnforcedStyleAlignWith: variable
132
+
133
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
134
+ Lint/RequireParentheses:
135
+ Enabled: true
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.3
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.3
5
+ before_install: gem install bundler -v 1.15.4
6
+ script:
7
+ - bundle exec rake
8
+ - bundle exec rubocop
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at dtkinzer@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in roper.gemspec
8
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ # Note: The cmd option is now required due to the increasing number of ways
21
+ # rspec may be run, below are examples of the most common uses.
22
+ # * bundler: 'bundle exec rspec'
23
+ # * bundler binstubs: 'bin/rspec'
24
+ # * spring: 'bin/rspec' (This will use spring if running and you have
25
+ # installed the spring binstubs per the docs)
26
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
27
+ # * 'just' rspec: 'rspec'
28
+
29
+ guard :rspec, cmd: "bundle exec rspec" do
30
+ require "guard/rspec/dsl"
31
+ dsl = Guard::RSpec::Dsl.new(self)
32
+
33
+ # Feel free to open issues for suggestions and improvements
34
+
35
+ # RSpec files
36
+ rspec = dsl.rspec
37
+ watch(rspec.spec_helper) { rspec.spec_dir }
38
+ watch(rspec.spec_support) { rspec.spec_dir }
39
+ watch(rspec.spec_files)
40
+
41
+ # Ruby files
42
+ ruby = dsl.ruby
43
+ dsl.watch_spec_files_for(ruby.lib_files)
44
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 David Kinzer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Roper [![Build Status](https://travis-ci.org/tulibraries/roper.svg?branch=master)](https://travis-ci.org/tulibraries/roper)
2
+
3
+ Roper is a cli tool used to help stage a dockerized web app. There are some
4
+ assumptions made about the environment that roper runs in. The main one is
5
+ that traefik has been configured to run via the docker backend and that the
6
+ dockerized web application uses a docker-compose.yml file that knows how to
7
+ communicate with traefik.
8
+
9
+ Another assuption made is that the repository for the web applications roper is
10
+ concerned with lives at GitHub: At this point I have no intention of supporting
11
+ another git repository service.
12
+
13
+ Once Roper is configured it knows how to:
14
+ * Post to a GitHub branch PR with an in progress status for the
15
+ stage site setup. (TODO: make optional)
16
+ * Pull in a repo locally.
17
+ * Checkout a specific branch.
18
+ * Start docker-compose session
19
+ * Post back to GitHub branch PR with link for QA site or failure
20
+ status. (TODO: make optinal)
21
+ * When a PR is merged or closed the resources can be released/recovered.
22
+
23
+ At this point Roper only defines a cli interface so there is no way for GitHub
24
+ to communicate with it direclty via a webhook or whatnot. It's assumed that it
25
+ will be used in conjuction with a service like jenkins ci to handle the webook
26
+ part of the communication and trigger a roper staging on a desired Github event
27
+ (PR creation, update to PR, merge of PR).
28
+
29
+ Eventually it would be nice for Roper to include a web service interface that
30
+ GitHub can post direclty to. But then again, that might just be scope creep
31
+ considering there are already good options for handling the webhook concern
32
+ (i.e. jenkins)
33
+
34
+ ## Installation
35
+
36
+ Add this line to your application's Gemfile:
37
+
38
+ ```ruby gem 'roper' ```
39
+
40
+ And then execute:
41
+
42
+ $ bundle
43
+
44
+ Or install it yourself as:
45
+
46
+ $ gem install roper
47
+
48
+ ## Usage
49
+
50
+ `roper lasso "--repo=<REPO_OWNER>/<REPO_NAME>" [--branch=<BRANCH_NAME>] [--status-url=<STATUS_URL>]`
51
+
52
+ `roper release "--repo=<REPO_OWNER>/<REPO_NAME>" [--branch=<BRANCH_NAME>]`
53
+
54
+ OR:
55
+
56
+ You can use the individual components of the library as you wish.
57
+
58
+ ## Github Authentication
59
+ Currenlty Roper uses netrc for github authentication. I'm hoping to slap an interface to create this at setup but for now you will need to add a ~/.netrc file with an entry for `api.github.com` manually.
60
+
61
+ ## Development
62
+
63
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
64
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
65
+ prompt that will allow you to experiment.
66
+
67
+ To install this gem onto your local machine, run `bundle exec rake install`. To
68
+ release a new version, update the version number in `version.rb`, and then run
69
+ `bundle exec rake release`, which will create a git tag for the version, push
70
+ git commits and tags, and push the `.gem` file to
71
+ [rubygems.org](https://rubygems.org).
72
+
73
+ ## Contributing
74
+
75
+ Bug reports and pull requests are welcome on GitHub at
76
+ https://github.com/tulibraries/roper. This project is intended to be a safe,
77
+ welcoming space for collaboration, and contributors are expected to adhere to
78
+ the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
79
+
80
+ ## License
81
+
82
+ The gem is available as open source under the terms of the [MIT
83
+ License](http://opensource.org/licenses/MIT).
84
+
85
+ ## Code of Conduct
86
+
87
+ Everyone interacting in the Roper project’s codebases, issue trackers, chat
88
+ rooms and mailing lists is expected to follow the [code of
89
+ conduct](https://github.com/tulibraries/roper/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "roper"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/roper ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "roper"
5
+
6
+ include GLI::App
7
+
8
+ program_desc "Roper is a CLI tool used to help stage a dockerized web app."
9
+
10
+ version Roper::VERSION
11
+
12
+ subcommand_option_handling :normal
13
+ arguments :strict
14
+ sort_help :manually
15
+
16
+ desc "Pulls in github repo locally and runs docker-compose up on it."
17
+ command :lasso do |c|
18
+ c.desc "* The repo full name '<owner>/<name>'"
19
+ c.flag :r, :repo
20
+
21
+ c.desc "The branch name"
22
+ c.flag :b, :branch
23
+ c.default_value "master"
24
+
25
+ c.desc "The sha reference that we will post to."
26
+ c.flag :r, :ref
27
+
28
+ c.desc "A URL to a build status page."
29
+ c.flag :l, :status_url
30
+
31
+ c.desc "URL protocol to use in target_url for final traefik hosted container."
32
+ c.default_value "https"
33
+ c.flag :p, :protocol
34
+
35
+ c.desc "URL domain to use in target_url for final traefik hosted container."
36
+ c.flag :d, :domain
37
+
38
+ c.action do |global_options, options, args|
39
+ repo = options[:repo]
40
+ branch = options[:branch]
41
+ Roper::CLI.lasso(repo, branch, options)
42
+ puts "lasso command ran"
43
+ end
44
+ end
45
+
46
+ desc "Runs docker-compose down on local copy of repo and deletes the repo contents."
47
+ command :release do |c|
48
+ c.desc "* The repo full name '<owner>/<name>'"
49
+ c.flag :r, :repo
50
+
51
+ c.desc "The branch name"
52
+ c.flag :b, :branch
53
+ c.default_value "master"
54
+
55
+ c.action do |global_options, options, args|
56
+ repo = options[:repo]
57
+ branch = options[:branch]
58
+ Roper::CLI.release(repo, branch, options)
59
+ puts "release command ran"
60
+ end
61
+ end
62
+
63
+ pre do |global, command, options, args|
64
+ if args.count > 0
65
+ raise "Unexpected arguments, this command does not take any arguments."
66
+ end
67
+
68
+ if command.name == :lasso
69
+ raise "Protocol must be either 'http' or 'https'" unless ["http", "https"].include?(options[:protocol])
70
+ end
71
+
72
+ # Pre logic here
73
+ # Return true to proceed; false to abort and not call the
74
+ # chosen command
75
+ # Use skips_pre before a command to skip this block
76
+ # on that command only
77
+ true
78
+ end
79
+
80
+ post do |global, command, options, args|
81
+ # Post logic here
82
+ # Use skips_post before a command to skip this
83
+ # block on that command only
84
+ end
85
+
86
+ on_error do |exception|
87
+ # Error logic here
88
+ # return false to skip default error handling
89
+ true
90
+ end
91
+
92
+ exit run(ARGV)
data/lib/roper/cli.rb ADDED
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "roper/version"
4
+ require "roper/repo"
5
+ require "roper/hub"
6
+ require "roper/driver"
7
+
8
+ module Roper
9
+ class CLI
10
+ def initialize(repo, branch, options = {})
11
+ @branch = branch
12
+ @options = options
13
+ @git = Roper::Repo.new(repo, branch)
14
+ @driver = Roper::Driver.new(repo, branch)
15
+ @hub = Roper::Hub.new(repo, ref)
16
+ end
17
+
18
+ def self.lasso(repo, branch, options = {})
19
+ self.new(repo, branch, options).lasso
20
+ end
21
+
22
+ def self.release(repo, branch, options = {})
23
+ self.new(repo, branch, options).release
24
+ end
25
+
26
+ def lasso
27
+ @hub.create_status("pending", status_pending.merge(status_url))
28
+ begin
29
+ @git.mount || @git.update
30
+ @driver.up
31
+ @hub.create_status("success", status_success.merge(success_url))
32
+ rescue
33
+ @hub.create_status("failure", status_failure.merge(status_url))
34
+ end
35
+ end
36
+
37
+ def release
38
+ @driver.down
39
+ @git.unmount
40
+ end
41
+
42
+ private
43
+ def ref
44
+ @options[:ref] || begin
45
+ @git.mount || @git.update
46
+ @git.ref
47
+ end
48
+ end
49
+
50
+ def status_url
51
+ status_url = @options[:status_url]
52
+ status_url ? { status_url: status_url } : {}
53
+ end
54
+
55
+ def success_url
56
+ protocol = @options[:protocol] || "https"
57
+ domain = @options[:domain] || ENV["DOMAIN"]
58
+ { status_url: "#{protocol}://#{@branch}.#{domain}" }
59
+ end
60
+
61
+ def status_pending
62
+ { description: "The build process is in progress." }
63
+ end
64
+
65
+ def status_error
66
+ { description: "The build process had irrecoverrable error." }
67
+ end
68
+
69
+ def status_failure
70
+ { description: "The PR branch failed to build." }
71
+ end
72
+
73
+ def status_success
74
+ { description: "The PR brach was successfully built." }
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "docker/compose"
4
+
5
+ module Roper
6
+ class Driver
7
+ def initialize(repo, branch)
8
+ @repo = Octokit::Repository.new(repo)
9
+ @branch = branch
10
+ @mount_path = Roper::mount_path(repo, branch)
11
+ @compose = Docker::Compose.new
12
+ end
13
+
14
+ def up
15
+ Dir.chdir(@mount_path)
16
+ set_env_variables
17
+ @compose.up
18
+ end
19
+
20
+ def down
21
+ Dir.chdir(@mount_path)
22
+ @compose.down
23
+ end
24
+
25
+ private
26
+ def set_env_variables
27
+ ENV["ROPER_REPO_OWNER"] = @repo.owner
28
+ ENV["ROPER_REPO_NAME"] = @repo.name
29
+ ENV["ROPER_REPO_BRANCH"] = @branch
30
+ end
31
+ end
32
+ end
data/lib/roper/hub.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "octokit"
4
+ require "netrc"
5
+ require "json"
6
+
7
+ module Roper
8
+ class Hub
9
+ def initialize(repo, ref)
10
+ @repo = repo
11
+ @ref = ref
12
+ @client = Octokit::Client.new(netrc: true)
13
+ end
14
+
15
+ def create_status(state, options = {})
16
+ @client.create_status(@repo, @ref, state, options.merge(context: "Roper Stager"))
17
+ end
18
+ end
19
+ end
data/lib/roper/repo.rb ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "git"
4
+ require "octokit"
5
+ require "fileutils"
6
+
7
+ module Roper
8
+ class Repo
9
+ def initialize(repo, branch)
10
+ @branch = branch
11
+ @repo = Octokit::Repository.new(repo)
12
+ @mount_path = Roper::mount_path(repo, branch)
13
+ end
14
+
15
+ def mount
16
+ Git.clone(@repo.url, @mount_path)
17
+ .checkout(@branch) rescue nil
18
+ end
19
+
20
+ def update
21
+ Git.open(@mount_path)
22
+ .pull("origin", @branch)
23
+ end
24
+
25
+ def unmount
26
+ FileUtils.rm_r(@mount_path)
27
+ end
28
+
29
+ def ref
30
+ Git.open(@mount_path).object("HEAD").sha
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Roper
4
+ VERSION = "1.0.0.rc1"
5
+ end
data/lib/roper.rb ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "roper/cli"
4
+ require "gli"
5
+
6
+ module Roper
7
+ # Your code goes here...
8
+ ROOT_PATH = "#{ENV["HOME"]}/.roper"
9
+
10
+ def self.mount_path(repo, branch)
11
+ repo = Octokit::Repository.new(repo)
12
+ "#{Roper::ROOT_PATH}/#{repo.owner}/#{repo.name}/#{branch}"
13
+ end
14
+ end
data/roper.gemspec ADDED
@@ -0,0 +1,45 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path("../lib", __FILE__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require "roper/version"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "roper"
10
+ spec.version = Roper::VERSION
11
+ spec.authors = ["David Kinzer"]
12
+ spec.email = ["dtkinzer@gmail.com"]
13
+
14
+ spec.summary = " Stages dockerized web apps in a Traefik environment. "
15
+ spec.description = " Command line tool for staging dockerized Github web apps in a Traefik docker environment."
16
+ spec.homepage = "https://github.com/tulibraries/roper"
17
+ spec.platform = Gem::Platform::RUBY
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency "docker-compose"
28
+ spec.add_dependency "git"
29
+ spec.add_dependency "gli"
30
+ spec.add_dependency "netrc"
31
+ spec.add_dependency "octokit"
32
+
33
+ spec.add_development_dependency "binding_of_caller"
34
+ spec.add_development_dependency "bundler", "~> 1.15"
35
+ spec.add_development_dependency "guard"
36
+ spec.add_development_dependency "guard-rspec"
37
+ spec.add_development_dependency "multi_json"
38
+ spec.add_development_dependency "pry"
39
+ spec.add_development_dependency "pry-byebug"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
42
+ spec.add_development_dependency "rubocop"
43
+ spec.add_development_dependency "vcr"
44
+ spec.add_development_dependency "webmock"
45
+ end
metadata ADDED
@@ -0,0 +1,305 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roper
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - David Kinzer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: docker-compose
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: git
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: gli
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: netrc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: octokit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: binding_of_caller
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.15'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.15'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard
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'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: multi_json
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry-byebug
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rake
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '10.0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '10.0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rspec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '3.0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '3.0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rubocop
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: vcr
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: webmock
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ description: " Command line tool for staging dockerized Github web apps in a Traefik
252
+ docker environment."
253
+ email:
254
+ - dtkinzer@gmail.com
255
+ executables:
256
+ - roper
257
+ extensions: []
258
+ extra_rdoc_files: []
259
+ files:
260
+ - ".gitignore"
261
+ - ".rspec"
262
+ - ".rubocop.yml"
263
+ - ".ruby-version"
264
+ - ".travis.yml"
265
+ - CODE_OF_CONDUCT.md
266
+ - Gemfile
267
+ - Guardfile
268
+ - LICENSE.txt
269
+ - README.md
270
+ - Rakefile
271
+ - bin/console
272
+ - bin/setup
273
+ - exe/roper
274
+ - lib/roper.rb
275
+ - lib/roper/cli.rb
276
+ - lib/roper/driver.rb
277
+ - lib/roper/hub.rb
278
+ - lib/roper/repo.rb
279
+ - lib/roper/version.rb
280
+ - roper.gemspec
281
+ homepage: https://github.com/tulibraries/roper
282
+ licenses:
283
+ - MIT
284
+ metadata: {}
285
+ post_install_message:
286
+ rdoc_options: []
287
+ require_paths:
288
+ - lib
289
+ required_ruby_version: !ruby/object:Gem::Requirement
290
+ requirements:
291
+ - - ">="
292
+ - !ruby/object:Gem::Version
293
+ version: '0'
294
+ required_rubygems_version: !ruby/object:Gem::Requirement
295
+ requirements:
296
+ - - ">"
297
+ - !ruby/object:Gem::Version
298
+ version: 1.3.1
299
+ requirements: []
300
+ rubyforge_project:
301
+ rubygems_version: 2.6.14
302
+ signing_key:
303
+ specification_version: 4
304
+ summary: Stages dockerized web apps in a Traefik environment.
305
+ test_files: []