8000 Migrate to GitHub Actions by petergoldstein · Pull Request #103 · fog/fog-ovirt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Migrate to GitHub Actions #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
continue-on-error: ${{ matrix.ruby-version == 'head' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', 'head']

steps:
- uses: actions/checkout@v3
- name: Install libcurl dev (for ovirt native extensions)
run: sudo apt-get install libcurl4-openssl-dev
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Install dependencies
run: bundle install
- name: Run tests
run: bundle exec rake

rubocop:
name: Rubocop
runs-on: 'ubuntu-20.04'
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run Rubocop
run: bundle exec rubocop
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
Style/HashSyntax:
EnforcedStyle: hash_rockets

Metrics/LineLength:
Layout/LineLength:
Max: 100
Enabled: false

Expand Down Expand Up @@ -31,3 +31,4 @@ Gemspec/RequiredRubyVersion:
AllCops:
Exclude:
- 'lib/fog/ovirt/compute.rb'
- 'vendor/**/*'
5 changes: 2 additions & 3 deletions fog-ovirt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.license = "MIT"

spec.files = `git ls-files -z`.split("\x0")
spec.test_files = spec.files.grep(%r{^tests\/})
spec.test_files = spec.files.grep(%r{^tests/})
spec.require_paths = ["lib"]
spec.required_ruby_version = ">= 2.0.0"

Expand All @@ -27,8 +27,7 @@ Gem::Specification.new do |spec|
spec.add_dependency("ovirt-engine-sdk", ">= 4.3.1")

spec.add_development_dependency "bundler"
spec.add_development_dependency "pry"
spec.add_development_dependency "rake"
spec.add_development_dependency "rubocop", "~> 0.52"
spec.add_development_dependency "rubocop", "~> 1.0"
spec.add_development_dependency "shindo"
end
1 change: 1 addition & 0 deletions lib/fog/ovirt/models/compute/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Ovirt
class Compute
class Interface < Fog::Model
attr_accessor :raw

identity :id

attribute :name
Expand Down
5 changes: 3 additions & 2 deletions lib/fog/ovirt/models/compute/interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ class Interfaces < Fog::Collection

def all(_filters = {})
requires :vm
if vm.is_a? Fog::Ovirt::Compute::Server
9E7A case vm
when Fog::Ovirt::Compute::Server
load service.list_vm_interfaces(vm.id)
elsif vm.is_a? Fog::Ovirt::Compute::Template
when Fog::Ovirt::Compute::Template
load service.list_template_interfaces(vm.id)
else
raise ::Fog::Ovirt::Errors::OvirtError, "interfaces should have vm or template"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/models/compute/operating_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Ovirt
class Compute
class OperatingSystem < Fog::Model
attr_accessor :raw

identity :id

attribute :name
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/models/compute/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Ovirt
class Compute
class Volume < Fog::Model
attr_accessor :raw

identity :id

attribute :storage_domain
Expand Down
5 changes: 3 additions & 2 deletions lib/fog/ovirt/models/compute/volumes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ class Volumes < Fog::Collection
attr_accessor :vm

def all(_filters = {})
if vm.is_a? Fog::Ovirt::Compute::Server
case vm
when Fog::Ovirt::Compute::Server
load service.list_vm_volumes(vm.id)
elsif vm.is_a? Fog::Ovirt::Compute::Template
when Fog::Ovirt::Compute::Template
load service.list_template_volumes(vm.id)
else
load service.list_volumes
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/get_api_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def api_version
"4.0"
end
end

class Mock
def api_version
"4.0"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/get_cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def get_cluster(id)
ovirt_attrs client.system_service.clusters_service.cluster_service(id).get
end
end

class Mock
def get_cluster(_id)
xml = read_xml("cluster.xml")
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/get_instance_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def get_instance_type(id)
ovirt_attrs client.system_service.instance_types_service.instance_type_service(id).get
end
end

class Mock
def get_instance_type(_id)
xml = read_xml "instance_type.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/get_quota.rb
Original file line number Diff line number Diff line 46CA change
Expand Up @@ -8,6 +8,7 @@ def get_quota(id)
ovirt_attrs quota
end
end

class Mock
def get_quota(_id)
xml = read_xml("quota.xml")
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/get_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def get_template(id)
ovirt_attrs client.system_service.templates_service.template_service(id).get
end
end

class Mock
def get_template(_id)
xml = read_xml "template.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/get_virtual_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def get_virtual_machine(id)
ovirt_attrs client.system_service.vms_service.vm_service(id).get(:all_content => true)
end
end

class Mock
def get_virtual_machine(_id)
xml = read_xml "vm.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/get_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def get_volume(id)
ovirt_attrs client.system_service.disks_service.disk_service(id).get
end
end

class Mock
def get_volume(_id)
xml = read_xml("disk.xml")
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_clusters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def list_clusters(opts = {})
client.system_service.clusters_service.list(opts).map { |ovirt_obj| ovirt_attrs(ovirt_obj) }
end
end

class Mock
def list_clusters(_filters = {})
xml = read_xml "clusters.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_instance_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def list_instance_types(filters = {})
client.system_service.instance_types_service.list(filters).map { |ovirt_obj| ovirt_attrs ovirt_obj }
end
end

class Mock
def list_instance_types(_filters = {})
xml = read_xml "instance_types.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_networks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def list_networks(cluster_id)
client.system_service.clusters_service.cluster_service(cluster_id).networks_service.list
end
end

class Mock
def list_networks(_cluster_id)
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def list_operating_systems
client.system_service.operating_systems_service.list.map { |ovirt_obj| ovirt_attrs ovirt_obj }
end
end

class Mock
def list_operating_systems
xml = read_xml "operating_systems.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_quotas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def list_quotas(filters = {})
data_center.quotas_service.list(filters).map { |ovirt_obj| ovirt_attrs ovirt_obj }
end
end

class Mock
def list_quotas(_filters = {})
xml = read_xml "quotas.xml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def list_template_interfaces(vm_id)
client.system_service.templates_service.template_service(vm_id).nics_service.list.map { |ovirt_obj| ovirt_attrs ovirt_obj }
end
end

class Mock
def list_template_interfaces(_vm_id)
xml = read_xml "nics.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def list_template_volumes(template_id)
end
end
end

class Mock
def list_template_volumes(_template_id)
xml = read_xml "volumes.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def list_templates(filters = {})
client.system_service.templates_service.list(filters).map { |ovirt_obj| ovirt_attrs ovirt_obj }
end
end

class Mock
def list_templates(_filters = {})
xml = read_xml "templates.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_virtual_machines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def list_virtual_machines(filters = {})
client.system_service.vms_service.list(filters).map { |ovirt_obj| ovirt_attrs ovirt_obj }
end
end

class Mock
def list_virtual_machines(_filters = {})
xml = read_xml "vms.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_vm_interfaces.rb 97AE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def list_vm_interfaces(vm_id)
client.system_service.vms_service.vm_service(vm_id).nics_service.list.map { |ovirt_obj| ovirt_attrs ovirt_obj }
end
end

class Mock
def list_vm_interfaces(_vm_id)
xml = read_xml "nics.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_vm_volumes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def list_vm_volumes(vm_id)
end
end
end

class Mock
def list_vm_volumes(_vm_id)
xml = read_xml "volumes.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_vnic_profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def list_vnic_profiles(_opts = {})
dc_vnics
end
end

class Mock
def list_vnic_profiles(_filters = {})
xml = read_xml "vnic_profiles.xml"
Expand Down
1 change: 1 addition & 0 deletions lib/fog/ovirt/requests/compute/v4/list_volumes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def list_volumes
client.system_service.disks_service.list.map { |ovirt_obj| ovirt_attrs ovirt_obj }
end
end

class Mock
def list_volumes
xml = read_xml "disks.xml"
Expand Down
5 changes: 3 additions & 2 deletions tests/helpers/succeeds_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module Shindo
class Tests
def succeeds
def succeeds(&block)
test("succeeds") do
!!instance_eval(&Proc.new)
p = block_given? ? block : proc {}
!!instance_eval(&p)
end
end
end
Expand Down
16 changes: 6 additions & 10 deletions tests/ovirt/requests/compute/v4/client_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ def @client_mock.foo
end

tests("The exception test is as expected").returns(true) do
begin
@object_under_test.foo
rescue Fog::Ovirt::Errors::OvirtEngineError => e
e.message == "Ovirt client returned an error: Test"
end
@object_under_test.foo
rescue Fog::Ovirt::Errors::OvirtEngineError => e
e.message == "Ovirt client returned an error: Test"
end

tests("The original exception test is as expected").returns(true) do
begin
@object_under_test.foo
rescue Fog::Ovirt::Errors::OvirtEngineError => e
e.orig_exception.message == "Test"
end
@object_under_test.foo
rescue Fog::Ovirt::Errors::OvirtEngineError => e
e.orig_exception.message == "Test"
end
end
4 changes: 2 additions & 2 deletions tests/ovirt/requests/compute/v4/create_vm_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
name_base = Time.now.to_i

tests("Create VM") do
response = compute.create_vm(:name => "fog-" + name_base.to_s, :cluster_name => "Default")
response = compute.create_vm(:name => "fog-#{name_base}", :cluster_name => "Default")
test("should be a kind of OvirtSDK4::Vm") { response.is_a? OvirtSDK4::Vm }
test("should be a 'OvirtSDK4::VmType::SERVER' VM type by default") { response.type == OvirtSDK4::VmType::SERVER }
end

tests("Create VM from template (clone)") do
response = compute.create_vm(:name => "fog-" + (name_base + 1).to_s, :template_name => "hwp_small", :cluster_name => "Default")
response = compute.create_vm(:name => "fog-#{name_base + 1}", :template_name => "hwp_small", :cluster_name => "Default")
test("should be a kind of OvirtSDK4::Vm") { response.is_a? OvirtSDK4::Vm }
end

Expand Down
2 changes: 1 addition & 1 deletion tests/ovirt/requests/compute/v4/destroy_vm_tests.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Shindo.tests("Fog::Ovirt::Compute v4 | vm_destroy request", ["ovirt"]) do
compute = Fog::Ovirt::Compute.new(:api_version => "v4")
compute.create_vm(:name => "fog-" + Time.now.to_i.to_s, :cluster_name => "Default") if compute.servers.all(:search => "fog-*").empty?
compute.create_vm(:name => "fog-#{Time.now.to_i}", :cluster_name => "Default") if compute.servers.all(:search => "fog-*").empty?
vm_id = compute.servers.all(:search => "fog-*").last.id

tests("The response should") do
Expand Down
2 changes: 1 addition & 1 deletion tests/ovirt/requests/compute/v4/update_volume_tests.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Shindo.tests("Fog::Ovirt::Compute.new v4 | update_volume request", ["ovirt"]) do
compute = Fog::Compute.new(:provider => :ovirt, :api_version => "v4")
compute.create_vm(:name => "fog-" + Time.now.to_i.to_s, :cluster_name => "Default") if compute.servers.all(:search => "fog-*").empty?
compute.create_vm(:name => "fog-#{Time.now.to_i}", :cluster_name => "Default") if compute.servers.all(:search => "fog-*").empty?
vm_id = compute.servers.all(:search => "fog-*").last

tests("The expected options") do
Expand Down
0