How to Contribute to Open Source - zenspider.com€¦ · How to Contribute to Open Source...

Preview:

Citation preview

Madison Ruby 2012, Madison, WI

Ryan Davis, Seattle.rbHow to Contribute to Open Source

How to Contribute to Open Source

Extensibility from Simplicity

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Madison!

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Don’t touch“Montecello”

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Lake Monona

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Lake mono-Na

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

As in: one “na”

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Bi-na

Sha-na-naBa-na-na

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Dodeca-na

na na na nana na na nana na na na

http://en.wikipedia.org/wiki/Na_Na_Na_(Na_Na_Na_Na_Na_Na_Na_Na_Na)

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Double Dodeca-na

na na na na na nana na na na na nana na na na na nana na na na na na

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

I Lied

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Aaron Patterson

talked about how to get

started contributing

to OSS.

Giving BackA practical guide to OSS contributions

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

I won't be talking about getting started.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

He did a better job than I could.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

The video will be up on confreaks.

…Eventually.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

http://juliepagano.com/blog/2012/08/05/steel-city-ruby-conf-2012-sketchnotes/

Madison Ruby 2012, Madison, WI

Ryan Davis, Seattle.rbHow to Contribute to Open Source

How to Contribute to Open Source

Holy crap, Communicate!

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

As a Sidenote…

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Aaron sucks and you never want to work

with him.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

It is embarrassing to go out to lunch with

him.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Embarrassing to work in public with

him.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

All he talks about is his fugly cat.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Who ran into a brick wall as a

kitten.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

…and his sausage.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

A Typical Day…

Why are you meowing?

Thinking about cats.

Why are you meowing Journey's

“Don't Stop Believing”?

Thinking about cats...

singing.

Thinking about cats...

singing.

Grrr…

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

That said...

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

He's brilliant and working with him is

fun and rewarding.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

My Talk

Later stages of open source contribution,both the developer and contributor standpoints.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

What are contributors?

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Consumers

Developers

Consumers

Developers

Contributors

ProprietarySoftware

OSSSoftware

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

What are contributions?

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Bugs

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Feature Requests

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Documentation

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Feedback

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Ye OldeOpen Source

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Started with smoke signals…

http://efuse.com/Grow/www-smoke-signals-rob-colvin-artville.jpg

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Check out project CVS or SVN

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Work your changes.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Submit diffs back to developer.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Hopefully there was sourceforge.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Most of the burden was on the user to

get it right.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Nowadays…

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Being a contributor is easier than ever!

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Now we use git.(or hg or darcs or ...)

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

On github…

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Pull Requestsinstead of patch sets.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

You don't even need a local checkout

anymore!

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Forked projects and Pull requests have

scaled up dramatically.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

This is good, but it also means that the project

developers are massively outnumbered.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

http://www.imdb.com/title/tt0098546/

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

http://www.jwz.org/blog/2008/03/you-get-to-drink-from-the-firehose/

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Most of the burden goes back to the

developer.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

When should someone try to

contribute?

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Early and often!

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

How to handle a contribution?

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Developer has roughly 3 options:

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Accept As-Is

0

25

50

75

100

Accept As-Is

ComplexityDramaEffort

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Reject

0

25

50

75

100

Reject

ComplexityDramaEffort

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Rewrite/Distill

0

25

50

75

100

Rewrite

ComplexityDramaEffort

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Distillation Example

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

minitest has a flexible but “simple” runner

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

“Simple”MiniTest::Unit.autorun MiniTest::Unit.new.run ARGV self.class.runner._run args send plugin run_tests _run_anything :test _run_suites suites, type _run_suite suite, type tc.run self before_setup setup after_setup run_test __name__ __send__ __name__ before_teardown teardown after_teardown

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Allows for:

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Running tests.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Running n×m benchmarks

w/ curve fitting.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

It has hooks for various phases of a

test run.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Aaron helped me generalize the hook

system.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

To meet his needs for testing rails with

mocks.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

He has the benefit of sitting next to me.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Most otherdevelopers don’t.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Mocha, turn,CI systems...

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Number of bugs filed?

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

0

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

copy/paste/munge./lib/mocha/integration/mini_test/assertion_counter.rb./lib/mocha/integration/mini_test/exception_translation.rb./lib/mocha/integration/mini_test/version_13.rb./lib/mocha/integration/mini_test/version_140.rb./lib/mocha/integration/mini_test/version_141.rb./lib/mocha/integration/mini_test/version_142_to_172.rb./lib/mocha/integration/mini_test/version_200.rb./lib/mocha/integration/mini_test/version_201_to_222.rb./lib/mocha/integration/mini_test/version_2110_to_2111.rb./lib/mocha/integration/mini_test/version_2112_to_320.rb./lib/mocha/integration/mini_test/version_230_to_2101.rb./lib/mocha/integration/mini_test/version_330.rb./lib/mocha/integration/mini_test.rb

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

complexity = #frameworks × #releases

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Every time minitest’s internals change, they (can) break.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Untenable

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Happy Example

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

IRC Dialog

