New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CI #224
Merged
Merged
Fix CI #224
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8d6d3bc
Handle the case of an unreachable network.
f9b8fe8
Add support for headers to the test adapter
kek 758ad95
removed autoload, caused problems with the Test adapter tests SOMETIMES
technoweenie d905caa
Merge commit '8d6d3bcf33f2247907c19fee3bca3597b0d1d062' into fix-ci
technoweenie 55c03ad
Merge commit 'f9b8fe8546c2546811d7b68e4020cd17f890d45e' into fix-ci
technoweenie 0d48d70
use #load_middleware since autoload was removed
technoweenie 1aed2d1
Don't let nested mutex deadlock the thread.
technoweenie 5f1d2bf
add script/console
technoweenie d704d6f
add script/gemspec
technoweenie 6403d7b
add script/gem
technoweenie 6faf149
add script/release
technoweenie 306ed76
add script/generate_certs
technoweenie 9bcad6f
document the scripts
technoweenie 7849079
use system, not `
technoweenie da5ae30
rename script/gem to script/package
technoweenie File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env ruby | ||
# Usage: script/console | ||
# Starts an IRB console with this library loaded. | ||
|
||
require 'rubygems' | ||
require 'irb' | ||
require File.expand_path("../ruby", __FILE__) | ||
require File.expand_path("../../lib/#{MakeScript.lib_name}", __FILE__) | ||
IRB.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env ruby | ||
# Usage: script/gemspec | ||
# Updates the gemspec's name, version, and file manifest. | ||
|
||
require File.expand_path("../ruby", __FILE__) | ||
|
||
def replace_header(head, header_name) | ||
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{MakeScript.send(header_name)}'"} | ||
end | ||
|
||
# read spec file and split out manifest section | ||
spec = File.read(MakeScript.gemspec_file) | ||
head, manifest, tail = spec.split(" # = MANIFEST =\n") | ||
|
||
# replace name version and date | ||
replace_header(head, :lib_name) | ||
replace_header(head, :version) | ||
|
||
files = `git ls-files`. | ||
split("\n"). | ||
sort. | ||
reject { |file| file =~ /^\./ }. | ||
reject { |file| file =~ /^(rdoc|pkg)/ }. | ||
map { |file| " #{file}" }. | ||
join("\n") | ||
|
||
# piece file back together and write | ||
manifest = " s.files = %w[\n#{files}\n ]\n" | ||
spec = [head, manifest, tail].join(" # = MANIFEST =\n") | ||
File.open(MakeScript.gemspec_file, 'w') { |io| io.write(spec) } | ||
puts "Updated #{MakeScript.gemspec_file}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
# Usage: generate_certs | ||
# Generate test certs for testing Faraday with SSL | ||
|
||
require File.expand_path("../ruby", __FILE__) | ||
require 'openssl' | ||
require 'fileutils' | ||
|
||
# Adapted from WEBrick::Utils. Skips cert extensions so it | ||
# can be used as a CA bundle | ||
def create_self_signed_cert(bits, cn, comment) | ||
rsa = OpenSSL::PKey::RSA.new(bits) | ||
cert = OpenSSL::X509::Certificate.new | ||
cert.version = 2 | ||
cert.serial = 1 | ||
name = OpenSSL::X509::Name.new(cn) | ||
cert.subject = name | ||
cert.issuer = name | ||
cert.not_before = Time.now | ||
cert.not_after = Time.now + (365*24*60*60) | ||
cert.public_key = rsa.public_key | ||
cert.sign(rsa, OpenSSL::Digest::SHA1.new) | ||
return [cert, rsa] | ||
end | ||
|
||
cert, key = create_self_signed_cert(1024, [['CN', 'localhost']], 'Faraday Test CA') | ||
FileUtils.mkdir_p 'tmp' | ||
File.open('tmp/faraday-cert.key', 'w') {|f| f.puts(key) } | ||
File.open('tmp/faraday-cert.crt', 'w') {|f| f.puts(cert.to_s) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env ruby | ||
# Usage: script/gem | ||
# Updates the gemspec and builds a new gem in the pkg directory. | ||
|
||
require File.expand_path("../ruby", __FILE__) | ||
require 'fileutils' | ||
|
||
FileUtils.mkdir_p File.expand_path("../../pkg", __FILE__) | ||
system "script/gemspec" | ||
system "gem build #{MakeScript.gemspec_file}" | ||
system "mv #{MakeScript.gem_file} pkg" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env ruby | ||
# Usage: script/release | ||
# Build the package, tag a commit, push it to origin, and then release the | ||
# package publicly. | ||
|
||
require File.expand_path("../ruby", __FILE__) | ||
|
||
system "script/package" | ||
system "git commit --allow-empty -a -m 'Release #{MakeScript.version}'" | ||
system "git tag v#{MakeScript.version}" | ||
system "git push origin" | ||
system "git push origin v#{MakeScript.version}" | ||
system "gem push pkg/#{MakeScript.gem_file}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Opinionated module that picks out a ruby library's name and version based on | ||
# some conventions: | ||
# | ||
# * #{lib_name}.gemspec | ||
# * A VERSION constant defined in lib/#{lib_name}.rb | ||
# | ||
# Example: | ||
# | ||
# # foo.gemspec | ||
# # lib/foo.rb | ||
# module Foo | ||
# VERSION = "0.1" | ||
# end | ||
|
||
module MakeScript | ||
extend self | ||
|
||
def lib_name | ||
@lib_name ||= Dir['*.gemspec'].first.split('.').first | ||
end | ||
|
||
def version | ||
@version ||= begin | ||
line = File.read("lib/#{lib_name}.rb")[/^\s*VERSION\s*=\s*.*/] | ||
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] | ||
end | ||
end | ||
|
||
def gemspec_file | ||
@gemspec_file ||= "#{lib_name}.gemspec" | ||
end | ||
|
||
def gem_file | ||
@gem_file ||= "#{lib_name}-#{version}.gem" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a very dubious way to initialize a
Mutex
. If you have two threads that callmiddleware_mutex
at the same time, they may get different mutexes the first time.Also, instead of trying to use
@middleware_mutex.locked?
to create a poor mans recursive mutex, this should really just useMonitor
instead. It acts just like a mutex but it's recursive.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I have no idea what I'm doing here. Just trying to remove autoload.
It'd be awesome if someone that wanted autoload gone would help remove it
:)
It looks like I can essentially replace Mutex with Monitor, and it'll
magically work?
On Fri, Dec 28, 2012 at 1:54 AM, Eric Lindvall notifications@github.comwrote:
Rick Olson
http://github.com/technoweenie
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. Monitor has the same interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rad, thanks.