Skip to content

Commit

Permalink
Merge pull request drbrain#125 from deivid-rodriguez/github_actions
Browse files Browse the repository at this point in the history
Switch CI to Github Actions
  • Loading branch information
drbrain committed Mar 11, 2022
2 parents 75574f2 + 53c64a0 commit 857c3ba
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 61 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,36 @@
name: Test

on:
pull_request:

push:
branches:
- master

jobs:
test:
strategy:
fail-fast: false
matrix:
ruby: [2.4, 2.5, 2.6, 2.7, '3.0', 3.1, jruby-9.2]
os: [ubuntu-20.04, windows-2019]
include:
- { ruby: 3.1, os: ubuntu-20.04, matrix: pipeline }

runs-on: ${{ matrix.os }}

env:
CI_MATRIX: ${{ matrix.matrix }}

steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
rubygems: 3.3.6
bundler-cache: true

- name: Test things
run: bundle exec rake test manifest:check
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

13 changes: 6 additions & 7 deletions Gemfile
@@ -1,15 +1,14 @@
# -*- ruby -*-

# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.

source "https://rubygems.org/"

gem "connection_pool", "~>2.2"
gemspec

gem "minitest", "~>5.11", :group => [:development, :test]
gem "hoe-bundler", "~>1.5", :group => [:development, :test]
gem "hoe-travis", "~>1.4", ">=1.4.1", :group => [:development, :test]
gem "rake", "~>13.0"
gem "minitest", "~>5.15", :group => [:development, :test]
gem "rdoc", ">=4.0", "<7", :group => [:development, :test]
gem "hoe", "~>3.17", :group => [:development, :test]
gem "rake-manifest", "~>0.2"

gem 'net-http-pipeline', '~> 1.0' if ENV['CI_MATRIX'] == 'pipeline'

# vim: syntax=ruby
1 change: 0 additions & 1 deletion Manifest.txt
@@ -1,6 +1,5 @@
.autotest
.gemtest
.travis.yml
Gemfile
History.txt
Manifest.txt
Expand Down
2 changes: 1 addition & 1 deletion README.rdoc
@@ -1,7 +1,7 @@
= net-http-persistent

home :: https://github.com/drbrain/net-http-persistent
rdoc :: http://docs.seattlerb.org/net-http-persistent
rdoc :: https://rdoc.info/gems/net-http-persistent

== DESCRIPTION:

Expand Down
46 changes: 20 additions & 26 deletions Rakefile
@@ -1,31 +1,25 @@
# -*- ruby -*-

require 'hoe'

Hoe.plugin :bundler
Hoe.plugin :git
Hoe.plugin :minitest
Hoe.plugin :travis

Hoe.spec 'net-http-persistent' do
developer 'Eric Hodel', 'drbrain@segment7.net'

self.readme_file = 'README.rdoc'
self.extra_rdoc_files += Dir['*.rdoc']

self.require_ruby_version '>= 2.3'

license 'MIT'

rdoc_locations <<
'docs-push.seattlerb.org:/data/www/docs.seattlerb.org/net-http-persistent/'

dependency 'connection_pool', '~> 2.2'
dependency 'minitest', '~> 5.2', :development
dependency 'hoe-bundler', '~> 1.5', :development
dependency 'hoe-travis', ['~> 1.4', '>= 1.4.1'], :development
dependency 'net-http-pipeline', '~> 1.0' if
ENV['TRAVIS_MATRIX'] == 'pipeline'
require "bundler/gem_tasks"

require "rake/testtask"

Rake::TestTask.new

require "rake/manifest"

Rake::Manifest::Task.new do |t|
t.patterns = [
".autotest",
".gemtest",
".travis.yml",
"Gemfile",
"History.txt",
"Manifest.txt",
"README.rdoc",
"Rakefile",
"{test,lib}/**/*"
]
end

# vim: syntax=Ruby
11 changes: 9 additions & 2 deletions lib/net/http/persistent.rb
Expand Up @@ -164,7 +164,14 @@ class Net::HTTP::Persistent
# limits (typically windows).

if Process.const_defined? :RLIMIT_NOFILE
DEFAULT_POOL_SIZE = Process.getrlimit(Process::RLIMIT_NOFILE).first / 4
open_file_limits = Process.getrlimit(Process::RLIMIT_NOFILE)

