-
-
Notifications
You must be signed in to change notification settings - Fork 13
[MODULES-4152] Implement install_module and install_module_on methods #3
Conversation
bcaf52a
to
e489736
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting close!
before do | ||
@module_source_dir = '/a/b/c/d' | ||
allow(File).to receive(:exist?).and_return(true) | ||
allow(File).to receive(:read).and_return('{"name": "puppetlabs-vcsrepo"}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be more specific. Add a with() clause like you did below to avoid poisoning the well if the implementation changes later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now added.
end | ||
end | ||
|
||
context 'hosts_to_install_module_on with split master/agent setup' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The duplicated hosts_to_install_module_on
in the context description hints at this and the previous context needing a joint parent. "with" is always a good indicator for denoting a context, and therefore usually should go first:
context "#hosts_to_install_module_on" do
context "with split master/agent setup" do ... end
context "with solo agent setup" do ... end
PS: also the description here does not describe the reality of the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made changes to rectify this. Had to disable an rspec cop in .rubocop.yml to allow this change.
# valid metadata.json | ||
while module_source_dir.nil? && search_in.length > 1 | ||
# remove last segment (file or folder, doesn't matter) | ||
search_in = search_in.split('/')[0...-1].join('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work on Windows. See https://ruby-doc.org/core-2.3.1/File.html#SEPARATOR ,https://ruby-doc.org/core-2.3.1/File.html#ALT_SEPARATOR , https://ruby-doc.org/core-2.3.1/File.html#method-c-join , https://ruby-doc.org/core-2.3.1/File.html#method-c-split , and https://ruby-doc.org/core-2.3.1/File.html#method-c-dirname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have updated this implementation, let me know what you think!
@@ -3,7 +3,7 @@ source 'https://rubygems.org' | |||
gemspec | |||
|
|||
group :test do | |||
gem 'beaker', '2.51.0' if RUBY_VERSION <= '2.1.6' | |||
gem 'beaker', '2.52.0' if RUBY_VERSION <= '2.1.6' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does puppet_install_helper also need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed this. It is defined in gemspec.
|
||
This will install the module under test on the specified host using the local source | ||
### `install_module_on` | ||
This will install the module under test on the specified host using the local source. The module name will be derived from the name property of the module's metadata.json file, assuming it is in format author-modulename. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation could also do with examples. People love copy&pasting working code ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have added usage of install_module and install_module_on. These usage examples are basic and will be more useful when further functionality is implemented.
1e207ba
to
348656e
Compare
@DavidS would you be able to take a look at this if you get a chance? Thanks :) |
@@ -28,5 +28,6 @@ Gem::Specification.new do |spec| | |||
spec.add_development_dependency 'rspec' | |||
|
|||
# Run time dependencies | |||
spec.add_runtime_dependency 'beaker', '>= 2.0' | |||
spec.add_runtime_dependency 'beaker', '= 2.52' if RUBY_VERSION <= '2.1.6' | |||
spec.add_runtime_dependency 'beaker' if RUBY_VERSION > '2.1.6' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This is only evaluated at gem build time, but the RUBY_VERSION constraint depends on the executing runtime.
- there is no
2.52
version of beaker, it's2.52.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I should be moving this dependency to the Gemfile and updating the version correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still in the wrong place?
# valid metadata.json | ||
while module_source_dir.nil? && search_in.length > 1 | ||
# remove last segment (file or folder, doesn't matter) | ||
search_in = File.join(search_in.split(File::SEPARATOR)[0...-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still looks like https://ruby-doc.org/core-2.3.1/File.html#method-c-dirname ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have now fixed this in the latest commits and added an Assumptions section to the README based on what we discussed about requiring a metadata.json in the module. I also included the assumption that for the metadata.json to be found, the bundle install path must be within the module directory, as the bundle install --path option allows the bundle gems to be installed anywhere on the system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought https://github.com/puppetlabs/beaker-module_install_helper/pull/3/files#diff-111e45d2ddd48cd4fc5f8359327e2e81R78 makes the constraint on the install path unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Have fixed this now, sorry!
6f46fe2
to
2235176
Compare
…nd install_module_on methods, along with some supporting methods and accompanying tests
2235176
to
dc29c66
Compare
module_source_dir = nil | ||
# here we go up the file tree and search the directories for a | ||
# valid metadata.json | ||
while module_source_dir.nil? && search_in.length > 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also talked about fixing this here for windows.
module_source_dir = nil | ||
# here we go up the file tree and search the directories for a | ||
# valid metadata.json | ||
while module_source_dir.nil? && search_in.length > 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'C:/'.length
is bigger than 2. Alternatively try File.dirname(search_in) == search_in
, which should work on any filesystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a testcase with no metadata.json to the unit tests below, to avoid any further dead ends here ;-)
@@ -26,7 +26,4 @@ Gem::Specification.new do |spec| | |||
|
|||
## Testing dependencies | |||
spec.add_development_dependency 'rspec' | |||
|
|||
# Run time dependencies | |||
spec.add_runtime_dependency 'beaker', '>= 2.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still needed for documentation purposes.
…not found. Add spec test to cover no metadata.json found.
Also implemented accompanying unit tests and readme updates. Several supporting functions implemented and unit tested also.