all_images 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e58fc4d0a7eb29b0274ab8aa0cd4b8041776117b420a1829b6fd835d22eb4ca9
4
- data.tar.gz: f2ca6a25f6ce4f9f64d8fc4055d7af2b20c27df57b0392529062acee03e8b77f
3
+ metadata.gz: 4dcdc93b7a13b4553302d63dd2ff1cdd34c5e795d4b45119df2d54454b8c2dac
4
+ data.tar.gz: 0f6743c6e1f723596ea7749e76811815511175852f215dc9b9e74fbe20968df5
5
5
  SHA512:
6
- metadata.gz: b015ad6ac137692cf63b5186730ed6bbc769a2483896fffb9549579f64bfb3363a0696461e685bf50fe35910e1b4015e175e2ddea042af2dbeb144b5a825e03b
7
- data.tar.gz: 9bbf5d90bd4cf98de782158bdd91173d5990b7864d95a3659baf1060a19fb0310cc0ebf24f3d7e43fff749f2bc1273cf0fa101984de046511e0003061655e325
6
+ metadata.gz: 7eba1f686ff9afdad5f01dae94ae17648b610a29155552aef157b90f82ce36b161550b457c3cbb10044f31007abce36b1b8eb25756f932b1976cb2bc815dbecc
7
+ data.tar.gz: 31496325b74e67a0bbd0c414375aade96b6e0ba798d0c88910ba2c6e239d48106e4cf10320ab467d83f75a4e91e89faaa7fa13eaa4a815f28d6a494c05f1e1e1
data/CHANGES.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-01-17 v0.12.0
4
+
5
+ - Added new **before** and **after** configuration hooks in `.all_images.yml`
6
+ for pre/post execution functionality
7
+ - Introduced `RESULT` environment variable to enable post-execution decision
8
+ making in hooks
9
+ - Enhanced `sh` method with `crash: false` option to allow non-fatal hook execution
10
+ - Updated `run_image` method to execute hooks and track test results
11
+ - Updated README documentation for the new hook functionality
12
+ - Updated `rubygems_version` from **4.0.2** to **4.0.3**
13
+ - Updated `gem_hadar` development dependency from **>= 2.16.3** to **>=
14
+ 2.17.0**
15
+
16
+ ## 2026-01-02 v0.11.2
17
+
18
+ - Updated rake execution to use `bundle exec` for consistent dependency
19
+ management
20
+
3
21
  ## 2026-01-02 v0.11.1
4
22
 
5
23
  - Handle `nil` configuration gracefully when retrieving images to improve
data/README.md CHANGED
@@ -215,6 +215,32 @@ all_images run
215
215
  # Shows searchable list of available images
