bummr 0.3.1 → 0.6.0
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 +5 -5
- data/.circleci/config.yml +24 -0
- data/.ruby-version +1 -1
- data/README.md +41 -33
- data/bummr.gemspec +1 -0
- data/lib/bummr/bisecter.rb +1 -1
- data/lib/bummr/check.rb +1 -0
- data/lib/bummr/cli.rb +53 -17
- data/lib/bummr/git.rb +31 -0
- data/lib/bummr/outdated.rb +4 -1
- data/lib/bummr/prompt.rb +14 -0
- data/lib/bummr/remover.rb +26 -0
- data/lib/bummr/scm.rb +9 -0
- data/lib/bummr/updater.rb +15 -4
- data/lib/bummr/version.rb +1 -1
- data/lib/bummr.rb +4 -1
- data/spec/black_box/bummr_update_spec.rb +59 -0
- data/spec/lib/bisecter_spec.rb +3 -3
- data/spec/lib/cli_spec.rb +42 -7
- data/spec/lib/git_spec.rb +88 -0
- data/spec/lib/outdated_spec.rb +54 -26
- data/spec/lib/prompt_spec.rb +49 -0
- data/spec/lib/remover_spec.rb +31 -0
- data/spec/lib/updater_spec.rb +19 -19
- data/spec/spec_helper.rb +1 -0
- metadata +33 -11
- data/circle.yml +0 -3
- data/lib/bummr/rebaser.rb +0 -29
- data/spec/lib/rebaser_spec.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3defa139f960ba6926952a637df79639fa2ba63d42215ea3b6e91036fc2e229b
|
4
|
+
data.tar.gz: c97eef10397acf5441dd7d2ea3330afb9c6e8c98a4aaf1ea33508adb614368bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec5cb5fde39dabc1dc008fd28cbba5cc936a32785ce1605085b9db4e1aabcb04b866a2d8b0e8fa497c45c58507f4268841c3d1ffc91199e266a6a3389aaac72
|
7
|
+
data.tar.gz: 404c1a9e7aecf4140cbdd9fa5137b333731047a6eac06dd0ea018317db94f1926ab28a72dc5323127d49857d90ea52a42c7a449654edc8257ceb22aea7133015
|
@@ -0,0 +1,24 @@
|
|
1
|
+
version: 2.1,
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@1.1.2
|
4
|
+
jobs:
|
5
|
+
test:
|
6
|
+
docker:
|
7
|
+
- image: cimg/ruby:2.7-node
|
8
|
+
steps:
|
9
|
+
- checkout
|
10
|
+
- run:
|
11
|
+
name: Install dependencies
|
12
|
+
command: bundle install
|
13
|
+
- run:
|
14
|
+
name: Test
|
15
|
+
command: bundle exec rake
|
16
|
+
- run:
|
17
|
+
name:
|
18
|
+
Report coverage to codeclimate
|
19
|
+
command: bundle exec codeclimate-test-reporter
|
20
|
+
workflows:
|
21
|
+
version: 2
|
22
|
+
test:
|
23
|
+
jobs:
|
24
|
+
- test
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.2
|
data/README.md
CHANGED
@@ -1,28 +1,39 @@
|
|
1
1
|
# Bummr
|
2
2
|
|
3
|
-
[](https://circleci.com/gh/lpender/bummr)
|
4
4
|
[](https://codeclimate.com/github/lpender/bummr)
|
5
|
-
[](https://codeclimate.com/github/lpender/bummr/test_coverage)
|
6
6
|
|
7
7
|
Updating Gems one by one is a bumm(e)r: especially when one gem causes your build
|
8
8
|
to fail.
|
9
9
|
|
10
|
-
Gems should be updated in [separate commits](
|
10
|
+
Gems should be updated in [separate commits](https://thoughtbot.com/blog/keep-your-gems-up-to-date).
|
11
11
|
|
12
12
|
The bummr gem allows you to automatically update all gems which pass your
|
13
13
|
build in separate commits, and logs the name and sha of each gem that fails.
|
14
14
|
|
15
|
-
Bummr assumes you have good test coverage and follow a [pull-request workflow]
|
16
|
-
with `master` as your default branch.
|
15
|
+
Bummr assumes you have good test coverage and follow a [pull-request workflow].
|
17
16
|
|
18
|
-
|
17
|
+
By default, bummr will assume your base branch is named `master`. If you would
|
18
|
+
like to designate a different base branch, you can set the `BASE_BRANCH`
|
19
|
+
environment variable: `export BASE_BRANCH='main'`
|
20
|
+
|
21
|
+
## Compatibility
|
22
|
+
|
23
|
+
| Bundler Version | Bummr Version |
|
24
|
+
| --------------- | ------------- |
|
25
|
+
| <= 2.1 | <= 0.6.0 |
|
26
|
+
| >= 2.2 | >= 1.0.0 |
|
19
27
|
|
20
|
-
##
|
28
|
+
## Setup
|
21
29
|
|
22
30
|
```bash
|
23
31
|
$ gem install bummr
|
24
32
|
```
|
25
33
|
|
34
|
+
To run headless (skip interactive rebasing/confirmation), use
|
35
|
+
`BUMMR_HEADLESS=true bundle exec bummr update`.
|
36
|
+
|
26
37
|
By default, bummr will use `bundle exec rake` to run your build.
|
27
38
|
|
28
39
|
To customize your build command, `export BUMMR_TEST="./bummr-build.sh"`
|
@@ -30,13 +41,9 @@ To customize your build command, `export BUMMR_TEST="./bummr-build.sh"`
|
|
30
41
|
If you prefer, you can [run the build more than once], to protect against
|
31
42
|
brittle tests and false positives.
|
32
43
|
|
33
|
-
By default, bummr will assume your base branch is named `master`. If you would
|
34
|
-
like to designate a different base branch, you can set the `BASE_BRANCH`
|
35
|
-
environment variable: `export BASE_BRANCH='develop'`
|
36
|
-
|
37
44
|
[run the build more than once]: https://gist.github.com/lpender/f6b55e7f3649db3b6df5
|
38
45
|
|
39
|
-
## Usage
|
46
|
+
## Usage
|
40
47
|
|
41
48
|
Using bummr can take anywhere from a few minutes to several hours, depending
|
42
49
|
on the number of outdated gems you have and the number of tests in your test
|
@@ -46,26 +53,33 @@ For the purpose of these instructions, we are assuming that your base branch is
|
|
46
53
|
`master`. If you would like to specify a different base branch, see the
|
47
54
|
instructions in the Installation section of this README.
|
48
55
|
|
49
|
-
- After installing, create a new, clean branch off of your
|
56
|
+
- After installing, create a new, clean branch off of your main branch.
|
50
57
|
- Run `bummr update`. This may take some time.
|
51
58
|
- `Bummr` will give you the opportunity to interactively rebase your branch
|
52
|
-
before running the tests.
|
53
|
-
to update and close the file.
|
59
|
+
before running the tests. Careful.
|
54
60
|
- At this point, you can leave `bummr` to work for some time.
|
55
|
-
- If your build fails, `bummr` will
|
56
|
-
|
57
|
-
|
61
|
+
- If your build fails, `bummr` will notify you of failures, logging the failures to
|
62
|
+
`log/bummr.log`. At this point it is recommended that you lock that gem version in
|
63
|
+
your Gemfile and start the process over from the top. Alternatively, you may wish
|
64
|
+
to implement code changes which fix the problem.
|
65
|
+
- Once your build passes, open a pull-request and merge it to your main branch.
|
58
66
|
|
59
67
|
##### `bummr update`
|
60
68
|
|
61
|
-
- Finds all your outdated gems
|
62
|
-
- Updates them each individually, using `bundle update --source #{gemname}`
|
63
|
-
- Commits each gem update separately, with a commit message like:
|
64
69
|
- Options:
|
70
|
+
|
65
71
|
- `--all` to include indirect dependencies (`bummr` defaults to direct dependencies only)
|
66
72
|
- `--group` to update only gems from a specific group (i.e. `test`, `development`)
|
73
|
+
- `--gem` to update only a specific gem (i.e. `tzinfo`)
|
74
|
+
|
75
|
+
- Finds all your outdated gems
|
76
|
+
- Updates them each individually, using `bundle update --source #{gemname}`. To use a less
|
77
|
+
conservative update strategy, start `bummr update` with the `--all` option.
|
78
|
+
- Commits each gem update separately, with a commit message like:
|
67
79
|
|
68
|
-
|
80
|
+
```
|
81
|
+
Update gemname from 0.0.1 to 0.0.2
|
82
|
+
```
|
69
83
|
|
70
84
|
- Runs `git rebase -i master` to allow you the chance to review and make changes.
|
71
85
|
- Runs `bummr test`
|
@@ -78,9 +92,9 @@ instructions in the Installation section of this README.
|
|
78
92
|
##### `bummr bisect`
|
79
93
|
|
80
94
|
- `git bisect`s against master.
|
81
|
-
-
|
95
|
+
- Upon finding the bad commit, runs `git bisect reset` and notifies the developer on
|
96
|
+
how best to proceed.
|
82
97
|
- Logs the bad commit in `log/bummr.log`.
|
83
|
-
- Runs `bummr test`.
|
84
98
|
|
85
99
|
## Notes
|
86
100
|
|
@@ -89,12 +103,6 @@ instructions in the Installation section of this README.
|
|
89
103
|
- Once the build passes, you can push your branch and create a pull-request!
|
90
104
|
- You may wish to `tail -f log/bummr.log` in a separate terminal window so you
|
91
105
|
can see which commits are being removed.
|
92
|
-
- Bummr conservatively updates gems using `bundle update --source gemname`
|
93
|
-
- Bummr automatically rebases out commits which fail the build using an "ours"
|
94
|
-
merge strategy.
|
95
|
-
- Bummr may not be able to remove the bad commit due to a merge conflict, in
|
96
|
-
which case you will have to remove it manually, continue the rebase, and
|
97
|
-
run `bummr test` again.
|
98
106
|
|
99
107
|
## License
|
100
108
|
|
@@ -109,9 +117,9 @@ wish to use it with.
|
|
109
117
|
|
110
118
|
`rake` will run the suite of unit tests.
|
111
119
|
|
112
|
-
|
113
|
-
|
114
|
-
|
120
|
+
The suite relies on Oliver Peate's [jet
|
121
|
+
black](https://github.com/odlp/jet_black) testing library for command line feature
|
122
|
+
tests.
|
115
123
|
|
116
124
|
## Thank you!
|
117
125
|
|
data/bummr.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "bundler"
|
29
29
|
spec.add_development_dependency "rake"
|
30
30
|
spec.add_development_dependency "guard"
|
31
|
+
spec.add_development_dependency "jet_black", "~> 0.3"
|
31
32
|
spec.add_development_dependency "pry"
|
32
33
|
spec.add_development_dependency "pry-remote"
|
33
34
|
spec.add_development_dependency "pry-nav"
|
data/lib/bummr/bisecter.rb
CHANGED
data/lib/bummr/check.rb
CHANGED
data/lib/bummr/cli.rb
CHANGED
@@ -1,28 +1,40 @@
|
|
1
1
|
TEST_COMMAND = ENV["BUMMR_TEST"] || "bundle exec rake"
|
2
2
|
BASE_BRANCH = ENV["BASE_BRANCH"] || "master"
|
3
|
+
HEADLESS = ENV["BUMMR_HEADLESS"] || false
|
3
4
|
|
4
5
|
module Bummr
|
5
6
|
class CLI < Thor
|
6
7
|
include Bummr::Log
|
8
|
+
include Bummr::Prompt
|
9
|
+
include Bummr::Scm
|
7
10
|
|
8
11
|
desc "check", "Run automated checks to see if bummr can be run"
|
9
12
|
def check(fullcheck=true)
|
10
13
|
Bummr::Check.instance.check(fullcheck)
|
11
14
|
end
|
12
15
|
|
13
|
-
desc "update",
|
16
|
+
desc "update",
|
17
|
+
"Update outdated gems, run tests, bisect if tests fail\n\n" +
|
18
|
+
"--all: Update indirect dependencies\n" +
|
19
|
+
"--group: Specify a group from the Gemfile to update\n" +
|
20
|
+
"--gem: Specify a specific gem to update\n" +
|
21
|
+
"\n"
|
22
|
+
|
23
|
+
|
14
24
|
method_option :all, type: :boolean, default: false
|
15
25
|
method_option :group, type: :string
|
26
|
+
method_option :gem, type: :string
|
27
|
+
|
16
28
|
def update
|
17
|
-
|
29
|
+
system("bundle install")
|
30
|
+
display_info
|
18
31
|
|
19
32
|
if yes? "Are you ready to use Bummr? (y/n)"
|
20
33
|
check
|
21
34
|
log("Bummr update initiated #{Time.now}")
|
22
|
-
system("bundle")
|
23
35
|
|
24
36
|
outdated_gems = Bummr::Outdated.instance.outdated_gems(
|
25
|
-
all_gems: options[:all], group: options[:group]
|
37
|
+
all_gems: options[:all], group: options[:group], gem: options[:gem]
|
26
38
|
)
|
27
39
|
|
28
40
|
if outdated_gems.empty?
|
@@ -30,7 +42,7 @@ module Bummr
|
|
30
42
|
else
|
31
43
|
Bummr::Updater.new(outdated_gems).update_gems
|
32
44
|
|
33
|
-
|
45
|
+
git.rebase_interactive(BASE_BRANCH)
|
34
46
|
test
|
35
47
|
end
|
36
48
|
else
|
@@ -41,15 +53,17 @@ module Bummr
|
|
41
53
|
desc "test", "Test for a successful build and bisect if necesssary"
|
42
54
|
def test
|
43
55
|
check(false)
|
44
|
-
system "bundle"
|
45
|
-
puts "Testing the build!".color(:green)
|
46
56
|
|
47
|
-
if
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
57
|
+
if yes? "Do you want to test the build now? (y/n)"
|
58
|
+
system "bundle install"
|
59
|
+
puts "Testing the build!".color(:green)
|
60
|
+
|
61
|
+
if system(TEST_COMMAND) == false
|
62
|
+
bisect
|
63
|
+
else
|
64
|
+
puts "Passed the build!".color(:green)
|
65
|
+
puts "See log/bummr.log for details".color(:yellow)
|
66
|
+
end
|
53
67
|
end
|
54
68
|
end
|
55
69
|
|
@@ -57,20 +71,42 @@ module Bummr
|
|
57
71
|
def bisect
|
58
72
|
check(false)
|
59
73
|
|
60
|
-
|
74
|
+
if yes? "Would you like to bisect in order to find which gem is causing " +
|
75
|
+
"your build to break? (y/n)"
|
76
|
+
Bummr::Bisecter.instance.bisect
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "remove_commit", "Remove a commit from the history"
|
81
|
+
def remove_commit(sha)
|
82
|
+
Bummr::Remover.instance.remove_commit(sha)
|
61
83
|
end
|
62
84
|
|
63
85
|
private
|
64
86
|
|
65
|
-
def
|
87
|
+
def display_info
|
88
|
+
puts "Bummr #{VERSION}"
|
66
89
|
puts "To run Bummr, you must:"
|
67
|
-
puts "- Be in the root path of a clean git branch off of #{BASE_BRANCH}"
|
90
|
+
puts "- Be in the root path of a clean git branch off of " + "#{BASE_BRANCH}".color(:yellow)
|
68
91
|
puts "- Have no commits or local changes"
|
69
92
|
puts "- Have a 'log' directory, where we can place logs"
|
70
93
|
puts "- Have your build configured to fail fast (recommended)"
|
71
94
|
puts "- Have locked any Gem version that you don't wish to update in your Gemfile"
|
72
95
|
puts "- It is recommended that you lock your versions of `ruby` and `rails` in your `Gemfile`"
|
73
|
-
puts "
|
96
|
+
puts "\n"
|
97
|
+
puts "Your test command is: " + "'#{TEST_COMMAND}'".color(:yellow)
|
98
|
+
puts "\n"
|
99
|
+
print_received_options
|
100
|
+
end
|
101
|
+
|
102
|
+
def print_received_options
|
103
|
+
puts "Bummr will run with the following options:"
|
104
|
+
|
105
|
+
options.each do |key, value|
|
106
|
+
puts "--#{key.color(:yellow)}: #{value}"
|
107
|
+
end
|
108
|
+
|
109
|
+
puts "\nRun `#{"bummr help update".color(:yellow)}` for more information.\n\n"
|
74
110
|
end
|
75
111
|
end
|
76
112
|
end
|
data/lib/bummr/git.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Bummr
|
2
|
+
class Git
|
3
|
+
include Singleton
|
4
|
+
include Log
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@git_commit = ENV.fetch("BUMMR_GIT_COMMIT") { "git commit" }
|
8
|
+
end
|
9
|
+
|
10
|
+
def add(files)
|
11
|
+
system("git add #{files}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def commit(message)
|
15
|
+
log "Commit: #{message}".color(:green)
|
16
|
+
system("#{git_commit} -m '#{message}'")
|
17
|
+
end
|
18
|
+
|
19
|
+
def rebase_interactive(sha)
|
20
|
+
system("git rebase -i #{BASE_BRANCH}") unless HEADLESS
|
21
|
+
end
|
22
|
+
|
23
|
+
def message(sha)
|
24
|
+
`git log --pretty=format:'%s' -n 1 #{sha}`
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :git_commit
|
30
|
+
end
|
31
|
+
end
|
data/lib/bummr/outdated.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'open3'
|
2
2
|
require 'singleton'
|
3
|
+
require 'bundler'
|
3
4
|
|
4
5
|
module Bummr
|
5
6
|
class Outdated
|
@@ -9,8 +10,10 @@ module Bummr
|
|
9
10
|
results = []
|
10
11
|
|
11
12
|
bundle_options = ""
|
13
|
+
bundle_options << " --parseable" if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2")
|
12
14
|
bundle_options << " --strict" unless options[:all_gems]
|
13
15
|
bundle_options << " --group #{options[:group]}" if options[:group]
|
16
|
+
bundle_options << " #{options[:gem]}" if options[:gem]
|
14
17
|
|
15
18
|
Open3.popen2("bundle outdated" + bundle_options) do |_std_in, std_out|
|
16
19
|
while line = std_out.gets
|
@@ -27,7 +30,7 @@ module Bummr
|
|
27
30
|
end
|
28
31
|
|
29
32
|
def parse_gem_from(line)
|
30
|
-
regex = /
|
33
|
+
regex = /(?:\s+\* )?(.*) \(newest (\d[\d\.]*\d)[,\s] installed (\d[\d\.]*\d)[\),\s]/.match line
|
31
34
|
|
32
35
|
unless regex.nil?
|
33
36
|
{ name: regex[1], newest: regex[2], installed: regex[3] }
|
data/lib/bummr/prompt.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Bummr
|
2
|
+
class Remover < Thor
|
3
|
+
include Singleton
|
4
|
+
include Log
|
5
|
+
include Scm
|
6
|
+
|
7
|
+
desc "remove_commit", "Remove a commit from the history"
|
8
|
+
def remove_commit(sha)
|
9
|
+
log "Bad commit: #{git.message(sha)}, #{sha}".color(:red)
|
10
|
+
log "Resetting..."
|
11
|
+
system("git bisect reset")
|
12
|
+
|
13
|
+
message = "\nThe commit:\n\n `#{sha} #{git.message(sha)}`\n\n" +
|
14
|
+
"Is breaking the build.\n\n" +
|
15
|
+
"Please do one of the following: \n\n" +
|
16
|
+
" 1. Update your code to work with the latest version of this gem.\n\n" +
|
17
|
+
" 2. Perform the following steps to lock the gem version:\n\n" +
|
18
|
+
" - `git reset --hard master`\n" +
|
19
|
+
" - Lock the version of this Gem in your Gemfile.\n" +
|
20
|
+
" - Commit the changes.\n" +
|
21
|
+
" - Run `bummr update` again.\n\n"
|
22
|
+
|
23
|
+
puts message.color(:yellow)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|