@@ -15,7 +15,12 @@ RSpec::Core::RakeTask.new(:spec) do |t|
15
15
t . exclude_pattern = "spec/acceptance/**/*.rb"
16
16
end
17
17
18
+ RSpec ::Core ::RakeTask . new ( :acceptance ) do |t |
19
+ t . pattern = "spec/unit/**/*.rb"
20
+ end
21
+
18
22
task :spec => :spec_clean
23
+ task :acceptance => :spec_prep
19
24
20
25
# Add our own tasks
21
26
require 'puppet-strings/tasks'
@@ -32,138 +37,3 @@ task :validate do
32
37
sh "erb -P -x -T '-' #{ template } | ruby -c"
33
38
end
34
39
end
35
-
36
- namespace :litmus do
37
- def install_remote_gem ( gem_name , target_nodes , inventory_hash )
38
- # TODO: Currently this is Linux only
39
- install_command = "/opt/puppetlabs/puppet/bin/gem install #{ gem_name } "
40
- result = run_command ( install_command , target_nodes , config : nil , inventory : inventory_hash )
41
- if result . is_a? ( Array )
42
- result . each do |node |
43
- puts "#{ node [ 'target' ] } failed: '#{ node [ 'value' ] } '" if node [ 'status' ] != 'success'
44
- end
45
- else
46
- raise "Failed trying to run '#{ install_command } ' against inventory."
47
- end
48
- end
49
-
50
- def install_build_tools ( target_nodes , inventory_hash )
51
- puts 'Installing build tools...'
52
- install_build_command = "yum -y group install 'Development Tools'"
53
- result = run_command ( install_build_command , target_nodes , config : nil , inventory : inventory_hash )
54
- if result . is_a? ( Array )
55
- result . each do |node |
56
- puts "#{ node [ 'target' ] } failed: '#{ node [ 'value' ] } '" if node [ 'status' ] != 'success'
57
- end
58
- else
59
- raise "Failed trying to run '#{ install_build_command } ' against inventory."
60
- end
61
- end
62
-
63
- # Install the gem under test and required fixture on a collection of nodes
64
- #
65
- # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
66
- desc 'install_gems - build and install module fixtures'
67
- task :install_gems , [ :target_node_name ] do |_task , args |
68
- inventory_hash = inventory_hash_from_inventory_file
69
- target_nodes = find_targets ( inventory_hash , args [ :target_node_name ] )
70
- if target_nodes . empty?
71
- puts 'No targets found'
72
- exit 0
73
- end
74
- require 'bolt_spec/run'
75
- include BoltSpec ::Run
76
-
77
- # Build the gem
78
- puts 'Building gem...'
79
- `gem build puppet-strings.gemspec --quiet`
80
- result = $CHILD_STATUS
81
- raise "Unable to build the puppet-strings gem. Returned exit code #{ result . exitstatus } " unless result . exitstatus . zero?
82
-
83
- # Find the gem build artifact
84
- gem_tar = Dir . glob ( 'puppet-strings-*.gem' ) . max_by { |f | File . mtime ( f ) }
85
- raise "Unable to find package in 'puppet-strings-*.gem'" if gem_tar . nil?
86
-
87
- gem_tar = File . expand_path ( gem_tar )
88
-
89
- target_string = if args [ :target_node_name ] . nil?
90
- 'all'
91
- else
92
- args [ :target_node_name ]
93
- end
94
- puts 'Copying gem to targets...'
95
- upload_file ( gem_tar , File . basename ( gem_tar ) , target_string , inventory : inventory_hash )
96
-
97
- install_build_tools ( target_nodes , inventory_hash )
98
-
99
- # Install dependent gems
100
- puts 'Installing yard gem...'
101
- install_remote_gem ( 'yard' , target_nodes , inventory_hash )
102
- puts 'Installing rgen gem...'
103
- install_remote_gem ( 'rgen' , target_nodes , inventory_hash )
104
- # Install puppet-strings
105
- puts 'Installing puppet-strings gem...'
106
- install_remote_gem ( File . basename ( gem_tar ) , target_nodes , inventory_hash )
107
- puts 'Installed'
108
- end
109
- end
110
-
111
- #### CHANGELOG ####
112
- begin
113
- require 'github_changelog_generator/task'
114
- GitHubChangelogGenerator ::RakeTask . new :changelog do |config |
115
- require 'puppet-strings/version'
116
- config . future_release = "v#{ PuppetStrings ::VERSION } "
117
- config . header = "# Changelog\n \n " \
118
- "All significant changes to this repo will be summarized in this file.\n "
119
- config . configure_sections = {
120
- added : {
121
- prefix : "Added" ,
122
- labels : [ "enhancement" ]
123
- } ,
124
- fixed : {
125
- prefix : "Fixed" ,
126
- labels : [ "bugfix" ]
127
- } ,
128
- breaking : {
129
- prefix : "Changed" ,
130
- labels : [ "backwards-incompatible" ]
131
- }
132
- }
133
- config . exclude_labels = [ 'maintenance' , 'incomplete' ]
134
- config . user = 'puppetlabs'
135
- config . project = 'puppet-strings'
136
- end
137
- rescue LoadError
138
- desc 'Install github_changelog_generator to get access to automatic changelog generation'
139
- task :changelog do
140
- raise 'Install github_changelog_generator to get access to automatic changelog generation'
141
- end
142
- end
143
-
144
- desc 'Run acceptance tests'
145
- task :acceptance do
146
-
147
- begin
148
- if ENV [ 'MATRIX_TARGET' ]
149
- agent_version = ENV [ 'MATRIX_TARGET' ] . chomp
150
- else
151
- agent_version = 'puppet7'
152
- end
153
-
154
- Rake ::Task [ 'litmus:provision' ] . invoke ( 'docker' , 'litmusimage/centos:7' )
155
-
156
- Rake ::Task [ 'litmus:install_agent' ] . invoke ( agent_version . to_s )
157
-
158
- Rake ::Task [ 'litmus:install_modules_from_directory' ] . invoke ( './spec/fixtures/acceptance/modules' )
159
-
160
- Rake ::Task [ 'litmus:install_gems' ] . invoke
161
-
162
- Rake ::Task [ 'litmus:acceptance:parallel' ] . invoke
163
-
164
- rescue StandardError => e
165
- puts e . message
166
- raise e
167
- end
168
-
169
- end
0 commit comments