@@ -34,16 +34,26 @@ DOCKER_PLATFORMS = {
34
34
35
35
# This table uses the latest version in each collection for accurate
36
36
# comparison when evaluating puppet requirements from the metadata
37
- COLLECTION_TABLE = {
38
- '6.24.0' => 'puppet6-nightly' ,
39
- '7.4.0' => 'puppet7-nightly' ,
40
- } . freeze
37
+ COLLECTION_TABLE = [
38
+ {
39
+ puppet_maj_version : 6 ,
40
+ ruby_version : 2.5 ,
41
+ } ,
42
+ {
43
+ puppet_maj_version : 7 ,
44
+ ruby_version : 2.7 ,
45
+ } ,
46
+ ] . freeze
41
47
42
48
matrix = {
43
49
platforms : [ ] ,
44
50
collection : [ ] ,
45
51
}
46
52
53
+ spec_matrix = {
54
+ include : [ ] ,
55
+ }
56
+
47
57
metadata = JSON . parse ( File . read ( 'metadata.json' ) )
48
58
# Set platforms based on declared operating system support
49
59
metadata [ 'operatingsystem_support' ] . sort_by { |a | a [ 'operatingsystem' ] } . each do |sup |
@@ -83,23 +93,32 @@ if metadata.key?('requirements') && metadata['requirements'].length.positive?
83
93
cmp_one , ver_one , cmp_two , ver_two = match . captures
84
94
reqs = [ "#{ cmp_one } #{ ver_one } " , "#{ cmp_two } #{ ver_two } " ]
85
95
86
- COLLECTION_TABLE . each do |key , val |
87
- if Gem ::Requirement . create ( reqs ) . satisfied_by? ( Gem ::Version . new ( key ) )
88
- matrix [ :collection ] << val
89
- end
96
+ COLLECTION_TABLE . each do |collection |
97
+ # Test against the "largest" puppet version in a collection, e.g. `7.9999` to allow puppet requirements with a non-zero lower bound on minor/patch versions.
98
+ # This assumes that such a boundary will always allow the latest actually existing puppet version of a release stream, trading off simplicity vs accuracy here.
99
+ next unless Gem ::Requirement . create ( reqs ) . satisfied_by? ( Gem ::Version . new ( "#{ collection [ :puppet_maj_version ] } .9999" ) )
100
+
101
+ matrix [ :collection ] << "puppet#{ collection [ :puppet_maj_version ] } -nightly"
102
+ spec_matrix [ :include ] << { puppet_version : "~> #{ collection [ :puppet_maj_version ] } .0" , ruby_version : collection [ :ruby_version ] }
90
103
end
91
104
end
92
105
end
93
106
94
107
# Set to defaults (all collections) if no matches are found
95
108
if matrix [ :collection ] . empty?
96
- matrix [ :collection ] = COLLECTION_TABLE . values
109
+ matrix [ :collection ] = COLLECTION_TABLE . map { | collection | "puppet #{ collection [ :puppet_maj_version ] } -nightly" }
97
110
end
98
111
99
112
# Just to make sure there aren't any duplicates
100
113
matrix [ :platforms ] = matrix [ :platforms ] . uniq . sort { |a , b | a [ :label ] <=> b [ :label ] }
101
114
matrix [ :collection ] = matrix [ :collection ] . uniq . sort
102
115
103
116
puts "::set-output name=matrix::#{ JSON . generate ( matrix ) } "
117
+ puts "::set-output name=spec_matrix::#{ JSON . generate ( spec_matrix ) } "
118
+
119
+ acceptance_test_cell_count = matrix [ :platforms ] . length * matrix [ :collection ] . length
120
+ spec_test_cell_count = spec_matrix [ :include ] . length
104
121
105
- puts "Created matrix with #{ matrix [ :platforms ] . length * matrix [ :collection ] . length } cells."
122
+ puts "Created matrix with #{ acceptance_test_cell_count + spec_test_cell_count } cells:"
123
+ puts " - Acceptance Test Cells: #{ acceptance_test_cell_count } "
124
+ puts " - Spec Test Cells: #{ spec_test_cell_count } "
0 commit comments