beaker-module_install_helper 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/release.yml +31 -0
- data/.github/workflows/test.yml +35 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +96 -0
- data/Gemfile +13 -5
- data/README.md +32 -5
- data/Rakefile +18 -1
- data/beaker-module_install_helper.gemspec +8 -6
- data/lib/beaker/module_install_helper.rb +15 -10
- data/spec/spec_helper.rb +24 -0
- data/spec/unit/beaker/module_install_helper_spec.rb +62 -45
- metadata +27 -14
- data/.travis.yml +0 -8
- data/MAINTAINERS +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c5192677947674c9afe89bc03271fd1496458140556f66ec5d5765a892c31e7
|
4
|
+
data.tar.gz: 318f11f4d52851391ea4f266cc84ce01a84799604066b9d7ea7fa4caa4bdc1cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9d605bc7dae5ea9c9f3e89c36c89423ca006bd61b3930513dbe970fcbe52e0827737ec7a119aa2c4ba559ed4aef3b23f6404b7264587ad95ecebe4e700b48a0
|
7
|
+
data.tar.gz: 9c1d699e742bd6f800b8841027b5261aa11fec41e381a82866fbec27a75ddaad0a3765e161e83b6e77f6106ca7d9a792bdfabf08f6d8a7e03aaf93fc1a8fdd04
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- '*'
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
release:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
if: github.repository_owner == 'voxpupuli'
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Install Ruby 3.0
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: '3.0'
|
18
|
+
bundler: 'none'
|
19
|
+
- name: Build gem
|
20
|
+
run: gem build *.gemspec
|
21
|
+
- name: Publish gem to rubygems.org
|
22
|
+
run: gem push *.gem
|
23
|
+
env:
|
24
|
+
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
|
25
|
+
- name: Setup GitHub packages access
|
26
|
+
run: |
|
27
|
+
mkdir -p ~/.gem
|
28
|
+
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
|
29
|
+
chmod 0600 ~/.gem/credentials
|
30
|
+
- name: Publish gem to GitHub packages
|
31
|
+
run: gem push --key github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
- pull_request
|
5
|
+
- push
|
6
|
+
|
7
|
+
env:
|
8
|
+
BUNDLE_WITHOUT: release
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
include:
|
17
|
+
- ruby: "2.4"
|
18
|
+
- ruby: "2.5"
|
19
|
+
- ruby: "2.6"
|
20
|
+
- ruby: "2.7"
|
21
|
+
- ruby: "3.0"
|
22
|
+
coverage: "yes"
|
23
|
+
env:
|
24
|
+
COVERAGE: ${{ matrix.coverage }}
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v2
|
27
|
+
- name: Install Ruby ${{ matrix.ruby }}
|
28
|
+
uses: ruby/setup-ruby@v1
|
29
|
+
with:
|
30
|
+
ruby-version: ${{ matrix.ruby }}
|
31
|
+
bundler-cache: true
|
32
|
+
- name: Run tests
|
33
|
+
run: bundle exec rake spec
|
34
|
+
- name: Verify gem builds
|
35
|
+
run: bundle exec gem build *.gemspec
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## [1.0.0](https://github.com/voxpupuli/beaker-module_install_helper/tree/1.0.0) (2021-11-03)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/v0.1.7...1.0.0)
|
8
|
+
|
9
|
+
**Closed issues:**
|
10
|
+
|
11
|
+
- Master fails to build in Travis [\#25](https://github.com/voxpupuli/beaker-module_install_helper/issues/25)
|
12
|
+
|
13
|
+
**Merged pull requests:**
|
14
|
+
|
15
|
+
- Add beaker-puppet dependency, update gem versions, fix CI [\#31](https://github.com/voxpupuli/beaker-module_install_helper/pull/31) ([ekohl](https://github.com/ekohl))
|
16
|
+
- Add Dependabot & GH Actions for testing & release [\#27](https://github.com/voxpupuli/beaker-module_install_helper/pull/27) ([genebean](https://github.com/genebean))
|
17
|
+
- Allow passing in options to install\_module [\#26](https://github.com/voxpupuli/beaker-module_install_helper/pull/26) ([ekohl](https://github.com/ekohl))
|
18
|
+
- Don't attempt to modify possibly frozen strings [\#24](https://github.com/voxpupuli/beaker-module_install_helper/pull/24) ([beezly](https://github.com/beezly))
|
19
|
+
|
20
|
+
## [v0.1.7](https://github.com/voxpupuli/beaker-module_install_helper/tree/v0.1.7) (2017-12-08)
|
21
|
+
|
22
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/v0.1.6...v0.1.7)
|
23
|
+
|
24
|
+
**Merged pull requests:**
|
25
|
+
|
26
|
+
- Release prep 0.1.7 [\#22](https://github.com/voxpupuli/beaker-module_install_helper/pull/22) ([pmcmaw](https://github.com/pmcmaw))
|
27
|
+
- Fix broken beaker dependency [\#21](https://github.com/voxpupuli/beaker-module_install_helper/pull/21) ([cdenneen](https://github.com/cdenneen))
|
28
|
+
|
29
|
+
## [v0.1.6](https://github.com/voxpupuli/beaker-module_install_helper/tree/v0.1.6) (2017-12-08)
|
30
|
+
|
31
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/0.1.5...v0.1.6)
|
32
|
+
|
33
|
+
**Merged pull requests:**
|
34
|
+
|
35
|
+
- minor gemspec changes [\#20](https://github.com/voxpupuli/beaker-module_install_helper/pull/20) ([pmcmaw](https://github.com/pmcmaw))
|
36
|
+
- Release Prep for 0.1.6 [\#19](https://github.com/voxpupuli/beaker-module_install_helper/pull/19) ([pmcmaw](https://github.com/pmcmaw))
|
37
|
+
- \(BKR-1254\) Update for Unix::Host does not allow each [\#17](https://github.com/voxpupuli/beaker-module_install_helper/pull/17) ([cdenneen](https://github.com/cdenneen))
|
38
|
+
|
39
|
+
## [0.1.5](https://github.com/voxpupuli/beaker-module_install_helper/tree/0.1.5) (2017-07-26)
|
40
|
+
|
41
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/0.1.4...0.1.5)
|
42
|
+
|
43
|
+
**Merged pull requests:**
|
44
|
+
|
45
|
+
- 0.1.5 fix uninitialized constant Net::HTTP [\#16](https://github.com/voxpupuli/beaker-module_install_helper/pull/16) ([hunner](https://github.com/hunner))
|
46
|
+
- Fix bug that causes a NoMethodError: undefined method `each' for nil:NilClass [\#15](https://github.com/voxpupuli/beaker-module_install_helper/pull/15) ([dhollinger](https://github.com/dhollinger))
|
47
|
+
- Correct markdown formatting [\#14](https://github.com/voxpupuli/beaker-module_install_helper/pull/14) ([ekohl](https://github.com/ekohl))
|
48
|
+
|
49
|
+
## [0.1.4](https://github.com/voxpupuli/beaker-module_install_helper/tree/0.1.4) (2017-02-27)
|
50
|
+
|
51
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/0.1.3...0.1.4)
|
52
|
+
|
53
|
+
**Merged pull requests:**
|
54
|
+
|
55
|
+
- Fix get\_module\_source\_directory when module used with Rototiller [\#12](https://github.com/voxpupuli/beaker-module_install_helper/pull/12) ([wilson208](https://github.com/wilson208))
|
56
|
+
|
57
|
+
## [0.1.3](https://github.com/voxpupuli/beaker-module_install_helper/tree/0.1.3) (2017-02-22)
|
58
|
+
|
59
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/0.1.2...0.1.3)
|
60
|
+
|
61
|
+
**Merged pull requests:**
|
62
|
+
|
63
|
+
- Fix beaker forge api not specified error [\#11](https://github.com/voxpupuli/beaker-module_install_helper/pull/11) ([wilson208](https://github.com/wilson208))
|
64
|
+
|
65
|
+
## [0.1.2](https://github.com/voxpupuli/beaker-module_install_helper/tree/0.1.2) (2017-02-02)
|
66
|
+
|
67
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/0.1.1...0.1.2)
|
68
|
+
|
69
|
+
**Merged pull requests:**
|
70
|
+
|
71
|
+
- Minor version bump for release 0.1.2 [\#10](https://github.com/voxpupuli/beaker-module_install_helper/pull/10) ([wilson208](https://github.com/wilson208))
|
72
|
+
- \[MODULES-4312\] Install modules dependencies from alternative forge instances and install modules not specified in metadata.json [\#9](https://github.com/voxpupuli/beaker-module_install_helper/pull/9) ([wilson208](https://github.com/wilson208))
|
73
|
+
|
74
|
+
## [0.1.1](https://github.com/voxpupuli/beaker-module_install_helper/tree/0.1.1) (2017-01-09)
|
75
|
+
|
76
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/0.1.0...0.1.1)
|
77
|
+
|
78
|
+
**Merged pull requests:**
|
79
|
+
|
80
|
+
- Release 0.1.1 containing fixes [\#8](https://github.com/voxpupuli/beaker-module_install_helper/pull/8) ([wilson208](https://github.com/wilson208))
|
81
|
+
|
82
|
+
## [0.1.0](https://github.com/voxpupuli/beaker-module_install_helper/tree/0.1.0) (2017-01-04)
|
83
|
+
|
84
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-module_install_helper/compare/2992a8637097a36d1452be05348f11715a587bc7...0.1.0)
|
85
|
+
|
86
|
+
**Merged pull requests:**
|
87
|
+
|
88
|
+
- Add maintainers file [\#7](https://github.com/voxpupuli/beaker-module_install_helper/pull/7) ([wilson208](https://github.com/wilson208))
|
89
|
+
- Add CONTRIBUTING.md, a README update and version bump before initial release [\#6](https://github.com/voxpupuli/beaker-module_install_helper/pull/6) ([wilson208](https://github.com/wilson208))
|
90
|
+
- Implement install\_module\_dependencies\_on method [\#5](https://github.com/voxpupuli/beaker-module_install_helper/pull/5) ([wilson208](https://github.com/wilson208))
|
91
|
+
- \[MODULES-4152\] Implement install\_module and install\_module\_on methods [\#3](https://github.com/voxpupuli/beaker-module_install_helper/pull/3) ([wilson208](https://github.com/wilson208))
|
92
|
+
- \[MODULES-4157\] Basic setup with stub methods and placeholder tests [\#2](https://github.com/voxpupuli/beaker-module_install_helper/pull/2) ([wilson208](https://github.com/wilson208))
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
@@ -3,11 +3,10 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
gem 'beaker'
|
7
|
-
gem '
|
8
|
-
gem '
|
9
|
-
gem '
|
10
|
-
gem 'rspec', '~> 3'
|
6
|
+
gem 'beaker'
|
7
|
+
gem 'bundler', '>= 1.9', '< 3'
|
8
|
+
gem 'rake', '~> 13.0'
|
9
|
+
gem 'rspec', '~> 3.0'
|
11
10
|
gem 'rubocop', require: false
|
12
11
|
gem 'rubocop-rspec', require: false
|
13
12
|
end
|
@@ -16,3 +15,12 @@ group :development do
|
|
16
15
|
gem 'pry'
|
17
16
|
gem 'pry-byebug'
|
18
17
|
end
|
18
|
+
|
19
|
+
group :coverage, optional: ENV['COVERAGE']!='yes' do
|
20
|
+
gem 'simplecov-console', :require => false
|
21
|
+
gem 'codecov', :require => false
|
22
|
+
end
|
23
|
+
|
24
|
+
group :release do
|
25
|
+
gem 'github_changelog_generator', '>= 1.16.4', require: false if RUBY_VERSION >= '2.5'
|
26
|
+
end
|
data/README.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## beaker-module\_install\_helper
|
2
2
|
|
3
|
+
[![License](https://img.shields.io/github/license/voxpupuli/beaker-module_install_helper.svg)](https://github.com/voxpupuli/beaker-module_install_helper/blob/master/LICENSE)
|
4
|
+
[![Test](https://github.com/voxpupuli/beaker-module_install_helper/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/beaker-module_install_helper/actions/workflows/test.yml)
|
5
|
+
[![Release](https://github.com/voxpupuli/beaker-module_install_helper/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/beaker-module_install_helper/actions/workflows/release.yml)
|
6
|
+
[![RubyGem Version](https://img.shields.io/gem/v/beaker-module_install_helper.svg)](https://rubygems.org/gems/beaker-module_install_helper)
|
7
|
+
[![RubyGem Downloads](https://img.shields.io/gem/dt/beaker-module_install_helper.svg)](https://rubygems.org/gems/beaker-module_install_helper)
|
8
|
+
[![Donated by Puppet Inc](https://img.shields.io/badge/donated%20by-Puppet%20Inc-fb7047.svg)](#transfer-notice)
|
9
|
+
|
3
10
|
This gem is simply an abstraction for the various functions that are performed within the `spec/spec_helper_acceptance.rb` files across the modules to standardise how these are implemented.
|
4
11
|
|
5
12
|
### Usage
|
@@ -35,15 +42,15 @@ This will call `install_module_dependencies_on` on the hosts with role 'master'.
|
|
35
42
|
### `install_module_dependencies_on`
|
36
43
|
This will install a list of dependencies on the specified host from the forge, using the dependencies list specified in the metadata.json file, taking into consideration the version constraints if specified.
|
37
44
|
|
38
|
-
**See
|
45
|
+
**See:** [Alternative Forge Instances](#alternative-forge-instances)
|
39
46
|
|
40
47
|
### `install_module_from_forge(module_name, version_requirement)`
|
41
|
-
This will call `install_module_from_forge_on` on the hosts with role 'master'. If there are none, the module will be
|
48
|
+
This will call `install_module_from_forge_on` on the hosts with role 'master'. If there are none, the module will be installed on all hosts with the role 'agent', again, if there are none, the module will be installed on all hosts.
|
42
49
|
|
43
50
|
### `install_module_from_forge_on(hosts, module_name, version_requirement)`
|
44
|
-
This will install a module from the forge on the given host(s). Module name must be specified in the {author}-{module_name} or {author}/{module_name} format. Version requirement must be specified to meet [this](https://docs.puppet.com/puppet/latest/modules_metadata.html#version-specifiers) criteria.
|
51
|
+
This will install a module from the forge on the given host(s). Module name must be specified in the `{author}-{module_name}` or `{author}/{module_name}` format. Version requirement must be specified to meet [this](https://docs.puppet.com/puppet/latest/modules_metadata.html#version-specifiers) criteria.
|
45
52
|
|
46
|
-
**See
|
53
|
+
**See:** [Alternative Forge Instances](#alternative-forge-instances)
|
47
54
|
|
48
55
|
### Alternative Forge Instances
|
49
56
|
It is possible to use alternative forge instances rather than the production forge instance to install module dependencies by specifiying 2 environment variables, `BEAKER_FORGE_HOST` and `BEAKER_FORGE_API`. Both of these are required as the forge API is used under the hood to resolve version requirement boundary strings.
|
@@ -54,4 +61,24 @@ BEAKER_FORGE_HOST=https://module-staging.puppetlabs.com BEAKER_FORGE_API=https:/
|
|
54
61
|
```
|
55
62
|
|
56
63
|
### Support
|
57
|
-
No support is supplied or implied. Use at your own risk.
|
64
|
+
No support is supplied or implied. Use at your own risk.
|
65
|
+
|
66
|
+
## Transfer Notice
|
67
|
+
|
68
|
+
This plugin was originally authored by [Puppet Inc](http://puppet.com).
|
69
|
+
The maintainer preferred that [Vox Pupuli](https://voxpupuli.org) take ownership of the module for future improvement and maintenance.
|
70
|
+
Existing pull requests and issues were transferred over, please fork and continue to contribute here.
|
71
|
+
|
72
|
+
## License
|
73
|
+
|
74
|
+
This gem is licensed under the Apache-2 license.
|
75
|
+
|
76
|
+
## Release information
|
77
|
+
|
78
|
+
To make a new release, please do:
|
79
|
+
* update the version in the gemspec file
|
80
|
+
* Install gems with `bundle install --with release --path .vendor`
|
81
|
+
* generate the changelog with `bundle exec rake changelog`
|
82
|
+
* Check if the new version matches the closed issues/PRs in the changelog
|
83
|
+
* Create a PR with it
|
84
|
+
* After it got merged, push a tag. GitHub actions will do the actual release to rubygems and GitHub Packages
|
data/Rakefile
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
|
-
task default: [
|
4
|
+
task default: %i[lint spec]
|
3
5
|
|
4
6
|
require 'rubocop/rake_task'
|
5
7
|
desc 'Run rubocop'
|
@@ -13,3 +15,18 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|
13
15
|
t.rspec_opts = ['--color']
|
14
16
|
t.pattern = 'spec'
|
15
17
|
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
require 'rubygems'
|
21
|
+
require 'github_changelog_generator/task'
|
22
|
+
rescue LoadError
|
23
|
+
# github_changelog_generator isn't available, so we won't define a rake task with it
|
24
|
+
else
|
25
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
26
|
+
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
|
27
|
+
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog]
|
28
|
+
config.user = 'voxpupuli'
|
29
|
+
config.project = 'beaker-module_install_helper'
|
30
|
+
config.future_release = Gem::Specification.load("#{config.project}.gemspec").version
|
31
|
+
end
|
32
|
+
end
|
@@ -1,12 +1,11 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
|
5
4
|
Gem::Specification.new do |spec|
|
6
5
|
spec.name = 'beaker-module_install_helper'
|
7
|
-
spec.version = '0.
|
8
|
-
spec.authors = ['
|
9
|
-
spec.email = ['
|
6
|
+
spec.version = '1.0.0'
|
7
|
+
spec.authors = ['Vox Pupuli']
|
8
|
+
spec.email = ['voxpupuli@groups.io']
|
10
9
|
|
11
10
|
spec.summary = 'A helper gem for use in a Puppet Modules ' \
|
12
11
|
'spec_helper_acceptance.rb file'
|
@@ -14,8 +13,8 @@ Gem::Specification.new do |spec|
|
|
14
13
|
'spec_helper_acceptance.rb file to help install the ' \
|
15
14
|
'module under test and its dependencies on the system ' \
|
16
15
|
'under test'
|
17
|
-
spec.homepage = 'https://github.com/
|
18
|
-
spec.license = 'Apache-2'
|
16
|
+
spec.homepage = 'https://github.com/voxpupuli/beaker-module_install_helper'
|
17
|
+
spec.license = 'Apache-2.0'
|
19
18
|
|
20
19
|
spec.files = `git ls-files`.split("\n")
|
21
20
|
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -29,4 +28,7 @@ Gem::Specification.new do |spec|
|
|
29
28
|
|
30
29
|
# Run time dependencies
|
31
30
|
spec.add_runtime_dependency 'beaker', '>= 2.0'
|
31
|
+
spec.add_runtime_dependency 'beaker-puppet', '~> 1.0'
|
32
|
+
|
33
|
+
spec.required_ruby_version = '>= 2.4.0'
|
32
34
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'beaker'
|
2
|
+
require 'beaker-puppet'
|
2
3
|
|
3
4
|
# Provides method for use in module test setup to install the module under
|
4
5
|
# test and it's dependencies on the specified hosts
|
@@ -7,16 +8,18 @@ module Beaker::ModuleInstallHelper
|
|
7
8
|
|
8
9
|
# This method calls the install_module_on method for each host which is a
|
9
10
|
# master, or if no master is present, on all agent nodes.
|
10
|
-
def install_module
|
11
|
-
install_module_on
|
11
|
+
def install_module(opts = {})
|
12
|
+
install_module_on(hosts_to_install_module_on, opts)
|
12
13
|
end
|
13
14
|
|
14
15
|
# This method will install the module under test on the specified host(s) from
|
15
16
|
# the source on the local machine
|
16
|
-
def install_module_on(host)
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def install_module_on(host, opts = {})
|
18
|
+
opts = {
|
19
|
+
source: $module_source_dir,
|
20
|
+
module_name: module_name_from_metadata
|
21
|
+
}.merge(opts)
|
22
|
+
copy_module_to(host, opts)
|
20
23
|
end
|
21
24
|
|
22
25
|
# This method calls the install_module_dependencies_on method for each
|
@@ -29,6 +32,7 @@ module Beaker::ModuleInstallHelper
|
|
29
32
|
# specified host(s) from the dependencies list in metadata.json
|
30
33
|
def install_module_dependencies_on(hsts, deps = nil)
|
31
34
|
hsts = [hsts] if hsts.is_a?(Hash)
|
35
|
+
hsts = [hsts] unless hsts.respond_to?(:each)
|
32
36
|
deps = deps.nil? ? module_dependencies_from_metadata : deps
|
33
37
|
|
34
38
|
fh = ENV['BEAKER_FORGE_HOST']
|
@@ -51,10 +55,10 @@ module Beaker::ModuleInstallHelper
|
|
51
55
|
end
|
52
56
|
|
53
57
|
def install_module_from_forge_on(hsts, mod_name, ver_req)
|
54
|
-
mod_name.sub
|
58
|
+
sub_mod_name = mod_name.sub('/', '-')
|
55
59
|
dependency = {
|
56
|
-
module_name:
|
57
|
-
version: module_version_from_requirement(
|
60
|
+
module_name: sub_mod_name,
|
61
|
+
version: module_version_from_requirement(sub_mod_name, ver_req)
|
58
62
|
}
|
59
63
|
|
60
64
|
install_module_dependencies_on(hsts, [dependency])
|
@@ -69,7 +73,7 @@ module Beaker::ModuleInstallHelper
|
|
69
73
|
|
70
74
|
dependencies = []
|
71
75
|
metadata['dependencies'].each do |d|
|
72
|
-
tmp = { module_name: d['name'].sub
|
76
|
+
tmp = { module_name: d['name'].sub('/', '-') }
|
73
77
|
|
74
78
|
if d.key?('version_requirement')
|
75
79
|
tmp[:version] = module_version_from_requirement(tmp[:module_name],
|
@@ -86,6 +90,7 @@ module Beaker::ModuleInstallHelper
|
|
86
90
|
# and upper bounds. The function then uses the forge rest endpoint to find
|
87
91
|
# the most recent release of the given module matching the version requirement
|
88
92
|
def module_version_from_requirement(mod_name, vr_str)
|
93
|
+
require 'net/http'
|
89
94
|
uri = URI("#{forge_api}v3/modules/#{mod_name}")
|
90
95
|
response = Net::HTTP.get(uri)
|
91
96
|
forge_data = JSON.parse(response)
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1,25 @@
|
|
1
|
+
begin
|
2
|
+
require 'simplecov'
|
3
|
+
require 'simplecov-console'
|
4
|
+
require 'codecov'
|
5
|
+
rescue LoadError
|
6
|
+
else
|
7
|
+
SimpleCov.start do
|
8
|
+
track_files 'lib/**/*.rb'
|
9
|
+
|
10
|
+
add_filter '/spec'
|
11
|
+
|
12
|
+
enable_coverage :branch
|
13
|
+
|
14
|
+
# do not track vendored files
|
15
|
+
add_filter '/vendor'
|
16
|
+
add_filter '/.vendor'
|
17
|
+
end
|
18
|
+
|
19
|
+
SimpleCov.formatters = [
|
20
|
+
SimpleCov::Formatter::Console,
|
21
|
+
SimpleCov::Formatter::Codecov,
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
1
25
|
require 'beaker/module_install_helper'
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Beaker::ModuleInstallHelper do
|
4
|
-
|
5
|
-
context '
|
4
|
+
describe 'hosts_to_install_module_on' do
|
5
|
+
context 'with a split master/agent setup' do
|
6
6
|
let(:hosts) do
|
7
7
|
[
|
8
|
-
{ 'roles' => %w
|
8
|
+
{ 'roles' => %w[master database dashboard classifier] },
|
9
9
|
{ 'roles' => ['agent'] }
|
10
10
|
]
|
11
11
|
end
|
@@ -15,7 +15,7 @@ describe Beaker::ModuleInstallHelper do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
context '
|
18
|
+
context 'with a split agent only setup' do
|
19
19
|
let(:hosts) { [{ 'roles' => ['agent'] }] }
|
20
20
|
|
21
21
|
it 'returns a node with master role' do
|
@@ -24,7 +24,7 @@ describe Beaker::ModuleInstallHelper do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
describe 'module_name_from_metadata' do
|
28
28
|
let(:module_metadata) { { 'name' => 'puppetlabs-vcsrepo' } }
|
29
29
|
|
30
30
|
it 'Removes author from name' do
|
@@ -33,7 +33,7 @@ describe Beaker::ModuleInstallHelper do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
describe 'module_metadata' do
|
37
37
|
before do
|
38
38
|
$module_source_dir = '/a/b/c/d'
|
39
39
|
allow(File).to receive(:exist?)
|
@@ -44,12 +44,12 @@ describe Beaker::ModuleInstallHelper do
|
|
44
44
|
.and_return('{"name": "puppetlabs-vcsrepo"}')
|
45
45
|
end
|
46
46
|
|
47
|
-
it '
|
47
|
+
it 'returns hash with correct data' do
|
48
48
|
expect(module_metadata['name']).to eq('puppetlabs-vcsrepo')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
describe 'get_module_source_directory' do
|
53
53
|
let(:call_stack) { ['/a/b/c/d/e/f/g/spec_helper_acceptance.rb'] }
|
54
54
|
let(:call_stack_no_metadata) { ['/test/test/test/spec_helper_acceptance.rb'] }
|
55
55
|
|
@@ -67,33 +67,56 @@ describe Beaker::ModuleInstallHelper do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
describe 'install_module_on' do
|
71
71
|
let(:module_source_dir) { '/a/b/c/d' }
|
72
|
+
let(:host) { { 'roles' => %w[master database dashboard classifier] } }
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
74
|
+
context 'without options' do
|
75
|
+
before do
|
76
|
+
$module_source_dir = '/a/b/c/d'
|
77
|
+
allow(File).to receive(:exist?).and_return(true)
|
78
|
+
allow(File).to receive(:read).and_return('{"name": "puppetlabs-vcsrepo"}')
|
79
|
+
|
80
|
+
allow_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
|
81
|
+
.to receive(:copy_module_to)
|
82
|
+
.with(anything)
|
83
|
+
.and_return(false)
|
84
|
+
|
85
|
+
allow_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
|
86
|
+
.to receive(:copy_module_to)
|
87
|
+
.with(host, source: module_source_dir, module_name: 'vcsrepo')
|
88
|
+
.and_return(true)
|
89
|
+
end
|
82
90
|
|
83
|
-
|
84
|
-
.to
|
85
|
-
|
86
|
-
.and_return(true)
|
91
|
+
it 'copy module to given host' do
|
92
|
+
expect(install_module_on(host)).to be true
|
93
|
+
end
|
87
94
|
end
|
88
95
|
|
89
|
-
|
96
|
+
context 'with options' do
|
97
|
+
before do
|
98
|
+
$module_source_dir = '/a/b/c/d'
|
99
|
+
allow(File).to receive(:exist?).and_return(true)
|
100
|
+
allow(File).to receive(:read).and_return('{"name": "puppetlabs-vcsrepo"}')
|
101
|
+
|
102
|
+
allow_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
|
103
|
+
.to receive(:copy_module_to)
|
104
|
+
.with(anything)
|
105
|
+
.and_return(false)
|
106
|
+
|
107
|
+
allow_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
|
108
|
+
.to receive(:copy_module_to)
|
109
|
+
.with(host, source: module_source_dir, module_name: 'vcsrepo', protocol: 'rsync')
|
110
|
+
.and_return(true)
|
111
|
+
end
|
90
112
|
|
91
|
-
|
92
|
-
|
113
|
+
it 'copy module to given host' do
|
114
|
+
expect(install_module_on(host, protocol: 'rsync')).to be true
|
115
|
+
end
|
93
116
|
end
|
94
117
|
end
|
95
118
|
|
96
|
-
|
119
|
+
describe 'module_version_matching_requirement' do
|
97
120
|
context 'with simple version requirement, no upper bound' do
|
98
121
|
it 'return latest matching version' do
|
99
122
|
res = module_version_from_requirement('puppetlabs-ntp', '= 6.0.0')
|
@@ -110,14 +133,14 @@ describe Beaker::ModuleInstallHelper do
|
|
110
133
|
end
|
111
134
|
end
|
112
135
|
|
113
|
-
|
136
|
+
describe 'module_dependencies_from_metadata' do
|
114
137
|
before do
|
115
138
|
allow_any_instance_of(described_class)
|
116
139
|
.to receive(:module_metadata)
|
117
140
|
.and_return(input_metadata)
|
118
141
|
end
|
119
142
|
|
120
|
-
context 'multiple dependencies with versions' do
|
143
|
+
context 'with multiple dependencies with versions' do
|
121
144
|
let(:input_metadata) do
|
122
145
|
{
|
123
146
|
'name' => 'puppetlabs-vcsrepo',
|
@@ -146,7 +169,7 @@ describe Beaker::ModuleInstallHelper do
|
|
146
169
|
end
|
147
170
|
end
|
148
171
|
|
149
|
-
context 'multiple dependencies without versions' do
|
172
|
+
context 'with multiple dependencies without versions' do
|
150
173
|
let(:input_metadata) do
|
151
174
|
{
|
152
175
|
'name' => 'puppetlabs-vcsrepo',
|
@@ -170,7 +193,7 @@ describe Beaker::ModuleInstallHelper do
|
|
170
193
|
end
|
171
194
|
end
|
172
195
|
|
173
|
-
context 'empty dependencies' do
|
196
|
+
context 'with empty dependencies' do
|
174
197
|
let(:input_metadata) do
|
175
198
|
{
|
176
199
|
'name' => 'puppetlabs-vcsrepo',
|
@@ -185,7 +208,7 @@ describe Beaker::ModuleInstallHelper do
|
|
185
208
|
end
|
186
209
|
end
|
187
210
|
|
188
|
-
context 'no dependencies' do
|
211
|
+
context 'with no dependencies' do
|
189
212
|
let(:input_metadata) { { 'name' => 'puppetlabs-vcsrepo' } }
|
190
213
|
let(:desired) { [] }
|
191
214
|
|
@@ -196,7 +219,7 @@ describe Beaker::ModuleInstallHelper do
|
|
196
219
|
end
|
197
220
|
end
|
198
221
|
|
199
|
-
|
222
|
+
describe 'version_requirements_from_string' do
|
200
223
|
context 'with simple version requirement containing lower bound' do
|
201
224
|
let(:lower_bound) { '>= 2.0.0' }
|
202
225
|
|
@@ -218,7 +241,7 @@ describe Beaker::ModuleInstallHelper do
|
|
218
241
|
end
|
219
242
|
end
|
220
243
|
|
221
|
-
|
244
|
+
describe 'forge_host' do
|
222
245
|
context 'without env variables specified' do
|
223
246
|
it 'returns production forge host' do
|
224
247
|
allow(ENV).to receive(:[]).with('BEAKER_FORGE_HOST').and_return(nil)
|
@@ -236,7 +259,7 @@ describe Beaker::ModuleInstallHelper do
|
|
236
259
|
end
|
237
260
|
end
|
238
261
|
|
239
|
-
|
262
|
+
describe 'forge_api' do
|
240
263
|
context 'without env variables specified' do
|
241
264
|
it 'returns production forge api' do
|
242
265
|
allow(ENV).to receive(:[]).with('BEAKER_FORGE_HOST').and_return(nil)
|
@@ -256,7 +279,7 @@ describe Beaker::ModuleInstallHelper do
|
|
256
279
|
end
|
257
280
|
end
|
258
281
|
|
259
|
-
|
282
|
+
describe 'install_module_dependencies_on' do
|
260
283
|
before do
|
261
284
|
allow_any_instance_of(described_class)
|
262
285
|
.to receive(:module_metadata)
|
@@ -280,14 +303,12 @@ describe Beaker::ModuleInstallHelper do
|
|
280
303
|
}
|
281
304
|
end
|
282
305
|
|
283
|
-
|
306
|
+
it 'installs the modules' do
|
284
307
|
expect_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
|
285
308
|
.to receive(:install_puppet_module_via_pmt_on)
|
286
309
|
.with(a_host, dependency)
|
287
310
|
.exactly(1)
|
288
|
-
end
|
289
311
|
|
290
|
-
it 'installs the modules' do
|
291
312
|
install_module_dependencies_on(a_host)
|
292
313
|
end
|
293
314
|
end
|
@@ -306,7 +327,7 @@ describe Beaker::ModuleInstallHelper do
|
|
306
327
|
let(:dependency1) { { module_name: 'puppetlabs-concat' } }
|
307
328
|
let(:dependency2) { { module_name: 'puppetlabs-stdlib' } }
|
308
329
|
|
309
|
-
|
330
|
+
it 'installs both modules' do # rubocop:disable RSpec/ExampleLength,RSpec/MultipleExpectations
|
310
331
|
expect_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
|
311
332
|
.to receive(:install_puppet_module_via_pmt_on)
|
312
333
|
.with(a_host, dependency1)
|
@@ -316,28 +337,24 @@ describe Beaker::ModuleInstallHelper do
|
|
316
337
|
.to receive(:install_puppet_module_via_pmt_on)
|
317
338
|
.with(a_host, dependency2)
|
318
339
|
.exactly(1)
|
319
|
-
end
|
320
340
|
|
321
|
-
it 'installs both modules' do
|
322
341
|
install_module_dependencies_on(a_host)
|
323
342
|
end
|
324
343
|
end
|
325
344
|
end
|
326
345
|
|
327
|
-
|
346
|
+
describe 'install_module_from_forge_on' do
|
328
347
|
let(:a_host) { { name: 'a_host' } }
|
329
348
|
let(:dependency) { { module_name: 'puppetlabs-stdlib', version: '4.14.0' } }
|
330
349
|
let(:input_module_name) { 'puppetlabs/stdlib' }
|
331
350
|
let(:input_module_version_requirement) { '>= 4.13.1 <= 4.14.0' }
|
332
351
|
|
333
|
-
|
352
|
+
it 'installs the module' do
|
334
353
|
expect_any_instance_of(Beaker::DSL::InstallUtils::ModuleUtils)
|
335
354
|
.to receive(:install_puppet_module_via_pmt_on)
|
336
355
|
.with(a_host, dependency)
|
337
356
|
.exactly(1)
|
338
|
-
end
|
339
357
|
|
340
|
-
it 'installs the module' do
|
341
358
|
install_module_from_forge_on(a_host, input_module_name, input_module_version_requirement)
|
342
359
|
end
|
343
360
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-module_install_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Vox Pupuli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,30 +38,46 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: beaker-puppet
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
41
55
|
description: A helper gem for use in a Puppet Modules spec_helper_acceptance.rb file
|
42
56
|
to help install the module under test and its dependencies on the system under test
|
43
57
|
email:
|
44
|
-
-
|
58
|
+
- voxpupuli@groups.io
|
45
59
|
executables: []
|
46
60
|
extensions: []
|
47
61
|
extra_rdoc_files: []
|
48
62
|
files:
|
63
|
+
- ".github/dependabot.yml"
|
64
|
+
- ".github/workflows/release.yml"
|
65
|
+
- ".github/workflows/test.yml"
|
49
66
|
- ".gitignore"
|
50
67
|
- ".rubocop.yml"
|
51
|
-
-
|
68
|
+
- CHANGELOG.md
|
52
69
|
- CONTRIBUTING.md
|
53
70
|
- Gemfile
|
54
71
|
- LICENSE
|
55
|
-
- MAINTAINERS
|
56
72
|
- README.md
|
57
73
|
- Rakefile
|
58
74
|
- beaker-module_install_helper.gemspec
|
59
75
|
- lib/beaker/module_install_helper.rb
|
60
76
|
- spec/spec_helper.rb
|
61
77
|
- spec/unit/beaker/module_install_helper_spec.rb
|
62
|
-
homepage: https://github.com/
|
78
|
+
homepage: https://github.com/voxpupuli/beaker-module_install_helper
|
63
79
|
licenses:
|
64
|
-
- Apache-2
|
80
|
+
- Apache-2.0
|
65
81
|
metadata: {}
|
66
82
|
post_install_message:
|
67
83
|
rdoc_options: []
|
@@ -71,18 +87,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
87
|
requirements:
|
72
88
|
- - ">="
|
73
89
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
90
|
+
version: 2.4.0
|
75
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
92
|
requirements:
|
77
93
|
- - ">="
|
78
94
|
- !ruby/object:Gem::Version
|
79
95
|
version: '0'
|
80
96
|
requirements: []
|
81
|
-
|
82
|
-
rubygems_version: 2.6.8
|
97
|
+
rubygems_version: 3.2.22
|
83
98
|
signing_key:
|
84
99
|
specification_version: 4
|
85
100
|
summary: A helper gem for use in a Puppet Modules spec_helper_acceptance.rb file
|
86
|
-
test_files:
|
87
|
-
- spec/spec_helper.rb
|
88
|
-
- spec/unit/beaker/module_install_helper_spec.rb
|
101
|
+
test_files: []
|
data/.travis.yml
DELETED
data/MAINTAINERS
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"version": 1,
|
3
|
-
"file_format": "This MAINTAINERS file format is described at http://pup.pt/maintainers",
|
4
|
-
"issues": "https://github.com/puppetlabs/beaker-module_install_helper/issues",
|
5
|
-
"people": [
|
6
|
-
{
|
7
|
-
"github": "wilson208",
|
8
|
-
"name": "Wilson McCoubrey"
|
9
|
-
}
|
10
|
-
]
|
11
|
-
}
|