all_images 0.11.2 → 0.13.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 +4 -4
- data/CHANGES.md +26 -0
- data/README.md +26 -0
- data/all_images.gemspec +4 -4
- data/lib/all_images/app.rb +23 -23
- data/lib/all_images/version.rb +1 -1
- data/spec/app_spec.rb +14 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d26f310a9f016d361cdbc1656b151341913bbafade960d047a53283c8af5a19
|
|
4
|
+
data.tar.gz: 24c7dc7114d65cc4ecee26550a4c943ac225cb701ea858b6a178a25019c88014
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 00d46aa18f3f390e77cc0355a15da0798c5ed2d2d7a941f5467a23df158964a8846be45cf4183d981ba575c564c2056168db9a4dd726fe7c2af62d7e1d30fd76
|
|
7
|
+
data.tar.gz: 2ee0b04f24de5e8c60bb49d46d3efd24a1ddc2b4fc283f651beab95861f3dfad6546dbbd9ed5bb559f362efda1a479a7f9ecdea9f7c860aa47b17da322a1b9c6
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-10-08 v0.13.0
|
|
4
|
+
|
|
5
|
+
* Fixed `#env` to stop mutating `@config`; `env_hash` is now built immutably,
|
|
6
|
+
`ALL_IMAGES` is set to `?1` unconditionally, and the host `TERM` is used
|
|
7
|
+
only as a fallback when absent.
|
|
8
|
+
* Added an `env:` section to `.all_images.yml` pinning `TERM=xterm`,
|
|
9
|
+
`COLUMNS=80`, and `LINES=25`.
|
|
10
|
+
* Added specs in `spec/app_spec.rb` to assert `COLUMNS`, `LINES`, and `TERM`
|
|
11
|
+
inside the container, guarded by `skip 'not in all images'`.
|
|
12
|
+
* Updated `all_images.gemspec` to set `rubygems_version` to **4.0.22** and
|
|
13
|
+
require `gem_hadar` >= **2.18.0**.
|
|
14
|
+
* Added steps to `.all_images.yml` to remove `Gemfile.lock` during CI.
|
|
15
|
+
|
|
16
|
+
## 2026-01-17 v0.12.0
|
|
17
|
+
|
|
18
|
+
- Added new **before** and **after** configuration hooks in `.all_images.yml`
|
|
19
|
+
for pre/post execution functionality
|
|
20
|
+
- Introduced `RESULT` environment variable to enable post-execution decision
|
|
21
|
+
making in hooks
|
|
22
|
+
- Enhanced `sh` method with `crash: false` option to allow non-fatal hook execution
|
|
23
|
+
- Updated `run_image` method to execute hooks and track test results
|
|
24
|
+
- Updated README documentation for the new hook functionality
|
|
25
|
+
- Updated `rubygems_version` from **4.0.2** to **4.0.3**
|
|
26
|
+
- Updated `gem_hadar` development dependency from **>= 2.16.3** to **>=
|
|
27
|
+
2.17.0**
|
|
28
|
+
|
|
3
29
|
## 2026-01-02 v0.11.2
|
|
4
30
|
|
|
5
31
|
- Updated rake execution to use `bundle exec` for consistent dependency
|
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.
|
|
2
|
+
# stub: all_images 0.13.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "all_images".freeze
|
|
6
|
-
s.version = "0.
|
|
6
|
+
s.version = "0.13.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.
|
|
20
|
+
s.rubygems_version = "4.0.22".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.
|
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.18.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])
|
data/lib/all_images/app.rb
CHANGED
|
@@ -105,8 +105,7 @@ class AllImages::App
|
|
|
105
105
|
# @return [ Hash ] a hash mapping environment variable names to their values
|
|
106
106
|
def env
|
|
107
107
|
vars = @config.fetch('env', [])
|
|
108
|
-
|
|
109
|
-
vars.each_with_object({}) { |v, h|
|
|
108
|
+
env_hash = vars.each_with_object({}) { |v, h|
|
|
110
109
|
name, value = v.split(?=, 2)
|
|
111
110
|
if value
|
|
112
111
|
h[name] = value
|
|
@@ -114,29 +113,22 @@ class AllImages::App
|
|
|
114
113
|
h[name] = ENV[name]
|
|
115
114
|
end
|
|
116
115
|
}
|
|
116
|
+
if !env_hash.key?('TERM') && ENV['TERM']
|
|
117
|
+
env_hash['TERM'] = ENV['TERM']
|
|
118
|
+
end
|
|
119
|
+
env_hash['ALL_IMAGES'] = ?1
|
|
120
|
+
env_hash
|
|
117
121
|
end
|
|
118
122
|
|
|
119
|
-
|
|
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)
|
|
123
|
+
def sh(script, crash: true)
|
|
132
124
|
if $DEBUG
|
|
133
125
|
STDERR.puts "Executing #{a.inspect}."
|
|
134
126
|
end
|
|
135
|
-
system(
|
|
127
|
+
system(script)
|
|
136
128
|
if $?.success?
|
|
137
129
|
true
|
|
138
|
-
|
|
139
|
-
raise "Command #{
|
|
130
|
+
elsif crash
|
|
131
|
+
raise "Command #{script.inspect} failed with: #{$?.exitstatus}"
|
|
140
132
|
end
|
|
141
133
|
end
|
|
142
134
|
|
|
@@ -165,25 +157,33 @@ class AllImages::App
|
|
|
165
157
|
#
|
|
166
158
|
# @return [ Integer ] exit code indicating success (0) or failure (1) of the script execution
|
|
167
159
|
def run_image(image, script, interactive: false)
|
|
160
|
+
if before = @config['before']
|
|
161
|
+
sh before
|
|
162
|
+
end
|
|
168
163
|
dockerfile = @config.fetch('dockerfile').to_s
|
|
169
164
|
tag = provide_image image, dockerfile, script
|
|
170
165
|
envs = env.full? { |e| +' ' << e.map { |n, v| '-e %s=%s' % [ n, v.inspect ] } * ' ' }
|
|
166
|
+
result = 1
|
|
171
167
|
if interactive
|
|
172
168
|
puts "You can run /script interactively now."
|
|
173
|
-
sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh"
|
|
174
|
-
|
|
169
|
+
sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh", crash: true
|
|
170
|
+
result = nil
|
|
175
171
|
else
|
|
176
172
|
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"
|
|
173
|
+
if sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh -c /script", crash: false
|
|
178
174
|
info_puts "Image tagged #{tag.inspect} was run with result:"
|
|
179
175
|
puts green('SUCCESS')
|
|
180
|
-
|
|
176
|
+
result = 0
|
|
181
177
|
else
|
|
182
178
|
info_puts "Image tagged #{tag.inspect} was run with result:"
|
|
183
179
|
puts red('FAILURE')
|
|
184
|
-
return 1
|
|
185
180
|
end
|
|
186
181
|
end
|
|
182
|
+
if result and after = @config['after']
|
|
183
|
+
ENV['RESULT'] = result.to_s
|
|
184
|
+
sh after, crash: false
|
|
185
|
+
end
|
|
186
|
+
result.to_i
|
|
187
187
|
ensure
|
|
188
188
|
sh "docker rm -f #{name} >/dev/null"
|
|
189
189
|
end
|
data/lib/all_images/version.rb
CHANGED
data/spec/app_spec.rb
CHANGED
|
@@ -4,4 +4,18 @@ 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
|
|
11
|
+
|
|
12
|
+
it 'has columns and lines' do
|
|
13
|
+
skip 'not in all images' if ENV['ALL_IMAGES'].to_i == 0
|
|
14
|
+
expect(ENV.values_at('COLUMNS', 'LINES')).to eq %w[ 80 25 ]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'has term' do
|
|
18
|
+
skip 'not in all images' if ENV['ALL_IMAGES'].to_i == 0
|
|
19
|
+
expect(ENV['TERM']).to eq 'xterm'
|
|
20
|
+
end
|
|
7
21
|
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.
|
|
4
|
+
version: 0.13.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.
|
|
18
|
+
version: 2.18.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.
|
|
25
|
+
version: 2.18.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.
|
|
214
|
+
rubygems_version: 4.0.22
|
|
215
215
|
specification_version: 4
|
|
216
216
|
summary: Runs a script in all of the docker images
|
|
217
217
|
test_files:
|