216
216
  ```
217
217
 
218
+ ### Pre/Post Execution Hooks 🔄
219
+
220
+ AllImages supports pre/post execution hooks in your configuration:
221
+
222
+ ```yaml
223
+ before: |-
224
+ echo 🏁 Preparing…
225
+ echo Deleting Gemfile.lock
226
+ rm -f Gemfile.lock
227
+
228
+ after: |-
229
+ if [[ "$RESULT" = "1" ]]
230
+ then
231
+ echo 😵 Some tests failed!
232
+ else
233
+ echo 🥳 All tests passed!
234
+ fi
235
+
236
+ # ... rest of your configuration
237
+ ```
238
+
239
+ - `before` hook runs before each image execution
240
+ - `after` hook runs after each image execution with `RESULT` environment variable
241
+ - `RESULT` indicates success (0) or failure (1) of the test script
242
+ - Hooks are non-fatal (won't stop the workflow if they fail)
243
+
218
244
  ## Error Handling ⚠️
219
245
 
220
246
  AllImages provides comprehensive error handling for common scenarios:
data/all_images.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: all_images 0.11.1 ruby lib
2
+ # stub: all_images 0.12.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "all_images".freeze
6
- s.version = "0.11.1".freeze
6
+ s.version = "0.12.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -17,13 +17,13 @@ Gem::Specification.new do |s|
17
17
  s.homepage = "https://github.com/flori/all_images".freeze
18
18
  s.licenses = ["MIT".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "AllImages -- Runs a script in all of the docker images".freeze, "--main".freeze, "README.md".freeze]
20
- s.rubygems_version = "4.0.2".freeze
20
+ s.rubygems_version = "4.0.3".freeze
21
21
  s.summary = "Runs a script in all of the docker images".freeze
22
22
  s.test_files = ["spec/app_spec.rb".freeze, "spec/spec_helper.rb".freeze]
23
23
 
24
24
  s.specification_version = 4
25
25
 
26
- s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.16.3".freeze])
26
+ s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.17.0".freeze])
27
27
  s.add_development_dependency(%q<rake>.freeze, [">= 0".freeze])
28
28
  s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
29
29
  s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
@@ -116,27 +116,15 @@ class AllImages::App
116
116
  }
117
117
  end
118
118
 
119
- # Executes a system command and handles its result
120
- #
121
- # This method runs a given system command with the provided arguments,
122
- # optionally logging the execution when debug mode is enabled. It checks the
123
- # command's exit status and raises an exception if the command fails,
124
- # otherwise returning true to indicate success.
125
- #
126
- # @param a [ Array<String> ] the command and its arguments to be executed
127
- #
128
- # @return [ TrueClass ] when the command executes successfully
129
- #
130
- # @raise [ RuntimeError ] if the executed command exits with a non-zero status
131
- def sh(*a)
119
+ def sh(script, crash: true)
132
120
  if $DEBUG
133
121
  STDERR.puts "Executing #{a.inspect}."
134
122
  end
135
- system(*a)
123
+ system(script)
136
124
  if $?.success?
137
125
  true
138
- else
139
- raise "Command #{Shellwords.join(a).inspect} failed with: #{$?.exitstatus}"
126
+ elsif crash
127
+ raise "Command #{script.inspect} failed with: #{$?.exitstatus}"
140
128
  end
141
129
  end
142
130
 
@@ -165,25 +153,33 @@ class AllImages::App
165
153
  #
166
154
  # @return [ Integer ] exit code indicating success (0) or failure (1) of the script execution
167
155
  def run_image(image, script, interactive: false)
156
+ if before = @config['before']
157
+ sh before
158
+ end
168
159
  dockerfile = @config.fetch('dockerfile').to_s
169
160
  tag = provide_image image, dockerfile, script
170
161
  envs = env.full? { |e| +' ' << e.map { |n, v| '-e %s=%s' % [ n, v.inspect ] } * ' ' }
162
+ result = 1
171
163
  if interactive
172
164
  puts "You can run /script interactively now."
173
- sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh"
174
- return 0
165
+ sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh", crash: true
166
+ result = nil
175
167
  else
176
168
  info_puts "Running container #{name.inspect} for image tagged #{tag.inspect}."
177
- if sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh -c /script"
169
+ if sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh -c /script", crash: false
178
170
  info_puts "Image tagged #{tag.inspect} was run with result:"
179
171
  puts green('SUCCESS')
180
- return 0
172
+ result = 0
181
173
  else
182
174
  info_puts "Image tagged #{tag.inspect} was run with result:"
183
175
  puts red('FAILURE')
184
- return 1
185
176
  end
186
177
  end
178
+ if result and after = @config['after']
179
+ ENV['RESULT'] = result.to_s
180
+ sh after, crash: false
181
+ end
182
+ result.to_i
187
183
  ensure
188
184
  sh "docker rm -f #{name} >/dev/null"
189
185
  end
@@ -28,7 +28,7 @@ module AllImages::Config
28
28
  echo -e "\\e[0m"
29
29
  bundle update --all
30
30
  bundle install --jobs=$(getconf _NPROCESSORS_ONLN)
31
- rake spec
31
+ bundle exec rake spec
32
32
 
33
33
  fail_fast: true
34
34
 
@@ -1,6 +1,6 @@
1
1
  module AllImages
2
2
  # AllImages version
3
- VERSION = '0.11.1'
3
+ VERSION = '0.12.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/spec/app_spec.rb CHANGED
@@ -4,4 +4,8 @@ RSpec.describe AllImages::App do
4
4
  it 'can be instantiated' do
5
5
  expect(described_class.new([])).to be_a described_class
6
6
  end
7
+
8
+ xit 'can fail' do
9
+ expect(true).to eq false
10
+ end
7
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: all_images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 2.16.3
18
+ version: 2.17.0
19
19
  type: :development
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 2.16.3
25
+ version: 2.17.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
213
  requirements: []
214
- rubygems_version: 4.0.2
214
+ rubygems_version: 4.0.3
215
215
  specification_version: 4
216
216
  summary: Runs a script in all of the docker images
217
217
  test_files: