diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..834d62b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,124 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + ubuntu: + name: Ubuntu + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + ruby: + - "3.0" + - "2.7" + - "2.6" + - "2.5" + - "2.4" + - "2.3" + - debug + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + + - run: rake build + + - name: Install irb for old Ruby + if: | + matrix.ruby == '2.5' || + matrix.ruby == '2.4' || + matrix.ruby == '2.3' + run: | + cat < Gemfile.irb + source 'https://rubygems.org' + gem 'irb' + GEMFILE + BUNDLE_GEMFILE=Gemfile.irb bundle install --jobs 4 --retry 3 + + - run: gem install pkg/*.gem + + - run: ruby -r iruby -e "p IRuby::SessionAdapter.select_adapter_class" + env: + IRUBY_SESSION_ADAPTER: ffi-rzmq + + - name: Install requirements on ubuntu + run: | + sudo apt update + sudo apt install -y --no-install-recommends \ + libczmq-dev \ + python3 \ + python3-pip \ + python3-setuptools + sudo pip3 install wheel + sudo pip3 install -r ci/requirements.txt + + - run: bundle install --jobs 4 --retry 3 + + - name: Run tests + env: + PYTHON: python3 + ADAPTERS: cztop ffi-rzmq pyzmq + run: | + for adapter in $ADAPTERS; do + export IRUBY_TEST_SESSION_ADAPTER_NAME=$adapter + bundle exec rake test TESTOPTS=-v + done + + windows: + name: Windows + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.0" + + - run: rake build + + - run: gem install pkg/*.gem + + - run: ruby -r iruby -e "p IRuby::SessionAdapter.select_adapter_class" + env: + IRUBY_SESSION_ADAPTER: ffi-rzmq + + macos: + name: macOS + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.0" + + - run: rake build + + - run: gem install pkg/*.gem + + - run: ruby -r iruby -e "p IRuby::SessionAdapter.select_adapter_class" + env: + IRUBY_SESSION_ADAPTER: ffi-rzmq diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml deleted file mode 100644 index e138c66..0000000 --- a/.github/workflows/ubuntu.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: CI - -on: - push: - branches: - - master - pull_request: - types: - - opened - - synchronize - - reopened - -jobs: - test: - name: Test - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: - - ubuntu-20.04 - - ubuntu-latest - ruby: - - 3.0 - - 2.7 - - 2.6 - - 2.5 - - 2.4 - - 2.3 - - debug - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - - - name: Install requirements on ubuntu - run: | - sudo apt update - sudo apt install -y --no-install-recommends \ - libczmq-dev \ - python3 \ - python3-pip \ - python3-setuptools - sudo pip3 install wheel - sudo pip3 install -r ci/requirements.txt - - - run: gem install bundler - - - run: bundle install --jobs 4 --retry 3 - - - name: Run tests - env: - PYTHON: python3 - ADAPTERS: cztop ffi-rzmq pyzmq - run: | - for adapter in $ADAPTERS; do - export IRUBY_TEST_SESSION_ADAPTER_NAME=$adapter - bundle exec rake test TESTOPTS=-v - done - - - run: rake build - - - run: gem install pkg/*.gem diff --git a/ext/Rakefile b/ext/Rakefile new file mode 100644 index 0000000..1a3f516 --- /dev/null +++ b/ext/Rakefile @@ -0,0 +1,19 @@ +task default: :all + +task all: [:ensure_zeromq] + +task :ensure_zeromq do + begin + require 'ffi-rzmq' + rescue LoadError + require 'native-package-installer' + unless NativePackageInstaller.install(arch_linux: 'zeromq', + debian: 'libzmq3-dev', + freebsd: 'libzmq4', + homebrew: 'zmq', + macports: 'zmq', + redhat: 'zeromq-devel') + raise 'Failed to install ZeroMQ' + end + end +end diff --git a/iruby.gemspec b/iruby.gemspec index 467300c..cb73f28 100644 --- a/iruby.gemspec +++ b/iruby.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } s.test_files = s.files.grep(%r{^test/}) s.require_paths = %w[lib] + s.extensions = %w[ext/Rakefile] s.required_ruby_version = '>= 2.3.0' @@ -22,9 +23,12 @@ Gem::Specification.new do |s| s.add_dependency 'irb' s.add_dependency 'mime-types', '>= 3.3.1' s.add_dependency 'multi_json', '~> 1.11' + s.add_dependency 'native-package-installer' s.add_development_dependency 'pycall', '>= 1.2.1' s.add_development_dependency 'rake' s.add_development_dependency 'test-unit' s.add_development_dependency 'test-unit-rr' + + s.metadata['msys2_mingw_dependencies'] = 'zeromq' end