Adjust groups to reduce test dependencies (#1748)

Switch around the groups defined in the Gemfile to allow execution
without installing additional tools that are useful for development but
not needed for testing or packaging.
This commit is contained in:
Darragh Bailey
2023-08-15 12:19:09 +01:00
committed by GitHub
parent 284b52f57c
commit 1ebfacf979
6 changed files with 31 additions and 50 deletions

View File

@@ -13,6 +13,9 @@ jobs:
matrix: ${{ steps.generate-matrix.outputs.matrix }} matrix: ${{ steps.generate-matrix.outputs.matrix }}
env: env:
# skip installing development group gems to save time
BUNDLE_WITHOUT: 'development'
BUNDLE_JOBS: 4
NOKOGIRI_USE_SYSTEM_LIBRARIES: true NOKOGIRI_USE_SYSTEM_LIBRARIES: true
VAGRANT_VERSION: v2.2.14 VAGRANT_VERSION: v2.2.14
@@ -27,20 +30,11 @@ jobs:
libvirt-dev \ libvirt-dev \
libz-dev \ libz-dev \
; ;
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.6.6 ruby-version: 2.6.6
- name: Run bundler using cached path bundler-cache: true
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Generate matrix - name: Generate matrix
id: generate-matrix id: generate-matrix
run: | run: |
@@ -59,6 +53,9 @@ jobs:
test_name: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} test_name: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
env: env:
# skip installing development group gems to save time
BUNDLE_WITHOUT: 'development'
BUNDLE_JOBS: 4
NOKOGIRI_USE_SYSTEM_LIBRARIES: true NOKOGIRI_USE_SYSTEM_LIBRARIES: true
VAGRANT_VERSION: v2.2.14 VAGRANT_VERSION: v2.2.14
@@ -91,26 +88,11 @@ jobs:
# add user to group # add user to group
sudo usermod -a -G libvirt $USER sudo usermod -a -G libvirt $USER
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- uses: actions/cache@v3
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-${{ env.VAGRANT_VERSION }}
restore-keys: |
${{ runner.os }}-
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.6.6 ruby-version: 2.6.6
- name: Run bundler using cached path bundler-cache: true
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Run tests - name: Run tests
run: | run: |
mkdir -p $HOME/.vagrant.d/ mkdir -p $HOME/.vagrant.d/

View File

@@ -25,6 +25,9 @@ jobs:
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.7 ruby-version: 2.7
bundler-cache: true
env:
BUNDLE_GEMFILE: ./docs/Gemfile
- name: Install and Build 🔧 - name: Install and Build 🔧
# don't allow a close to execute anything from the source code # don't allow a close to execute anything from the source code
if: ${{ github.event.action == 'labeled' }} if: ${{ github.event.action == 'labeled' }}
@@ -41,8 +44,7 @@ jobs:
plugin_script_base_path: /${REPO_NAME}/pr-preview/pr-${PR_NUMBER} plugin_script_base_path: /${REPO_NAME}/pr-preview/pr-${PR_NUMBER}
EOF EOF
BUNDLE_GEMFILE=./docs/Gemfile bundle install bundle exec jekyll build --source docs/ --baseurl="/${REPO_NAME}/pr-preview/pr-${PR_NUMBER}" --destination build
BUNDLE_GEMFILE=./docs/Gemfile bundle exec jekyll build --source docs/ --baseurl="/${REPO_NAME}/pr-preview/pr-${PR_NUMBER}" --destination build
- name: Set action - name: Set action
run: | run: |
event_type=$(jq -r ".action" "$GITHUB_EVENT_PATH") event_type=$(jq -r ".action" "$GITHUB_EVENT_PATH")

View File

@@ -63,20 +63,6 @@ jobs:
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@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Set up rubygems
run: |
gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)
gem update bundler --conservative
- name: Ensure bundle uses https instead of insecure git - name: Ensure bundle uses https instead of insecure git
run: | run: |
git config --global url."https://github.com/".insteadOf git://github.com/ git config --global url."https://github.com/".insteadOf git://github.com/
@@ -92,17 +78,22 @@ jobs:
cp .deps/libvirt-ruby/pkg/ruby-libvirt-*.gem vendor/bundle/ruby/3.0.0/cache/ cp .deps/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 # need the following to allow the local provided gem to be used instead of the
# one from rubygems # one from rubygems
bundle config set --local disable_checksum_validation true echo "BUNDLE_DISABLE_CHECKSUM_VALIDATION=true" >> ${GITHUB_ENV}
- name: Run bundler using cached path - name: Set up Ruby
run: | uses: ruby/setup-ruby@v1
bundle config path vendor/bundle with:
bundle install --jobs 4 --retry 3 ruby-version: ${{ matrix.ruby }}
bundler-cache: true
env: env:
# skip installing development group gems to save time
BUNDLE_WITHOUT: 'development'
BUNDLE_JOBS: 4
VAGRANT_VERSION: ${{ matrix.vagrant }} VAGRANT_VERSION: ${{ matrix.vagrant }}
- name: Run tests - name: Run tests
run: | run: |
bundle exec rspec --color --format documentation bundle exec parallel_test spec --type rspec
env: env:
BUNDLE_WITHOUT: 'development'
VAGRANT_VERSION: ${{ matrix.vagrant }} VAGRANT_VERSION: ${{ matrix.vagrant }}
- name: Coveralls Parallel - name: Coveralls Parallel
uses: coverallsapp/github-action@master uses: coverallsapp/github-action@master

View File

@@ -2,7 +2,7 @@
source 'https://rubygems.org' source 'https://rubygems.org'
group :development do group :test do
# We depend on Vagrant for development, but we don't add it as a # We depend on Vagrant for development, but we don't add it as a
# 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`.
@@ -46,10 +46,11 @@ group :plugins do
gemspec gemspec
end end
group :test do group :development do
gem "test-prof", require: false gem "test-prof", require: false
gem "ruby-prof", ">= 0.17.0", require: false gem "ruby-prof", ">= 0.17.0", require: false
gem 'stackprof', '>= 0.2.9', require: false gem 'stackprof', '>= 0.2.9', require: false
gem 'rubocop', require: false
end end
gem 'parallel_tests', group: [:development, :test], require: false gem 'parallel_tests', group: [:development, :test], require: false

View File

@@ -2,6 +2,9 @@
require 'log4r' require 'log4r'
require 'vagrant-libvirt/util/erb_template'
require 'vagrant-libvirt/util/storage_util'
module VagrantPlugins module VagrantPlugins
module ProviderLibvirt module ProviderLibvirt
module Action module Action

View File

@@ -1,5 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'rexml/document'
require_relative '../../spec_helper' require_relative '../../spec_helper'
require 'vagrant-libvirt/util/network_util' require 'vagrant-libvirt/util/network_util'