rubyfarm-bisect 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +130 -0
- data/Rakefile +2 -0
- data/exe/rubyfarm-bisect +63 -0
- data/exe/rubyfarm-bisect-core +37 -0
- data/rubyfarm-bisect.gemspec +21 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 561ce8b5d13e224cbf37496b67dab8ef921f0bca276ddd676c50521f89798151
|
4
|
+
data.tar.gz: 7f8c97069d5da97a41c924b340e50a03b7177d6e682388a150614fb9f14e9170
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 930b2fadcb428b5257d9881e62f08a0cc38625323616685d7a4ad4328ed34c56585ec6cea1e6173b32c7f7043602fece9b3ae798586613289c403d5254df49ea
|
7
|
+
data.tar.gz: f57779725fdc87734eb202b8f5687928dcf1713eae38d3c03b3ca7738e182fbd3cbd98c4729f6187a22795e67830812a2e1eed3225ed8e63252b048e5dcf4067
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Yusuke Endoh
|
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,130 @@
|
|
1
|
+
# rubyfarm-bisect
|
2
|
+
|
3
|
+
This tool allows you to do "git bisect" MRI revisions easily.
|
4
|
+
Instead of compiling each revision locally, it uses ["mametter/rubyfarm" repository](https://hub.docker.com/r/mametter/rubyfarm/tags/) in DockerHub, which contains all MRI revisions since r57410 that were successfully built.
|
5
|
+
In short, you don't need to worry about "exit 125" (compilation failure).
|
6
|
+
|
7
|
+
## How to setup
|
8
|
+
|
9
|
+
You need to install rubyfarm-bisect.
|
10
|
+
|
11
|
+
```
|
12
|
+
$ gem install rubyfarm-biesct
|
13
|
+
```
|
14
|
+
|
15
|
+
You also need to be able to use "docker" command without "sudo".
|
16
|
+
|
17
|
+
```
|
18
|
+
$ docker run --rm -t mametter/rubyfarm:r60001 ruby -v
|
19
|
+
Unable to find image 'mametter/rubyfarm:r60001' locally
|
20
|
+
r60001: Pulling from mametter/rubyfarm
|
21
|
+
|
22
|
+
*snip*
|
23
|
+
|
24
|
+
Status: Downloaded newer image for mametter/rubyfarm:r60001
|
25
|
+
ruby 2.5.0dev (2017-09-23 trunk 60001) [x86_64-linux]
|
26
|
+
```
|
27
|
+
|
28
|
+
## How to use
|
29
|
+
|
30
|
+
The simplest way:
|
31
|
+
|
32
|
+
```
|
33
|
+
$ rubyfarm-bisect ruby -e '<your test code>'
|
34
|
+
```
|
35
|
+
|
36
|
+
which assumes that `<your test code>` runs successfully at r57410, and fails at HEAD.
|
37
|
+
|
38
|
+
### `-g`/`-b`: specify a good/bad commit range
|
39
|
+
|
40
|
+
You can specify good and bad commits for git bisect:
|
41
|
+
|
42
|
+
```
|
43
|
+
$ rubyfarm-bisect -g 7c1b30a6 -b HEAD ruby -e '<your test code>'
|
44
|
+
```
|
45
|
+
|
46
|
+
`-g` is a good commit, and `-b` is a bad commit.
|
47
|
+
The arguments must be a SVN revision (e.g., "r60000"), or a commit hash of [git.ruby-lang.org/ruby.git](https://git.ruby-lang.org/ruby.git) (e.g., 7c1b30a6).
|
48
|
+
|
49
|
+
### `-u`: specify a git url
|
50
|
+
|
51
|
+
This tool clones [the git repository of ruby](https://git.ruby-lang.org/ruby.git) into temporary directory, which takes some minutes.
|
52
|
+
To make it fast, you can use your local repository:
|
53
|
+
|
54
|
+
```
|
55
|
+
$ git clone https://git.ruby-lang.org/ruby /path/to/local/git/repo
|
56
|
+
$ rubyfarm-bisect -u /path/to/local/git/repo ruby -e '<your test code>'
|
57
|
+
```
|
58
|
+
|
59
|
+
### `-t`: use `test.rb`
|
60
|
+
|
61
|
+
If you want to pass a test script instead of a command-line argument, use:
|
62
|
+
|
63
|
+
```
|
64
|
+
$ vim test.rb # create and save your test.rb
|
65
|
+
$ rubyfarm-bisect -t
|
66
|
+
```
|
67
|
+
|
68
|
+
which mounts `test.rb` in the current directory to `/root/test.rb` in the docker container.
|
69
|
+
|
70
|
+
### `-m`: specify a path to be mounted to `/root`
|
71
|
+
|
72
|
+
If you want to pass not only a test script but also some data files, you can specify a directory to be mounted to `/root`:
|
73
|
+
|
74
|
+
```
|
75
|
+
$ rubyfarm-bisect -m /path/to/dir ruby /root/test.rb
|
76
|
+
```
|
77
|
+
|
78
|
+
Your `/path/to/dir` must contains `test.rb`. Note that the directory is mounted in read-only mode.
|
79
|
+
|
80
|
+
## Example
|
81
|
+
|
82
|
+
Consider that you encounter a bug of trunk:
|
83
|
+
|
84
|
+
```
|
85
|
+
$ ruby -rripper -e 'Ripper.slice("foo", "ident")'
|
86
|
+
Traceback (most recent call last):
|
87
|
+
8: from -e:1:in `<main>'
|
88
|
+
7: from /opt/ruby/lib/ruby/2.5.0/ripper/lexer.rb:156:in `slice'
|
89
|
+
6: from /opt/ruby/lib/ruby/2.5.0/ripper/lexer.rb:163:in `token_match'
|
90
|
+
5: from /opt/ruby/lib/ruby/2.5.0/ripper/lexer.rb:163:in `new'
|
91
|
+
4: from /opt/ruby/lib/ruby/2.5.0/ripper/lexer.rb:181:in `initialize'
|
92
|
+
3: from /opt/ruby/lib/ruby/2.5.0/ripper/lexer.rb:202:in `compile'
|
93
|
+
2: from /opt/ruby/lib/ruby/2.5.0/ripper/lexer.rb:202:in `scan'
|
94
|
+
1: from /opt/ruby/lib/ruby/2.5.0/ripper/lexer.rb:205:in `block in compile'
|
95
|
+
/opt/ruby/lib/ruby/2.5.0/ripper/lexer.rb:205:in `concat': can't modify frozen String (RuntimeError)
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
You can find the regression by using rubyfarm-bisect:
|
100
|
+
|
101
|
+
```
|
102
|
+
$ rubyfarm-bisect ruby -rripper -e 'Ripper.slice("foo", "ident")'
|
103
|
+
|
104
|
+
*snip*
|
105
|
+
|
106
|
+
e3300dce829955390b5099c013ab4452a74ffd20 is the first bad commit
|
107
|
+
commit e3300dce829955390b5099c013ab4452a74ffd20
|
108
|
+
Author: kazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
|
109
|
+
Date: Sun Feb 5 07:54:32 2017 +0000
|
110
|
+
|
111
|
+
{ext,test}/ripper: Specify frozen_string_literal: true.
|
112
|
+
|
113
|
+
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
114
|
+
|
115
|
+
:040000 040000 7092727b90c406b5672852457099250bc0a8f62e 5ad04f3dce97452d18b6c72850ac69f6b34014bc M ext
|
116
|
+
:040000 040000 83300d1a837029ed91f9675b2de984dcce2fe735 e679db1ae68baac0825f0fde89e3dd743781dd26 M test
|
117
|
+
bisect run success
|
118
|
+
```
|
119
|
+
|
120
|
+
```
|
121
|
+
$ rubyfarm-bisect -g r57410 -b r60000 -u /path/to/ruby.git/ ruby -rripper -e 'Ripper.slice("foo", "ident")'
|
122
|
+
```
|
123
|
+
|
124
|
+
```
|
125
|
+
$ cat test.rb
|
126
|
+
require "ripper"
|
127
|
+
Ripper.slice("foo", "ident")
|
128
|
+
|
129
|
+
$ rubyfarm-bisect -t
|
130
|
+
```
|
data/Rakefile
ADDED
data/exe/rubyfarm-bisect
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "tmpdir"
|
4
|
+
require "optparse"
|
5
|
+
require "open3"
|
6
|
+
|
7
|
+
FIRST_COMMIT = "7c1b30a602ab109d8d5388d7dfb3c5b180ba24e1" # r57410
|
8
|
+
ORIGINAL_GIT_PATH = "https://git.ruby-lang.org/ruby.git"
|
9
|
+
CORE = File.join(__dir__, "rubyfarm-bisect-core")
|
10
|
+
|
11
|
+
good_commit = FIRST_COMMIT
|
12
|
+
bad_commit = "HEAD"
|
13
|
+
git_url = ORIGINAL_GIT_PATH
|
14
|
+
mounts = []
|
15
|
+
|
16
|
+
opt = OptionParser.new
|
17
|
+
opt.on("-u URL", "--git-url URL", "URL of git repository (defalut: #{ ORIGINAL_GIT_PATH })") {|v| git_url = v }
|
18
|
+
opt.on("-g COMMIT", "--good-commit COMMIT", "good commit (defalut: 7c1b30a)") {|v| good_commit = v }
|
19
|
+
opt.on("-b COMMIT", "--bad-commit COMMIT", "bad commit (defalut: HEAD)") {|v| bad_commit = v }
|
20
|
+
opt.on("-m PATH", "--mount-volume PATH", "mount PATH to /root (default: none)") {|v| mounts << v }
|
21
|
+
opt.on("-t", "--test-rb", "run test.rb") do
|
22
|
+
mounts = ["test.rb"]
|
23
|
+
ARGV.concat(["ruby", "/root/test.rb"])
|
24
|
+
end
|
25
|
+
opt.order!(ARGV)
|
26
|
+
|
27
|
+
mounts = mounts.flat_map do |path|
|
28
|
+
path = File.expand_path(path)
|
29
|
+
bind = nil
|
30
|
+
if File.directory?(path)
|
31
|
+
bind = "#{ path }:/root"
|
32
|
+
else
|
33
|
+
bind = "#{ path }:/root/#{ File.basename(path) }"
|
34
|
+
end
|
35
|
+
["-v", bind + ":ro"]
|
36
|
+
end
|
37
|
+
|
38
|
+
solve_rev = -> commit do
|
39
|
+
case commit
|
40
|
+
when /\A\h+\z/
|
41
|
+
commit
|
42
|
+
when /\Ar(\d+)\z/
|
43
|
+
id = "git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@#$1"
|
44
|
+
commits, = Open3.capture2("git", "log", "--grep", id, "--format=format:%H")
|
45
|
+
commits.lines.last.chomp
|
46
|
+
else
|
47
|
+
raise "unknown revision format: #{ commit }"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
puts "color legend: \e[36mgit clone\e[0m git bisect \e[1m\e[32mrubyfarm-bisect\e[0m \e[34mdocker\e[0m \e[31mtest script\e[0m"
|
52
|
+
puts
|
53
|
+
Dir.mktmpdir do |dir|
|
54
|
+
Dir.chdir(dir) do
|
55
|
+
print "\e[36m"
|
56
|
+
system("git", "clone", git_url)
|
57
|
+
puts "\e[0m"
|
58
|
+
Dir.chdir("ruby") do
|
59
|
+
system("git", "bisect", "start", solve_rev[bad_commit], solve_rev[good_commit])
|
60
|
+
system("git", "bisect", "run", CORE, *mounts, "--", *ARGV)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "shellwords"
|
4
|
+
|
5
|
+
REPOSITORY = "mametter/rubyfarm"
|
6
|
+
|
7
|
+
puts
|
8
|
+
rev = "r" + `git show HEAD`[%r(git-svn-id: svn\+ssh://ci.ruby-lang.org/ruby/trunk@(\d+)), 1]
|
9
|
+
log = -> msg do
|
10
|
+
puts "\e[1m\e[32mrubyfarm-bisect[#{ rev }]: #{ msg }\e[0m"
|
11
|
+
end
|
12
|
+
run = -> color, *cmd do
|
13
|
+
log[Shellwords.join(cmd)]
|
14
|
+
print color
|
15
|
+
system(*cmd)
|
16
|
+
print "\e[0m"
|
17
|
+
end
|
18
|
+
tag = "mametter/rubyfarm:#{ rev }"
|
19
|
+
|
20
|
+
run["\e[34m", "docker", "pull", tag]
|
21
|
+
|
22
|
+
unless $?.success?
|
23
|
+
log["failed to pull #{ tag }; skip #{ rev }"]
|
24
|
+
exit 125
|
25
|
+
end
|
26
|
+
|
27
|
+
i = ARGV.index("--")
|
28
|
+
opt = ARGV[0, i]
|
29
|
+
cmd = ARGV[i + 1 .. -1]
|
30
|
+
|
31
|
+
run["\e[31m", "docker", "run", "--rm", "-t", *opt, tag, *cmd]
|
32
|
+
|
33
|
+
status = $?.exitstatus
|
34
|
+
msg = { 0 => "good", 125 => "skip" }[status] || "bad"
|
35
|
+
log["status = #{ status } (#{ rev } is #{ msg })"]
|
36
|
+
puts
|
37
|
+
exit status
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "rubyfarm-bisect"
|
3
|
+
spec.version = "1.0.0"
|
4
|
+
spec.authors = ["Yusuke Endoh"]
|
5
|
+
spec.email = ["mame@ruby-lang.org"]
|
6
|
+
|
7
|
+
spec.summary = %q{"git bisect" ruby without compilation trouble}
|
8
|
+
spec.description = %q{rubyfarm-bisect allows you to do "git bisect" MRI revisions without compilation.}
|
9
|
+
spec.homepage = "https://github.com/mame/rubyfarm-bisect"
|
10
|
+
spec.license = "MIT"
|
11
|
+
|
12
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
13
|
+
f.match(%r{^(test|spec|features)/})
|
14
|
+
end
|
15
|
+
spec.bindir = "exe"
|
16
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyfarm-bisect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yusuke Endoh
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-10 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: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
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
|
+
description: rubyfarm-bisect allows you to do "git bisect" MRI revisions without compilation.
|
42
|
+
email:
|
43
|
+
- mame@ruby-lang.org
|
44
|
+
executables:
|
45
|
+
- rubyfarm-bisect
|
46
|
+
- rubyfarm-bisect-core
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- exe/rubyfarm-bisect
|
56
|
+
- exe/rubyfarm-bisect-core
|
57
|
+
- rubyfarm-bisect.gemspec
|
58
|
+
homepage: https://github.com/mame/rubyfarm-bisect
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.7.3
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: '"git bisect" ruby without compilation trouble'
|
82
|
+
test_files: []
|