co-worker: I was trying to make something similar to this: http://caldersphere.rubyforge.org/ci_reporter/...zenspider: unfamiliar... seczenspider: oh godzenspider: that integration is crazy

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Monkeypatch of 224 lines! ARGH!

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

He submitted a pull request.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Trying to make his life easier.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Patch was the wrong way to go.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

There's already a huge difference.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

It got the ball rolling.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

He was communicating.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

This gave us the chance to reach

some clarity.

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Small change to minitest### Record the result of a single run. Makes it very easy to gather# information. Eg:## class StatisticsRecorder < MiniTest::Unit# def record suite, method, assertions, time, error# # ... record the results somewhere ...# end# end## MiniTest::Unit.runner = StatisticsRecorder.new

def record suite, method, assertions, time, errorend

# in _run_suite:record suite, method, inst._assertions, time, last_error

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Massively Simplified His Codediff --git a/.autotest b/.autotestindex 5cd7c43..f4f90a1 100644--- a/.autotest+++ b/.autotest@@ -1,26 +1,11 @@ # -*- ruby -*- require 'autotest/restart'+require 'autotest/isolate' Autotest.add_hook :initialize do |at| at.add_exception 'test/reports'-# at.extra_files << "../some/external/dependency.rb"-#-# at.libs << ":../some/external"-#-# at.add_exception 'vendor'-#-# at.add_mapping(/dependency.rb/) do |f, _|-# at.files_matching(/test_.*rb$/)-# end-#-# %w(TestA TestB).each do |klass|-# at.extra_class_map[klass] = "test/test_misc.rb"-# end false end -# Autotest.add_hook :run_command do |at|-# system "rake build"-# end # vim: syntax=rubydiff --git a/README.txt b/README.txtindex 92c840f..5898fb2 100644--- a/README.txt+++ b/README.txt@@ -5,11 +5,12 @@ == DESCRIPTION: CI reporter plugin for MiniTest+ This gem was made possible by ATT Interactive. == FEATURES/PROBLEMS: -* Monkeypatches MiniTest::Unit#_run_suite so I have to fix the version of MiniTest I support.+* Uses MiniTest::Unit#record which is only available since version 2.12.0 == SYNOPSIS: diff --git a/Rakefile b/Rakefileindex ff07b81..5e1ae7e 100644--- a/Rakefile+++ b/Rakefile@@ -10,7 +10,7 @@ Hoe.spec 'minitest-ci' do self.testlib = :none - extra_deps << ['minitest', '2.6.0']+ extra_deps << ['minitest', '~> 2.12.0'] extra_dev_deps << ['nokogiri', '~> 1.5.0'] extra_dev_deps << ['rdoc', '>= 2.4.2'] enddiff --git a/lib/minitest/ci.rb b/lib/minitest/ci.rbindex 6c1c5ba..02b1bc7 100644--- a/lib/minitest/ci.rb+++ b/lib/minitest/ci.rb@@ -1,12 +1,7 @@-begin- gem 'minitest', '2.6.0'- require "minitest/unit"-rescue Gem::LoadError => e- msg = [- 'minitest version 2.6.0 required',- 'try: gem install minitest -v 2.6.0'- ]- raise e.exception msg.join("\n")

+require 'minitest/unit'+#unless MiniTest::Unit::VERSION >= '2.12.0'+unless MiniTest::Unit.public_method_defined? :record+ abort 'you are running an unsupported version of MiniTest. try upgrading.' end require 'fileutils'@@ -14,44 +9,20 @@ module MiniTest module Ci- ###- # copied- file = if RUBY_VERSION =~ /^1\.9/ then # bt's expanded, but __FILE__ isn't :(- File.expand_path __FILE__- elsif __FILE__ =~ /^[^\.]/ then # assume both relative- require 'pathname'- pwd = Pathname.new Dir.pwd- pn = Pathname.new File.expand_path(__FILE__)- pn = File.join(".", pn.relative_path_from(pwd)) unless pn.relative?- pn.to_s- else # assume both are expanded- __FILE__- end- # end of copy- ###- CI_MINI_DIR = File.dirname(File.dirname(file)) VERSION = '1.0.4' - @test_dir = nil #'test/reports'- @error = nil+ @report_dir = nil @suites = Hash.new {|h,k| h[k] = []} class << self- attr_accessor :test_dir+ # Accessor method to change the report dir if you don't like the+ # defaults.+ attr_accessor :report_dir end - def add_error e- @error = e- end-- def push suite, method, num, time- a = [method, time, num]- if @error- a << @error- @error = nil- end- @suites[suite] << a+ def push suite, method, num_assertions, time, error+ @suites[suite] << [method, num_assertions, time, error] end def finish io@@ -60,7 +31,7 @@ def finish io clean - Dir.chdir @test_dir do+ Dir.chdir report_dir do @suites.each do |name, suite| generate_suite name, suite end@@ -70,31 +41,17 @@ def finish io private def clean- FileUtils.rm_rf @test_dir- FileUtils.mkdir_p @test_dir+ FileUtils.rm_rf report_dir+ FileUtils.mkdir_p report_dir

