Skip to content

Commit

Permalink
Add GitHub Actions CI
Browse files Browse the repository at this point in the history
childprocess_spec.rb - skip 'kills the full process tree' on Windows

.gitignore - add vendor/bundle
Delete .travis.yml
Delete appveyor.yml
  • Loading branch information
MSP-Greg authored and sds committed Dec 20, 2023
1 parent 9d387d6 commit 2c91f1b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 85 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI
on: [push, pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ ubuntu, macos, windows ]
ruby: [ 2.6, jruby, truffleruby ]
exclude:
- { os: windows, ruby: truffleruby }
runs-on: ${{ matrix.os }}-latest
env:
CHILDPROCESS_UNSET: should-be-unset
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake spec
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Gemfile.lock
.bundle

## PROJECT::SPECIFIC
vendor/bundle
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

36 changes: 0 additions & 36 deletions appveyor.yml

This file was deleted.

16 changes: 6 additions & 10 deletions lib/childprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class << self
def new(*args)
case os
when :macosx, :linux, :solaris, :bsd, :cygwin, :aix
if jruby? && !posix_spawn_chosen_explicitly?
JRuby::Process.new(args)
elsif posix_spawn?
if posix_spawn?
Unix::PosixSpawnProcess.new(args)
elsif jruby?
JRuby::Process.new(args)
else
Unix::ForkExecProcess.new(*args)
Unix::ForkExecProcess.new(args)
end
when :windows
Windows::Process.new(*args)
Windows::Process.new(args)
else
raise Error, "unsupported platform #{platform_name.inspect}"
end
Expand Down Expand Up @@ -69,12 +69,8 @@ def windows?
os == :windows
end

def posix_spawn_chosen_explicitly?
@posix_spawn || %w[1 true].include?(ENV['CHILDPROCESS_POSIX_SPAWN'])
end

def posix_spawn?
enabled = posix_spawn_chosen_explicitly? || !Process.respond_to?(:fork)
enabled = @posix_spawn || %w[1 true].include?(ENV['CHILDPROCESS_POSIX_SPAWN'])
return false unless enabled

begin
Expand Down
2 changes: 1 addition & 1 deletion lib/childprocess/abstract_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AbstractProcess
# @see ChildProcess.build
#

def initialize(*args)
def initialize(args)
unless args.all? { |e| e.kind_of?(String) }
raise ArgumentError, "all arguments must be String: #{args.inspect}"
end
Expand Down
10 changes: 9 additions & 1 deletion lib/childprocess/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ module Lib
extend FFI::Library

def self.msvcrt_name
RbConfig::CONFIG['RUBY_SO_NAME'][/msvc\w+/] || 'ucrtbase'
host_part = RbConfig::CONFIG['host_os'].split("_")[1]
manifest = File.join(RbConfig::CONFIG['bindir'], 'ruby.exe.manifest')

if host_part && host_part.to_i > 80 && File.exists?(manifest)
"msvcr#{host_part}"
else
"msvcrt"
end
end

ffi_lib "kernel32", msvcrt_name
ffi_convention :stdcall


end # Library
end # Windows
end # ChildProcess
Expand Down
1 change: 1 addition & 0 deletions spec/childprocess_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@
end

it 'kills the full process tree', :process_builder => false do
skip "Windows 'Access is denied failure'?" if ChildProcess.windows?
Tempfile.open('kill-process-tree') do |file|
process = write_pid_in_sleepy_grand_child(file.path)
process.leader = true
Expand Down

0 comments on commit 2c91f1b

Please sign in to comment.