Support testing against ruby 3.0 (#1243)

Retrieve vagrant and ruby-libvirt dependencies and modify as needed to
allow testing against ruby 3.0 until released versions support.

Use conditionals to skip steps when not needed.

Note that in order to use the locally built gem added to the cache
manually, need to disable checksums. However as all other ruby
versions will continue to use it, shouldn't be an issue as long as the
cache for ruby 3.0.0 is wiped clean before being used for anything such
as publishing.

Fixes: #1244
This commit is contained in:
Darragh Bailey
2021-04-07 19:41:28 +01:00
committed by GitHub
parent 8f65aec9eb
commit fbf026aeaa
2 changed files with 55 additions and 5 deletions

View File

@@ -39,17 +39,35 @@ jobs:
- ruby: 2.6.6 - ruby: 2.6.6
vagrant: v2.2.14 vagrant: v2.2.14
allow_fail: false allow_fail: false
# TODO: We should add ruby 3.0, once vagrant can be tested with it. - ruby: 3.0.0
vagrant:
allow_fail: false
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with:
path: vagrant-libvirt
- name: Clone vagrant for ruby 3.0 support
if: ${{ matrix.ruby == '3.0.0' }}
uses: actions/checkout@v2
with:
repository: hashicorp/vagrant
path: vagrant
ref: f7973f00edb9438d0b36085f210c80af71cfe5c5
- name: Clone ruby-libvirt for ruby 3.0 support
if: ${{ matrix.ruby == '3.0.0' }}
uses: actions/checkout@v2
with:
repository: libvirt/libvirt-ruby
path: libvirt-ruby
ref: 43444be184e4d877c5ce110ee5475c952d7590f7
- name: Set up libvirt - name: Set up libvirt
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install libvirt-dev sudo apt-get install libvirt-dev
- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:
path: vendor/bundle path: vagrant-libvirt/vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-gems- ${{ runner.os }}-gems-
@@ -61,15 +79,41 @@ jobs:
run: | run: |
gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems) gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)
gem update bundler --conservative gem update bundler --conservative
working-directory: vagrant-libvirt
- name: Handle additional ruby 3.0 setup
if: ${{ matrix.ruby == '3.0.0' }}
run: |
# ensure vagrant gemspec allows ruby 3.0
pushd ../vagrant/
# ensure main branch exists
git checkout -b main
sed -i -e 's@s.required_ruby_version.*=.*@s.required_ruby_version = "~> 3.0"@' vagrant.gemspec
popd
bundle config local.vagrant ${PWD}/../vagrant/
# build gem of latest bindings that contain fix for ruby include path
pushd ../libvirt-ruby
rake gem
popd
mkdir -p vendor/bundle/ruby/3.0.0/cache/
cp ../libvirt-ruby/pkg/ruby-libvirt-*.gem vendor/bundle/ruby/3.0.0/cache/
# need the following to allow the local provided gem to be used instead of the
# one from rubygems
bundle config set --local disable_checksum_validation true
working-directory: vagrant-libvirt
- name: Run bundler using cached path - name: Run bundler using cached path
run: | run: |
bundle config path vendor/bundle bundle config path vendor/bundle
bundle install --jobs 4 --retry 3 bundle install --jobs 4 --retry 3
working-directory: vagrant-libvirt
env: env:
VAGRANT_VERSION: ${{ matrix.vagrant }} VAGRANT_VERSION: ${{ matrix.vagrant }}
- name: Run tests - name: Run tests
run: | run: |
bundle exec rspec --color --format documentation bundle exec rspec --color --format documentation
working-directory: vagrant-libvirt
env: env:
VAGRANT_VERSION: ${{ matrix.vagrant }} VAGRANT_VERSION: ${{ matrix.vagrant }}
- name: Coveralls Parallel - name: Coveralls Parallel
@@ -77,6 +121,7 @@ jobs:
with: with:
github-token: ${{ secrets.github_token }} github-token: ${{ secrets.github_token }}
parallel: true parallel: true
path-to-lcov: ./vagrant-libvirt/coverage/lcov.info
finish: finish:

11
Gemfile
View File

@@ -8,11 +8,12 @@ group :development do
# gem dependency because we expect to be installed within the # gem dependency because we expect to be installed within the
# Vagrant environment itself using `vagrant plugin`. # Vagrant environment itself using `vagrant plugin`.
vagrant_version = ENV['VAGRANT_VERSION'] vagrant_version = ENV['VAGRANT_VERSION']
if vagrant_version if !vagrant_version.nil? && !vagrant_version.empty?
gem 'vagrant', :git => 'https://github.com/hashicorp/vagrant.git', gem 'vagrant', :git => 'https://github.com/hashicorp/vagrant.git',
tag: vagrant_version :ref => vagrant_version
else else
gem 'vagrant', :git => 'https://github.com/hashicorp/vagrant.git' gem 'vagrant', :git => 'https://github.com/hashicorp/vagrant.git',
:branch => 'main'
end end
begin begin
@@ -30,6 +31,10 @@ group :development do
gem 'vagrant-spec', :github => 'hashicorp/vagrant-spec', :branch => "main" gem 'vagrant-spec', :github => 'hashicorp/vagrant-spec', :branch => "main"
end end
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
gem 'rexml'
end
gem 'pry' gem 'pry'
end end