end def escape o CGI.escapeHTML(o.to_s) end - # use original as well as filtering this file.- def filter_backtrace bt- bt = MiniTest::filter_backtrace bt- orig_mini_dir = MiniTest::MINI_DIR-- orig_verbose, $VERBOSE = $VERBOSE, nil-- MiniTest.const_set :MINI_DIR, CI_MINI_DIR- MiniTest::filter_backtrace bt- ensure- MiniTest.const_set :MINI_DIR, orig_mini_dir- $VERBOSE = orig_verbose- end- def generate_suite name, suite total_time, assertions, errors, failures, skips = 0, 0, 0, 0, 0- suite.each do |_, t, a, e|+ suite.each do |_, a, t, e| total_time += t assertions += a case e@@ -111,12 +68,12 @@ def generate_suite name, suite f.puts '<?xml version="1.0" encoding="UTF-8"?>' f.puts "<testsuite time='#{"%6f" % total_time}' skipped='#{skips}' failures='#{failures}' errors='#{errors}' name='#{name}' assertions='#{assertions}' tests='#{suite.count}'>" - suite.each do |method, time, asserts, error|+ suite.each do |method, asserts, time, error| f.puts " <testcase time='#{"%6f" % time}' name='#{method}' assertions='#{asserts}'>" if error- bt = filter_backtrace(error.backtrace).join "\n"+ bt = MiniTest::filter_backtrace error.backtrace f.write " <#{type error} type='#{escape error.class}' message=#{escape( error.message ).inspect}>"- f.puts escape bt+ f.puts escape bt.join "\n" f.puts " </#{type error}>" end f.puts " </testcase>"@@ -138,55 +95,10 @@ def type e extend self end - class Unit- # pull this out of _run_suite to make it easier to grab stuff- def _run_suite_method suite, method- inst = suite.new method- inst._assertions = 0-- print "#{suite}##{method} = " if @verbose-- @start_time = Time.now- result = inst.run self- time = Time.now - @start_time-- print "%.2f s = " % time if @verbose- print result- puts if @verbose-- [inst._assertions, time]- end-- # copied out of MiniTest::Unit- def _run_suite suite, type- header = "#{type}_suite_header"- puts send(header, suite) if respond_to? header-- filter = options[:filter] || '/./'- filter = Regexp.new $1 if filter =~ /\/(.*)\//-

- assertions = suite.send("#{type}_methods").grep(filter).map { |method|- a_count, _ = _run_suite_method suite, method-- a_count- }-- return assertions.size, assertions.inject(0) { |sum, n| sum + n }- end- end- class CiUnit < Unit - def _run_suite_method suite, method- res = super-- MiniTest::Ci.push suite, method, *res-- res- end-- def puke klass, meth, e- MiniTest::Ci.add_error e+ def record suite, method, assertions, time, error+ MiniTest::Ci.push suite, method, assertions, time, error super end @@ -199,5 +111,5 @@ def status io = self.output end # set defaults-MiniTest::Ci.test_dir = 'test/reports'+MiniTest::Ci.report_dir = 'test/reports' MiniTest::Unit.runner = MiniTest::CiUnit.newdiff --git a/test/test_minitest_ci.rb b/test/test_minitest_ci.rbindex 1b204ec..6cfffce 100644--- a/test/test_minitest_ci.rb+++ b/test/test_minitest_ci.rb@@ -49,14 +49,14 @@ class TestMinitest::TestCi < MiniTest::Unit::TestCase ensure MiniTest::Unit.output = old_out end+ MiniTest::Unit.runner = nil # reset def self.output @output end def setup- file = "#{MiniTest::Ci.test_dir}/TEST-MockTestSuite.xml"- assert File.exists?( file ), 'expected xml file to exists'+ file = "#{MiniTest::Ci.report_dir}/TEST-MockTestSuite.xml" @file = File.read file @doc = Nokogiri.parse @file @doc = @doc.at_xpath('/testsuite')@@ -113,12 +113,8 @@ def test_output assert_match( /generating ci files/, self.class.output.read ) end - def test_filter_backtrace- bt = begin; raise; rescue => e; e.backtrace; end-- bt = MiniTest::Ci.send :filter_backtrace, bt-- assert_equal 1, bt.size- assert_match( /#{__FILE__}/, bt.first )+ def test_filtering_backtraces+ error = @doc.at_xpath('/testsuite/testcase[@name="test_raise_error"]')+ refute_match /lib\/minitest/, error.inner_text end end-- 1.7.10

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

His code now looks like:class CiUnit < MiniTest::Unit after_tests do MiniTest::Ci.finish self.output end

def record suite, method, assertions, time, error MiniTest::Ci.push suite, method, assertions, time, error super endend

# ...

MiniTest::Unit.runner = MiniTest::CiUnit.new

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Conclusion

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

Communicate Communicate Communicate Communicate

Ryan Davis, Seattle.rb

Madison Ruby 2012, Madison, WI

How to Contribute to Open Source

(Duh)

Madison Ruby 2012, Madison, WI

Ryan Davis, Seattle.rbHow to Contribute to Open Source

!ank You

Recommended