diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb118f400..ab1d23db8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,20 +6,24 @@ concurrency: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }}-latest timeout-minutes: 10 strategy: fail-fast: false matrix: ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby, truffleruby] + os: [ubuntu] + include: + - ruby: 3.3 + os: windows env: JAVA_OPTS: '-Xmx1024m' RUBYOPT: '-w' JRUBY_OPTS: '--dev' - name: "Tests: Ruby ${{ matrix.ruby }}" + name: "Tests: Ruby ${{ matrix.ruby }} - ${{ matrix.os }}" steps: - name: Clone Repo uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index b9cc412e0..db8fd7964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ ## Current +## Release v1.3.2, edge v0.7.1 (29 May 2024) + +concurrent-ruby: + +* (#1051) Remove dependency on `win32ole`. + +concurrent-ruby-edge: + +* (#1052) Fix dependency on `concurrent-ruby` to allow the latest release. + ## Release v1.3.1 (29 May 2024) * Release 1.3.0 was broken when pushed to RubyGems. 1.3.1 is a packaging fix. @@ -7,7 +17,7 @@ ## Release v1.3.0 (28 May 2024) * (#1042) Align Java Executor Service behavior for `shuttingdown?`, `shutdown?` -* (#1038) Add `Concurrent.usable_processor_count` that is cgroups aware. +* (#1038) Add `Concurrent.available_processor_count` that is cgroups aware. ## Release v1.2.3 (16 Jan 2024) diff --git a/Rakefile b/Rakefile index f167f4659..006fcb993 100644 --- a/Rakefile +++ b/Rakefile @@ -28,6 +28,10 @@ unless Concurrent.on_jruby? || Concurrent.on_truffleruby? end end +def which?(executable) + !`which #{executable} 2>/dev/null`.empty? +end + require 'rake_compiler_dock' namespace :repackage do desc '* with Windows fat distributions' @@ -42,12 +46,19 @@ namespace :repackage do Rake::Task['lib/concurrent-ruby/concurrent/concurrent_ruby.jar'].invoke # build all gem files + rack_compiler_dock_kwargs = {} + if which?('podman') and (!which?('docker') || `docker --version`.include?('podman')) + # podman and only podman available, so RakeCompilerDock will use podman, otherwise it uses docker + rack_compiler_dock_kwargs = { + options: ['--privileged'], # otherwise the directory in the image is empty + runas: false + } + end %w[x86-mingw32 x64-mingw32].each do |plat| RakeCompilerDock.sh( "bundle install --local && bundle exec rake native:#{plat} gem --trace", platform: plat, - options: ['--privileged'], # otherwise the directory in the image is empty - runas: false) + **rack_compiler_dock_kwargs) end end end @@ -256,10 +267,12 @@ namespace :release do Bundler.with_original_env do sh 'ruby -v' + sh 'bundle install' sh 'bundle exec rake spec:installed' - env = { "PATH" => "#{ENV['CONCURRENT_JRUBY_HOME']}/bin:#{ENV['PATH']}" } + env = { "PATH" => "#{ENV.fetch('CONCURRENT_JRUBY_HOME')}/bin:#{ENV['PATH']}" } sh env, 'ruby -v' + sh env, 'bundle install' sh env, 'bundle exec rake spec:installed' end @@ -271,8 +284,8 @@ namespace :release do task :publish => ['publish:ask', 'publish:tag', 'publish:rubygems', 'publish:post_steps'] namespace :publish do - publish_base = true - publish_edge = false + publish_base = nil + publish_edge = nil task :ask do begin @@ -280,8 +293,15 @@ namespace :release do input = STDIN.gets.strip.downcase end until %w(y n).include?(input) exit 1 if input == 'n' + + begin + STDOUT.puts 'Do you want to publish `concurrent-ruby`? (y/n)' + input = STDIN.gets.strip.downcase + end until %w(y n).include?(input) + publish_base = input == 'y' + begin - STDOUT.puts 'It will publish `concurrent-ruby`. Do you want to publish `concurrent-ruby-edge`? (y/n)' + STDOUT.puts 'Do you want to publish `concurrent-ruby-edge`? (y/n)' input = STDIN.gets.strip.downcase end until %w(y n).include?(input) publish_edge = input == 'y' diff --git a/concurrent-ruby-edge.gemspec b/concurrent-ruby-edge.gemspec index 02383d346..4eedb53f0 100644 --- a/concurrent-ruby-edge.gemspec +++ b/concurrent-ruby-edge.gemspec @@ -25,5 +25,5 @@ Please see http://concurrent-ruby.com for more information. s.required_ruby_version = '>= 2.3' - s.add_runtime_dependency 'concurrent-ruby', "~> #{Concurrent::VERSION}" + s.add_runtime_dependency 'concurrent-ruby', "~> #{Concurrent::VERSION.split('.')[0..1].join('.')}" end diff --git a/lib/concurrent-ruby-edge/concurrent/edge/version.rb b/lib/concurrent-ruby-edge/concurrent/edge/version.rb index 4a129936d..26ae15ef6 100644 --- a/lib/concurrent-ruby-edge/concurrent/edge/version.rb +++ b/lib/concurrent-ruby-edge/concurrent/edge/version.rb @@ -1,3 +1,3 @@ module Concurrent - EDGE_VERSION = '0.7.0' + EDGE_VERSION = '0.7.1' end diff --git a/lib/concurrent-ruby/concurrent/utility/processor_counter.rb b/lib/concurrent-ruby/concurrent/utility/processor_counter.rb index e31808722..d5274620e 100644 --- a/lib/concurrent-ruby/concurrent/utility/processor_counter.rb +++ b/lib/concurrent-ruby/concurrent/utility/processor_counter.rb @@ -68,10 +68,20 @@ def compute_physical_processor_count end cores.count when /mswin|mingw/ - require 'win32ole' - result_set = WIN32OLE.connect("winmgmts://").ExecQuery( - "select NumberOfCores from Win32_Processor") - result_set.to_enum.collect(&:NumberOfCores).reduce(:+) + # Get-CimInstance introduced in PowerShell 3 or earlier: https://learn.microsoft.com/en-us/previous-versions/powershell/module/cimcmdlets/get-ciminstance?view=powershell-3.0 + result = run('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object -Property NumberOfCores"') + if !result || $?.exitstatus != 0 + # fallback to deprecated wmic for older systems + result = run("wmic cpu get NumberOfCores") + end + if !result || $?.exitstatus != 0 + # Bail out if both commands returned something unexpected + processor_count + else + # powershell: "\nNumberOfCores\n-------------\n 4\n\n\n" + # wmic: "NumberOfCores \n\n4 \n\n\n\n" + result.scan(/\d+/).map(&:to_i).reduce(:+) + end else processor_count end @@ -81,6 +91,11 @@ def compute_physical_processor_count return 1 end + def run(command) + IO.popen(command, &:read) + rescue Errno::ENOENT + end + def compute_cpu_quota if RbConfig::CONFIG["target_os"].include?("linux") if File.exist?("/sys/fs/cgroup/cpu.max") diff --git a/lib/concurrent-ruby/concurrent/version.rb b/lib/concurrent-ruby/concurrent/version.rb index afa6a4b04..e449c62bc 100644 --- a/lib/concurrent-ruby/concurrent/version.rb +++ b/lib/concurrent-ruby/concurrent/version.rb @@ -1,3 +1,3 @@ module Concurrent - VERSION = '1.3.1' + VERSION = '1.3.2' end diff --git a/spec/concurrent/channel/integration_spec.rb b/spec/concurrent/channel/integration_spec.rb index 01f490dc9..4d4c073ee 100644 --- a/spec/concurrent/channel/integration_spec.rb +++ b/spec/concurrent/channel/integration_spec.rb @@ -68,7 +68,7 @@ end specify 'default-selection.rb' do - skip('flaky') if Concurrent.on_jruby? || Concurrent.on_truffleruby? + skip('flaky') if Concurrent.on_jruby? || Concurrent.on_truffleruby? || Concurrent.on_windows? expected = <<-STDOUT . . diff --git a/spec/concurrent/promises_spec.rb b/spec/concurrent/promises_spec.rb index d89ce309f..2aa88fdfa 100644 --- a/spec/concurrent/promises_spec.rb +++ b/spec/concurrent/promises_spec.rb @@ -758,6 +758,7 @@ def behaves_as_delay(delay, value) describe 'value!' do %w[with without].each do |timeout| it "does not return spuriously #{timeout} timeout" do + skip "SIGHUP not supported" if Concurrent.on_windows? # https://github.com/ruby-concurrency/concurrent-ruby/issues/1015 trapped = false original_handler = Signal.trap(:SIGHUP) { trapped = true }