From c4a9b064abdb4664c5c28ff26285e1ed5c61e1d3 Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Thu, 17 Sep 2020 17:05:38 -0400 Subject: [PATCH] Plugin Generator Updates --- .codeclimate.yml | 59 +++++++++++-------------- .gitignore | 5 ++- .rubocop.yml | 1 - .rubocop_cc.yml | 1 - .travis.yml | 12 +---- README.md | 11 +++-- Rakefile | 2 +- bin/ci/after_script | 3 ++ bundler.d/.keep | 0 lib/manageiq-providers-vmware.rb | 3 ++ lib/manageiq/providers/vmware.rb | 3 -- lib/manageiq/providers/vmware/engine.rb | 2 + lib/tasks/README.md | 20 +++++++-- lib/tasks_private/spec.rake | 5 +-- manageiq-providers-vmware.gemspec | 40 +++++++++-------- spec/spec_helper.rb | 8 ++-- 16 files changed, 91 insertions(+), 84 deletions(-) create mode 100755 bin/ci/after_script create mode 100644 bundler.d/.keep diff --git a/.codeclimate.yml b/.codeclimate.yml index cb8338c6b..a57cd7575 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,44 +1,37 @@ --- -exclude_paths: -- ".git/" -- "**.xml" -- "**.yaml" -- "**.yml" -- locale/ -- spec/ -- tools/ -engines: - brakeman: +version: '2' +prepare: + fetch: + - url: https://raw.githubusercontent.com/ManageIQ/guides/master/.rubocop_base.yml + path: ".rubocop_base.yml" + - url: https://raw.githubusercontent.com/ManageIQ/guides/master/.rubocop_cc_base.yml + path: ".rubocop_cc_base.yml" +checks: + argument-count: enabled: false - bundler-audit: + complex-logic: enabled: false - csslint: + file-lines: enabled: false - duplication: - enabled: true + method-complexity: config: - languages: - - ruby - - javascript - eslint: + threshold: 11 + method-count: enabled: false - channel: eslint-3 - fixme: + method-lines: enabled: false - markdownlint: + nested-control-flow: enabled: false + return-statements: + enabled: false +plugins: rubocop: enabled: true config: ".rubocop_cc.yml" - channel: rubocop-0-69 -prepare: - fetch: - - url: https://raw.githubusercontent.com/ManageIQ/guides/master/.rubocop_base.yml - path: ".rubocop_base.yml" - - url: https://raw.githubusercontent.com/ManageIQ/guides/master/.rubocop_cc_base.yml - path: ".rubocop_cc_base.yml" -ratings: - paths: - - Gemfile.lock - - "**.rake" - - "**.rb" + channel: 'rubocop-0-69' +exclude_patterns: +- node_modules/ +- spec/ +- test/ +- tmp/ +- vendor/ diff --git a/.gitignore b/.gitignore index 182eeb079..c8d2d18b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.rubocop-* /.bundle/ /.yardoc /Gemfile.lock @@ -9,8 +8,10 @@ /spec/reports/ /tmp/ +.rubocop-* +/bundler.d/* +!/bundler.d/.keep /config/settings.local.yml /config/settings/*.local.yml /config/environments/*.local.yml - /spec/manageiq diff --git a/.rubocop.yml b/.rubocop.yml index 4c9381b2e..ac92639e7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,3 @@ inherit_from: - https://raw.githubusercontent.com/ManageIQ/guides/master/.rubocop_base.yml -# put all local rubocop config into .rubocop_local.yml as it will be loaded by .rubocop_cc.yml as well - .rubocop_local.yml diff --git a/.rubocop_cc.yml b/.rubocop_cc.yml index ff96a0cba..f613872a6 100644 --- a/.rubocop_cc.yml +++ b/.rubocop_cc.yml @@ -1,5 +1,4 @@ inherit_from: -# this is downloaded by .codeclimate.yml - .rubocop_base.yml - .rubocop_cc_base.yml - .rubocop_local.yml diff --git a/.travis.yml b/.travis.yml index 3ac9d99ee..e8d9a03e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,9 @@ ---- -dist: xenial language: ruby +cache: bundler rvm: - 2.5.7 - 2.6.5 -sudo: false -cache: bundler -env: - global: - - RUBY_GC_HEAP_GROWTH_MAX_SLOTS=300000 - - RUBY_GC_HEAP_INIT_SLOTS=600000 - - RUBY_GC_HEAP_GROWTH_FACTOR=1.25 addons: postgresql: '10' install: bin/setup -after_script: bundle exec codeclimate-test-reporter +after_script: bin/ci/after_script diff --git a/README.md b/README.md index dc7b0ce17..4efc2c62b 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,17 @@ -# manageiq-providers-vmware +# ManageIQ::Providers::Vmware -[![Gem Version](https://badge.fury.io/rb/manageiq-providers-vmware.svg)](http://badge.fury.io/rb/manageiq-providers-vmware) [![Build Status](https://travis-ci.com/ManageIQ/manageiq-providers-vmware.svg?branch=master)](https://travis-ci.com/ManageIQ/manageiq-providers-vmware) -[![Code Climate](https://codeclimate.com/github/ManageIQ/manageiq-providers-vmware.svg)](https://codeclimate.com/github/ManageIQ/manageiq-providers-vmware) -[![Test Coverage](https://codeclimate.com/github/ManageIQ/manageiq-providers-vmware/badges/coverage.svg)](https://codeclimate.com/github/ManageIQ/manageiq-providers-vmware/coverage) +[![Maintainability](https://api.codeclimate.com/v1/badges/73bf62adcd9632fd9c7d/maintainability)](https://codeclimate.com/github/ManageIQ/manageiq-providers-vmware/maintainability) +[![Test Coverage](https://api.codeclimate.com/v1/badges/73bf62adcd9632fd9c7d/test_coverage)](https://codeclimate.com/github/ManageIQ/manageiq-providers-vmware/test_coverage) [![Security](https://hakiri.io/github/ManageIQ/manageiq-providers-vmware/master.svg)](https://hakiri.io/github/ManageIQ/manageiq-providers-vmware/master) [![Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ManageIQ/manageiq-providers-vmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -ManageIQ plugin for the Vmware provider. +ManageIQ plugin for the VMware provider. ## Development -See the section on pluggable providers in the [ManageIQ Developer Setup](http://manageiq.org/docs/guides/developer_setup) +See the section on plugins in the [ManageIQ Developer Setup](http://manageiq.org/docs/guides/developer_setup/plugins) For quick local setup run `bin/setup`, which will clone the core ManageIQ repository under the *spec* directory and setup necessary config files. If you have already cloned it, you can run `bin/update` to bring the core ManageIQ code up to date. diff --git a/Rakefile b/Rakefile index 452f0b473..600a8cfd0 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ require 'bundler/setup' begin require 'rspec/core/rake_task' - APP_RAKEFILE = File.expand_path("../spec/manageiq/Rakefile", __FILE__) + APP_RAKEFILE = File.expand_path("spec/manageiq/Rakefile", __dir__) load 'rails/tasks/engine.rake' load 'rails/tasks/statistics.rake' rescue LoadError diff --git a/bin/ci/after_script b/bin/ci/after_script new file mode 100755 index 000000000..c2a335bcc --- /dev/null +++ b/bin/ci/after_script @@ -0,0 +1,3 @@ +#!/bin/bash + +./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/bundler.d/.keep b/bundler.d/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/lib/manageiq-providers-vmware.rb b/lib/manageiq-providers-vmware.rb index 4cbb0ace0..0a2b54bfe 100644 --- a/lib/manageiq-providers-vmware.rb +++ b/lib/manageiq-providers-vmware.rb @@ -1 +1,4 @@ +require "manageiq/providers/vmware/engine" +require "manageiq/providers/vmware/version" + require "manageiq/providers/vmware" diff --git a/lib/manageiq/providers/vmware.rb b/lib/manageiq/providers/vmware.rb index 426f17660..bf4e72496 100644 --- a/lib/manageiq/providers/vmware.rb +++ b/lib/manageiq/providers/vmware.rb @@ -1,6 +1,3 @@ -require "manageiq/providers/vmware/engine" -require "manageiq/providers/vmware/version" - module ManageIQ module Providers module Vmware diff --git a/lib/manageiq/providers/vmware/engine.rb b/lib/manageiq/providers/vmware/engine.rb index 7308be1ca..eafe058f1 100644 --- a/lib/manageiq/providers/vmware/engine.rb +++ b/lib/manageiq/providers/vmware/engine.rb @@ -4,6 +4,8 @@ module Vmware class Engine < ::Rails::Engine isolate_namespace ManageIQ::Providers::Vmware + config.autoload_paths << root.join('lib').to_s + def self.vmdb_plugin? true end diff --git a/lib/tasks/README.md b/lib/tasks/README.md index 0d36d3ebb..c1045673c 100644 --- a/lib/tasks/README.md +++ b/lib/tasks/README.md @@ -1,6 +1,20 @@ -Tasks (.rake files) in this directory will be available in the main ManageIQ app. -They can be executed in the provider gem via the app: namespace +Tasks (.rake files) in this directory will be available as public tasks in the main +ManageIQ app. They can be executed in the plugin gem via the app: namespace +```shell bin/rails app: +``` -Task private to the provider should go into lib/tasks/tasks_private. +Since these tasks are public, please namespace them, as in the following example: + +```ruby +namespace "manageiq:providers:vmware" do + desc "Explaining what the task does" + task :your_task do + # Task goes here + end +end +``` + +Tasks places in the lib/tasks_private directory will be private to the plugin +and not available in the ManageIQ app. diff --git a/lib/tasks_private/spec.rake b/lib/tasks_private/spec.rake index 93aea1317..8b78c5c93 100644 --- a/lib/tasks_private/spec.rake +++ b/lib/tasks_private/spec.rake @@ -4,7 +4,6 @@ namespace :spec do end desc "Run all specs" -RSpec::Core::RakeTask.new(:spec => ["app:test:initialize", "app:evm:compile_sti_loader", "app:test:providers_common"]) do |t| - spec_dir = File.expand_path("../../spec", __dir__) - EvmTestHelper.init_rspec_task(t, ['--require', File.join(spec_dir, 'spec_helper')]) +RSpec::Core::RakeTask.new(:spec => ['app:test:spec_deps', 'app:test:providers_common']) do |t| + EvmTestHelper.init_rspec_task(t) end diff --git a/manageiq-providers-vmware.gemspec b/manageiq-providers-vmware.gemspec index 416d3685e..e22f0342b 100644 --- a/manageiq-providers-vmware.gemspec +++ b/manageiq-providers-vmware.gemspec @@ -1,24 +1,28 @@ -$:.push File.expand_path("../lib", __FILE__) +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'manageiq/providers/vmware/version' -require "manageiq/providers/vmware/version" +Gem::Specification.new do |spec| + spec.name = "manageiq-providers-vmware" + spec.version = ManageIQ::Providers::Vmware::VERSION + spec.authors = ["ManageIQ Authors"] -Gem::Specification.new do |s| - s.name = "manageiq-providers-vmware" - s.version = ManageIQ::Providers::Vmware::VERSION - s.authors = ["ManageIQ Developers"] - s.homepage = "https://github.com/ManageIQ/manageiq-providers-vmware" - s.summary = "Vmware Provider for ManageIQ" - s.description = "Vmware Provider for ManageIQ" - s.licenses = ["Apache-2.0"] + spec.summary = "ManageIQ plugin for the VMware provider." + spec.description = "ManageIQ plugin for the VMware provider." + spec.homepage = "https://github.com/ManageIQ/manageiq-providers-vmware" + spec.license = "Apache-2.0" - s.files = Dir["{app,config,lib}/**/*"] + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] - s.add_dependency("fog-vcloud-director", ["~> 0.3.0"]) - s.add_dependency "ffi-vix_disk_lib", "~>1.1" - s.add_dependency "rbvmomi", "~>3.0" - s.add_dependency "vmware_web_service", "~>2.0" - s.add_dependency "vsphere-automation-sdk", "~>0.4.7" + spec.add_dependency "fog-vcloud-director", "~> 0.3.0" + spec.add_dependency "ffi-vix_disk_lib", "~>1.1" + spec.add_dependency "rbvmomi", "~>3.0" + spec.add_dependency "vmware_web_service", "~>2.0" + spec.add_dependency "vsphere-automation-sdk", "~>0.4.7" - s.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0" - s.add_development_dependency "simplecov" + spec.add_development_dependency "simplecov" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0f7d73183..05b3df06d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,10 +3,12 @@ SimpleCov.start end +Dir[Rails.root.join("spec/shared/**/*.rb")].each { |f| require f } +Dir[File.join(__dir__, "support/**/*.rb")].each { |f| require f } + +require "manageiq-providers-vmware" + VCR.configure do |config| config.ignore_hosts 'codeclimate.com' if ENV['CI'] config.cassette_library_dir = File.join(ManageIQ::Providers::Vmware::Engine.root, 'spec/vcr_cassettes') end - -Dir[Rails.root.join("spec/shared/**/*.rb")].each { |f| require f } -Dir[ManageIQ::Providers::Vmware::Engine.root.join("spec/support/**/*.rb")].each { |f| require f }