dependency_updater 0.1.1
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dependency_updater.gemspec +37 -0
- data/lib/dependency_updater.rb +28 -0
- data/lib/dependency_updater/handlers/gem_handler.rb +66 -0
- data/lib/dependency_updater/handlers/gitlab_handler.rb +68 -0
- data/lib/dependency_updater/handlers/ruby_handler.rb +58 -0
- data/lib/dependency_updater/messengers.rb +29 -0
- data/lib/dependency_updater/railtie.rb +12 -0
- data/lib/dependency_updater/updater.rb +34 -0
- data/lib/dependency_updater/version.rb +3 -0
- data/lib/generators/dependency_updater/install_generator.rb +15 -0
- data/lib/tasks/dependency_updater/run_update.rake +12 -0
- data/lib/templates/dependency_updater/initializer.rb +12 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a4719bbbda500376d9c6b0813dfadf55e24d4fe33156fce432f3cbd567a01f4d
|
4
|
+
data.tar.gz: e70a674c8102304e58356dda2962a5e37c4045571f2918752994edff896036aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b11f7802a8a89e2f8eeef3ea4c4482ec2286f29444bea94368e3031260692da764173c49226d834f4004773a8736228b92b48bd12f9a1fb0436258c6c7a817a6
|
7
|
+
data.tar.gz: 006ab025b425e26146646386b8ef4cb1dbf633ead1b65f3fe5b73107de860d24fff86127339fc27bddec6a9084c069402b06fbbc0cb590e3dfb930b37e0a04a7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 david.michaux@pennmedicine.upenn.edu. 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
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 David Michaux
|
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,43 @@
|
|
1
|
+
# DependencyUpdater
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dependency_updater`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'dependency_updater'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install dependency_updater
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dependency_updater. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the DependencyUpdater project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/dependency_updater/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dependency_updater"
|
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,37 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "dependency_updater/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "dependency_updater"
|
7
|
+
spec.version = DependencyUpdater::VERSION
|
8
|
+
spec.authors = ["David Michaux"]
|
9
|
+
spec.email = ["david.michaux@pennmedicine.upenn.edu"]
|
10
|
+
spec.homepage = "https://gitlab.med.upenn.edu/infrastructure/dependency-updater.git"
|
11
|
+
spec.license = "MIT"
|
12
|
+
spec.summary = %q{A tool to check for gem and Ruby version updates}
|
13
|
+
|
14
|
+
spec.description = <<~DESC
|
15
|
+
This tool
|
16
|
+
1. create's a new branch
|
17
|
+
2. runs 'bundle update'
|
18
|
+
3. find's the latest patch-level version of Ruby and updates files that reference the version
|
19
|
+
4a. commit's the updates and pushes to gitlab, creating a new merge request
|
20
|
+
4b. delete's the branch if no updates were made
|
21
|
+
DESC
|
22
|
+
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
|
34
|
+
spec.add_dependency 'gitlab', '~> 4.14'
|
35
|
+
spec.add_dependency 'rails', '~> 5.0'
|
36
|
+
spec.add_dependency 'rest-client', '~> 2.1'
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "dependency_updater/version"
|
2
|
+
require "dependency_updater/updater"
|
3
|
+
require 'dependency_updater/railtie' if defined?(Rails)
|
4
|
+
|
5
|
+
module DependencyUpdater
|
6
|
+
class Error < StandardError; end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.configure
|
13
|
+
self.configuration ||= Configuration.new
|
14
|
+
yield(configuration) if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
class Configuration
|
18
|
+
attr_accessor :production_branch
|
19
|
+
attr_accessor :merge_target_branch
|
20
|
+
attr_accessor :project_id
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@production_branch = nil
|
24
|
+
@merge_target_branch = nil
|
25
|
+
@project_id = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
module DependencyUpdater
|
6
|
+
class GemHandler
|
7
|
+
|
8
|
+
# captures Using|Installing, gem name, new version, old version
|
9
|
+
UPDATE_REGEX = /(Using|Installing)\s(.+?)\s(\d+?\.\d+?\.\d+?)\s.was\s(\d+?\.\d+?\.\d+?)/
|
10
|
+
|
11
|
+
def initialize(git_object)
|
12
|
+
@gitlab = git_object
|
13
|
+
@gems = []
|
14
|
+
@updated_capistrano = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_gems
|
18
|
+
cmd = 'bundle update'
|
19
|
+
output, err, status = Open3.capture3 cmd
|
20
|
+
|
21
|
+
@gems = updated_gems output
|
22
|
+
return false unless @gems.present?
|
23
|
+
|
24
|
+
actions = actions_from_filepath('Gemfile.lock')
|
25
|
+
@gitlab.commit("Update gems", actions)
|
26
|
+
return true
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_capistrano_deploy
|
30
|
+
return unless check_for_capistrano
|
31
|
+
|
32
|
+
actions = actions_from_filepath('config/deploy.rb')
|
33
|
+
@gitlab.commit('Update deploy.rb with new Capistrano version', actions)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def updated_gems output
|
39
|
+
output.scan(UPDATE_REGEX).map do |match|
|
40
|
+
{
|
41
|
+
name: match[1],
|
42
|
+
old_version: match[3],
|
43
|
+
new_version: match[2]
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def actions_from_filepath(filepath)
|
49
|
+
actions = []
|
50
|
+
content = case filepath
|
51
|
+
when 'config/deploy.rb' then new_deploy_file_text(filepath)
|
52
|
+
when 'Gemfile.lock' then File.read(filepath).strip
|
53
|
+
end
|
54
|
+
|
55
|
+
actions << @gitlab.build_commit_action(filepath, content)
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_for_capistrano
|
59
|
+
@updated_capistrano = @gems.select { |gem| gem[:name] == 'capistrano' }.first
|
60
|
+
end
|
61
|
+
|
62
|
+
def new_deploy_file_text(filepath)
|
63
|
+
File.read(filepath).strip.gsub(/lock '\d+?\.\d+?\.\d+?'/, "lock '#{@updated_capistrano[:new_version]}'")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'gitlab'
|
4
|
+
require 'dependency_updater/messengers'
|
5
|
+
|
6
|
+
module DependencyUpdater
|
7
|
+
class GitlabHandler
|
8
|
+
attr_accessor :gitlab
|
9
|
+
include Messengers
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
config = DependencyUpdater.configuration
|
13
|
+
@project_id = config.project_id
|
14
|
+
@production_branch = config.production_branch
|
15
|
+
@target_branch = config.merge_target_branch
|
16
|
+
@new_branch = nil
|
17
|
+
@mr = nil
|
18
|
+
@messenger = Messengers::GitlabMessenger.new
|
19
|
+
@gitlab = Gitlab.client
|
20
|
+
@today = Time.zone.today
|
21
|
+
end
|
22
|
+
|
23
|
+
def new_branch
|
24
|
+
@new_branch = unique_branch_name
|
25
|
+
@gitlab.create_branch(@project_id, @new_branch, @production_branch)
|
26
|
+
@messenger.new_branch(@new_branch)
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_commit_action(filepath, content)
|
30
|
+
{
|
31
|
+
action: 'update',
|
32
|
+
file_path: filepath,
|
33
|
+
content: content
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def commit(message, actions)
|
38
|
+
signed_msg = "#{message} -- using Dependency Updater'"
|
39
|
+
@gitlab.create_commit(@project_id, @new_branch, signed_msg, actions)
|
40
|
+
@messenger.commit(signed_msg)
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_mr
|
44
|
+
title = "WIP: Dependency Update, #{@today}"
|
45
|
+
@mr = @gitlab.create_merge_request(@project_id, title, {
|
46
|
+
source_branch: @new_branch,
|
47
|
+
target_branch: @target_branch,
|
48
|
+
description: 'Dependency Updater has updated the gems and/or ruby version declarations.',
|
49
|
+
remove_source_branch: true
|
50
|
+
})
|
51
|
+
@messenger.new_mr(@mr.title, @mr.web_url)
|
52
|
+
end
|
53
|
+
|
54
|
+
def backout
|
55
|
+
@gitlab.delete_branch(@project_id, @new_branch)
|
56
|
+
@messenger.backing_out(@new_branch)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def unique_branch_name
|
62
|
+
updater_branches = @gitlab.branches(@project_id, { search: '^dependency-update' }).map(&:name)
|
63
|
+
highest_id = updater_branches.map { |b| b.slice(/\/update-(\d+)/, 1).to_i }.max
|
64
|
+
highest_id = 0 if highest_id.nil?
|
65
|
+
"dependency-update/#{@today}/update-#{highest_id + 1}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
|
5
|
+
module DependencyUpdater
|
6
|
+
class RubyHandler
|
7
|
+
|
8
|
+
SOURCE = 'https://www.ruby-lang.org/en/downloads/releases/'
|
9
|
+
FILES = [
|
10
|
+
'.ruby-version',
|
11
|
+
'.htaccess',
|
12
|
+
'lib/capistrano/templates/htaccess.erb'
|
13
|
+
]
|
14
|
+
|
15
|
+
def initialize(git_object)
|
16
|
+
@gitlab = git_object
|
17
|
+
@original_version = ''
|
18
|
+
@latest_patch_version = ''
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_version_data
|
22
|
+
find_original_version
|
23
|
+
find_latest_patch_version
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_project_files
|
27
|
+
return false if up_to_date
|
28
|
+
|
29
|
+
actions = []
|
30
|
+
FILES.each do |filepath|
|
31
|
+
next unless File.exist? filepath
|
32
|
+
|
33
|
+
new_text = File.read(filepath).strip.gsub(@original_version, @latest_patch_version)
|
34
|
+
actions << @gitlab.build_commit_action(filepath, new_text)
|
35
|
+
end
|
36
|
+
message = "Update Ruby version declarations to #{@latest_patch_version}"
|
37
|
+
@gitlab.commit(message, actions)
|
38
|
+
return true
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def find_original_version
|
44
|
+
@original_version = File.read('.ruby-version').strip
|
45
|
+
end
|
46
|
+
|
47
|
+
def find_latest_patch_version
|
48
|
+
minor_used = @original_version.slice(/(\d+?\.\d+?)\.\d+?/, 1)
|
49
|
+
minor_available = RestClient.get(SOURCE).body.scan(/Ruby\s(#{minor_used}\.\d+?)[^-]/).flatten
|
50
|
+
highest_patch_available = minor_available.map { |v| v.slice(/\d+?$/).to_i }.max
|
51
|
+
@latest_patch_version = "#{minor_used}.#{highest_patch_available}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def up_to_date
|
55
|
+
@original_version == @latest_patch_version
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DependencyUpdater
|
4
|
+
module Messengers
|
5
|
+
class GitlabMessenger
|
6
|
+
def new_branch(name)
|
7
|
+
puts "Checked out new branch: #{name}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def commit(message)
|
11
|
+
puts "Made commit: #{message}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def new_mr(title, web_url)
|
15
|
+
puts <<~MSG
|
16
|
+
Opened a new MR with title: #{title}
|
17
|
+
Find it here: #{web_url}
|
18
|
+
MSG
|
19
|
+
end
|
20
|
+
|
21
|
+
def backing_out(branch)
|
22
|
+
puts <<~MSG
|
23
|
+
Dependency Updater found nothing to update at this time
|
24
|
+
Deleting branch #{branch}
|
25
|
+
MSG
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dependency_updater/handlers/gitlab_handler'
|
4
|
+
require 'dependency_updater/handlers/gem_handler'
|
5
|
+
require 'dependency_updater/handlers/ruby_handler'
|
6
|
+
|
7
|
+
module DependencyUpdater
|
8
|
+
class Updater
|
9
|
+
def initialize
|
10
|
+
@gitlab = GitlabHandler.new
|
11
|
+
@gem = GemHandler.new(@gitlab)
|
12
|
+
@ruby = RubyHandler.new(@gitlab)
|
13
|
+
@updates = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def git_init
|
17
|
+
@gitlab.new_branch
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_ruby
|
21
|
+
@ruby.find_version_data
|
22
|
+
@updates = true if @ruby.update_project_files
|
23
|
+
end
|
24
|
+
|
25
|
+
def update_gems_and_cap_deploy
|
26
|
+
@updates = true if @gem.update_gems
|
27
|
+
@gem.update_capistrano_deploy
|
28
|
+
end
|
29
|
+
|
30
|
+
def wrap_up
|
31
|
+
@updates ? @gitlab.create_mr : @gitlab.backout
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
module DependencyUpdater
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path('../../../templates/dependency_updater', __FILE__)
|
8
|
+
|
9
|
+
desc 'This generator creates an initializer for Dependency Updater, allowing configuration'
|
10
|
+
|
11
|
+
def install_dependency_updater
|
12
|
+
template 'initializer.rb', 'config/initializers/dependency_updater.rb'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :dependency_updater do
|
4
|
+
desc 'Updates gems and ruby version declarations'
|
5
|
+
task run_update: :environment do |_task, args|
|
6
|
+
depbot = DependencyUpdater::Updater.new
|
7
|
+
depbot.git_init
|
8
|
+
depbot.update_ruby
|
9
|
+
depbot.update_gems_and_cap_deploy
|
10
|
+
depbot.wrap_up
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Initialize the Dependency Updater gem
|
2
|
+
DependencyUpdater.configure do |config|
|
3
|
+
config.production_branch = nil # e.g. 'main', 'master' [sic], 'prod'
|
4
|
+
config.merge_target_branch = nil # e.g. 'development', 'staging'; the branch set as 'default' in Gitlab
|
5
|
+
config.project_id = nil # Find this in the "Project overview" page in Gitlab, under the project's name
|
6
|
+
end
|
7
|
+
|
8
|
+
# Initialize the gitlab gem
|
9
|
+
Gitlab.configure do |config|
|
10
|
+
config.endpoint = 'https://gitlab.med.upenn.edu/api/v4/'
|
11
|
+
config.private_token = Rails.application.secrets.gitlab_private_token
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dependency_updater
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Michaux
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gitlab
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.14'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rest-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.1'
|
97
|
+
description: |
|
98
|
+
This tool
|
99
|
+
1. create's a new branch
|
100
|
+
2. runs 'bundle update'
|
101
|
+
3. find's the latest patch-level version of Ruby and updates files that reference the version
|
102
|
+
4a. commit's the updates and pushes to gitlab, creating a new merge request
|
103
|
+
4b. delete's the branch if no updates were made
|
104
|
+
email:
|
105
|
+
- david.michaux@pennmedicine.upenn.edu
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- ".rspec"
|
112
|
+
- ".travis.yml"
|
113
|
+
- CODE_OF_CONDUCT.md
|
114
|
+
- Gemfile
|
115
|
+
- LICENSE.txt
|
116
|
+
- README.md
|
117
|
+
- Rakefile
|
118
|
+
- bin/console
|
119
|
+
- bin/setup
|
120
|
+
- dependency_updater.gemspec
|
121
|
+
- lib/dependency_updater.rb
|
122
|
+
- lib/dependency_updater/handlers/gem_handler.rb
|
123
|
+
- lib/dependency_updater/handlers/gitlab_handler.rb
|
124
|
+
- lib/dependency_updater/handlers/ruby_handler.rb
|
125
|
+
- lib/dependency_updater/messengers.rb
|
126
|
+
- lib/dependency_updater/railtie.rb
|
127
|
+
- lib/dependency_updater/updater.rb
|
128
|
+
- lib/dependency_updater/version.rb
|
129
|
+
- lib/generators/dependency_updater/install_generator.rb
|
130
|
+
- lib/tasks/dependency_updater/run_update.rake
|
131
|
+
- lib/templates/dependency_updater/initializer.rb
|
132
|
+
homepage: https://gitlab.med.upenn.edu/infrastructure/dependency-updater.git
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubygems_version: 3.0.9
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: A tool to check for gem and Ruby version updates
|
155
|
+
test_files: []
|