Skip to content

Commit b52dfc6

Browse files
authored
Merge pull request #308 from kou/native-package-auto-install
Add support for native package auto install
2 parents d483f18 + f82ddfa commit b52dfc6

File tree

4 files changed

+147
-69
lines changed

4 files changed

+147
-69
lines changed

.github/workflows/ci.yml

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
13+
jobs:
14+
ubuntu:
15+
name: Ubuntu
16+
runs-on: ${{ matrix.os }}
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os:
22+
- ubuntu-latest
23+
ruby:
24+
- "3.0"
25+
- "2.7"
26+
- "2.6"
27+
- "2.5"
28+
- "2.4"
29+
- "2.3"
30+
- debug
31+
32+
steps:
33+
- uses: actions/checkout@v2
34+
with:
35+
fetch-depth: 1
36+
37+
- uses: ruby/setup-ruby@v1
38+
with:
39+
ruby-version: ${{ matrix.ruby }}
40+
41+
- run: rake build
42+
43+
- name: Install irb for old Ruby
44+
if: |
45+
matrix.ruby == '2.5' ||
46+
matrix.ruby == '2.4' ||
47+
matrix.ruby == '2.3'
48+
run: |
49+
cat <<GEMFILE > Gemfile.irb
50+
source 'https://rubygems.org'
51+
gem 'irb'
52+
GEMFILE
53+
BUNDLE_GEMFILE=Gemfile.irb bundle install --jobs 4 --retry 3
54+
55+
- run: gem install pkg/*.gem
56+
57+
- run: ruby -r iruby -e "p IRuby::SessionAdapter.select_adapter_class"
58+
env:
59+
IRUBY_SESSION_ADAPTER: ffi-rzmq
60+
61+
- name: Install requirements on ubuntu
62+
run: |
63+
sudo apt update
64+
sudo apt install -y --no-install-recommends \
65+
libczmq-dev \
66+
python3 \
67+
python3-pip \
68+
python3-setuptools
69+
sudo pip3 install wheel
70+
sudo pip3 install -r ci/requirements.txt
71+
72+
- run: bundle install --jobs 4 --retry 3
73+
74+
- name: Run tests
75+
env:
76+
PYTHON: python3
77+
ADAPTERS: cztop ffi-rzmq pyzmq
78+
run: |
79+
for adapter in $ADAPTERS; do
80+
export IRUBY_TEST_SESSION_ADAPTER_NAME=$adapter
81+
bundle exec rake test TESTOPTS=-v
82+
done
83+
84+
windows:
85+
name: Windows
86+
runs-on: windows-latest
87+
88+
steps:
89+
- uses: actions/checkout@v2
90+
with:
91+
fetch-depth: 1
92+
93+
- uses: ruby/setup-ruby@v1
94+
with:
95+
ruby-version: "3.0"
96+
97+
- run: rake build
98+
99+
- run: gem install pkg/*.gem
100+
101+
- run: ruby -r iruby -e "p IRuby::SessionAdapter.select_adapter_class"
102+
env:
103+
IRUBY_SESSION_ADAPTER: ffi-rzmq
104+
105+
macos:
106+
name: macOS
107+
runs-on: macos-latest
108+
109+
steps:
110+
- uses: actions/checkout@v2
111+
with:
112+
fetch-depth: 1
113+
114+
- uses: ruby/setup-ruby@v1
115+
with:
116+
ruby-version: "3.0"
117+
118+
- run: rake build
119+
120+
- run: gem install pkg/*.gem
121+
122+
- run: ruby -r iruby -e "p IRuby::SessionAdapter.select_adapter_class"
123+
env:
124+
IRUBY_SESSION_ADAPTER: ffi-rzmq

.github/workflows/ubuntu.yml

-69
This file was deleted.

ext/Rakefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
task default: :all
2+
3+
task all: [:ensure_zeromq]
4+
5+
task :ensure_zeromq do
6+
begin
7+
require 'ffi-rzmq'
8+
rescue LoadError
9+
require 'native-package-installer'
10+
unless NativePackageInstaller.install(arch_linux: 'zeromq',
11+
debian: 'libzmq3-dev',
12+
freebsd: 'libzmq4',
13+
homebrew: 'zmq',
14+
macports: 'zmq',
15+
redhat: 'zeromq-devel')
16+
raise 'Failed to install ZeroMQ'
17+
end
18+
end
19+
end

iruby.gemspec

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
1414
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
1515
s.test_files = s.files.grep(%r{^test/})
1616
s.require_paths = %w[lib]
17+
s.extensions = %w[ext/Rakefile]
1718

1819
s.required_ruby_version = '>= 2.3.0'
1920

@@ -22,9 +23,12 @@ Gem::Specification.new do |s|
2223
s.add_dependency 'irb'
2324
s.add_dependency 'mime-types', '>= 3.3.1'
2425
s.add_dependency 'multi_json', '~> 1.11'
26+
s.add_dependency 'native-package-installer'
2527

2628
s.add_development_dependency 'pycall', '>= 1.2.1'
2729
s.add_development_dependency 'rake'
2830
s.add_development_dependency 'test-unit'
2931
s.add_development_dependency 'test-unit-rr'
32+
33+
s.metadata['msys2_mingw_dependencies'] = 'zeromq'
3034
end

0 commit comments

Comments
 (0)