Skip to content

Commit 0ade8bf

Browse files
Migrate to GitHub Actions
Migrate CI to GitHub actions, including Rubocop. Upgrade Rubocop to ~> 1.0 and address lints
1 parent 7c05956 commit 0ade8bf

33 files changed

+96
-24
lines changed

.github/workflows/ruby.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7+
8+
name: Ruby
9+
10+
on:
11+
push:
12+
branches: [ master ]
13+
pull_request:
14+
branches: [ master ]
15+
16+
jobs:
17+
test:
18+
continue-on-error: ${{ matrix.ruby-version == 'head' }}
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', 'head']
24+
25+
steps:
26+
- uses: actions/checkout@v2.4.0
27+
- name: Install libcurl dev (for ovirt native extensions)
28+
run: sudo apt-get install libcurl4-openssl-dev
29+
- name: Set up Ruby
30+
uses: ruby/setup-ruby@v1
31+
with:
32+
ruby-version: ${{ matrix.ruby-version }}
33+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34+
- name: Install dependencies
35+
run: bundle install
36+
- name: Run tests
37+
run: bundle exec rake
38+
39+
rubocop:
40+
name: Rubocop
41+
runs-on: 'ubuntu-20.04'
42+
steps:
43+
- uses: actions/checkout@v2
44+
- name: Set up Ruby
45+
uses: ruby/setup-ruby@v1
46+
with:
47+
ruby-version: '2.7'
48+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
49+
- name: Run Rubocop
50+
run: bundle exec rubocop

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
33
Style/HashSyntax:
44
EnforcedStyle: hash_rockets
55

6-
Metrics/LineLength:
6+
Layout/LineLength:
77
Max: 100
88
Enabled: false
99

@@ -31,3 +31,4 @@ Gemspec/RequiredRubyVersion:
3131
AllCops:
3232
Exclude:
3333
- 'lib/fog/ovirt/compute.rb'
34+
- 'vendor/**/*'

fog-ovirt.gemspec

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
1616
spec.license = "MIT"
1717

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

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

2929
spec.add_development_dependency "bundler"
30-
spec.add_development_dependency "pry"
3130
spec.add_development_dependency "rake"
32-
spec.add_development_dependency "rubocop", "~> 0.52"
31+
spec.add_development_dependency "rubocop", "~> 1.0"
3332
spec.add_development_dependency "shindo"
3433
end

lib/fog/ovirt/models/compute/interface.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Ovirt
33
class Compute
44
class Interface < Fog::Model
55
attr_accessor :raw
6+
67
identity :id
78

89
attribute :name

lib/fog/ovirt/models/compute/interfaces.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ class Interfaces < Fog::Collection
1111

1212
def all(_filters = {})
1313
requires :vm
14-
if vm.is_a? Fog::Ovirt::Compute::Server
14+
case vm
15+
when Fog::Ovirt::Compute::Server
1516
load service.list_vm_interfaces(vm.id)
16-
elsif vm.is_a? Fog::Ovirt::Compute::Template
17+
when Fog::Ovirt::Compute::Template
1718
load service.list_template_interfaces(vm.id)
1819
else
1920
raise ::Fog::Ovirt::Errors::OvirtError, "interfaces should have vm or template"

lib/fog/ovirt/models/compute/operating_system.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Ovirt
33
class Compute
44
class OperatingSystem < Fog::Model
55
attr_accessor :raw
6+
67
identity :id
78

89
attribute :name

lib/fog/ovirt/models/compute/volume.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Ovirt
33
class Compute
44
class Volume < Fog::Model
55
attr_accessor :raw
6+
67
identity :id
78

89
attribute :storage_domain

lib/fog/ovirt/models/compute/volumes.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ class Volumes < Fog::Collection
1010
attr_accessor :vm
1111

1212
def all(_filters = {})
13-
if vm.is_a? Fog::Ovirt::Compute::Server
13+
case vm
14+
when Fog::Ovirt::Compute::Server
1415
load service.list_vm_volumes(vm.id)
15-
elsif vm.is_a? Fog::Ovirt::Compute::Template
16+
when Fog::Ovirt::Compute::Template
1617
load service.list_template_volumes(vm.id)
1718
else
1819
load service.list_volumes

lib/fog/ovirt/requests/compute/v4/get_api_version.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def api_version
77
"4.0"
88
end
99
end
10+
1011
class Mock
1112
def api_version
1213
"4.0"

lib/fog/ovirt/requests/compute/v4/get_cluster.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def get_cluster(id)
77
ovirt_attrs client.system_service.clusters_service.cluster_service(id).get
88
end
99
end
10+
1011
class Mock
1112
def get_cluster(_id)
1213
xml = read_xml("cluster.xml")

0 commit comments

Comments
 (0)