# Under JRuby on Windows Process responds to `getrlimit` but returns something that does not match docs
if open_file_limits.respond_to?(:first)
DEFAULT_POOL_SIZE = open_file_limits.first / 4
else
DEFAULT_POOL_SIZE = 256
end
else
DEFAULT_POOL_SIZE = 256
end
Expand Down Expand Up @@ -710,7 +717,7 @@ def max_retries= retries
# block is given. Returns all responses received.
#
# See
# Net::HTTP::Pipeline[http://docs.seattlerb.org/net-http-pipeline/Net/HTTP/Pipeline.html]
# Net::HTTP::Pipeline[https://rdoc.info/gems/net-http-pipeline/Net/HTTP/Pipeline]
# for further details.
#
# Only if <tt>net-http-pipeline</tt> was required before
Expand Down
22 changes: 22 additions & 0 deletions net-http-persistent.gemspec
@@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = "net-http-persistent".freeze
s.version = File.read("lib/net/http/persistent.rb")[/VERSION += +([\"\'])([\d][\w\.]+)\1/, 2]

s.metadata = { "homepage_uri" => "https://github.com/drbrain/net-http-persistent" }
s.require_paths = ["lib".freeze]
s.authors = ["Eric Hodel".freeze]
s.description = "Manages persistent connections using Net::HTTP including a thread pool for\nconnecting to multiple hosts.\n\nUsing persistent HTTP connections can dramatically increase the speed of HTTP.\nCreating a new HTTP connection for every request involves an extra TCP\nround-trip and causes TCP congestion avoidance negotiation to start over.\n\nNet::HTTP supports persistent connections with some API methods but does not\nmake setting up a single persistent connection or managing multiple\nconnections easy. Net::HTTP::Persistent wraps Net::HTTP and allows you to\nfocus on how to make HTTP requests.".freeze
s.email = ["drbrain@segment7.net".freeze]
s.extra_rdoc_files = ["History.txt".freeze, "Manifest.txt".freeze, "README.rdoc".freeze]
s.files = File.read("Manifest.txt").split
s.homepage = "https://github.com/drbrain/net-http-persistent".freeze
s.licenses = ["MIT".freeze]
s.rdoc_options = ["--main".freeze, "README.rdoc".freeze]
s.required_ruby_version = ">= 2.4".freeze
s.summary = "Manages persistent connections using Net::HTTP including a thread pool for connecting to multiple hosts".freeze

s.add_runtime_dependency(%q<connection_pool>.freeze, ["~> 2.2"])
end

9 changes: 8 additions & 1 deletion test/test_net_http_persistent.rb
Expand Up @@ -362,6 +362,7 @@ def test_connection_for_cached_expired
end

def test_connection_for_finished_ssl
skip 'Broken on Windows' if Gem.win_platform?
skip 'OpenSSL is missing' unless HAVE_OPENSSL

uri = URI.parse 'https://example.com/path'
Expand Down Expand Up @@ -555,6 +556,7 @@ def test_connection_for_refused
end

def test_connection_for_ssl
skip 'Broken on Windows' if Gem.win_platform?
skip 'OpenSSL is missing' unless HAVE_OPENSSL

uri = URI.parse 'https://example.com/path'
Expand Down Expand Up @@ -595,6 +597,7 @@ def test_connection_for_ssl_cached_reconnect
end

def test_connection_for_ssl_case
skip 'Broken on Windows' if Gem.win_platform?
skip 'OpenSSL is missing' unless HAVE_OPENSSL

uri = URI.parse 'HTTPS://example.com/path'
Expand Down Expand Up @@ -631,6 +634,7 @@ def test_unescape
end

def test_expired_eh
skip 'Broken on Windows' if Gem.win_platform?
c = basic_connection
c.requests = 0
c.last_use = Time.now - 11
Expand Down Expand Up @@ -976,7 +980,10 @@ def test_requestx
assert_equal 'keep-alive', req['connection']
assert_equal '30', req['keep-alive']

assert_in_delta Time.now, c.last_use
# There's some roounding issue on jruby preventing this from passing
unless RUBY_PLATFORM == "java"
assert_in_delta Time.now, c.last_use
end

assert_equal 1, c.requests
end
Expand Down

0 comments on commit 857c3ba

Please sign in to comment.