beaker-docker 3.1.2 → 3.1.3

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: 06f9fc450f23708d94b3a68993497c7f9f71fa60772b8b78ca7eb5ddd7668416
4
- data.tar.gz: abb226ed9841f2d44801729924e6ed38f2c4dfe8067b2379875d21006e04442c
3
+ metadata.gz: 9f1ee5ab53b86ffda7555b85471e7427d811d910ae943fdc60618dc71247780d
4
+ data.tar.gz: b88d72d90e95dbe4a986cf9444fedd2eca6eeee3c59efea73ad1e044afe72da0
5
5
  SHA512:
6
- metadata.gz: 3cb84d39f6f5781dffb3fa7e4f90c22d6289d4a2f94813eabc68fcc189ad751d16640b79b6d102347908167eb72bbe07a721519a9598939a1e1302ebd1328da2
7
- data.tar.gz: f5fb1783aead6963196fa14e3a73195ace14d8f80504e0e7036d05e3b0e8243d4d81961dca38506db2554e581f8c57a166178fe1f652625b165bb787eb3264cb
6
+ metadata.gz: 404f1d4b7d9c644583a76d4e4be545c613126d80be170b464a69a64d54abaec614697b728ffb52685d0c29bdca0970f2df3d9cfb6711ac3071d7433e3be196fa
7
+ data.tar.gz: c0634e2844595b1e691042ad3f65041fffa9a218e47c47214ddb9eff0de1d1ba4569a692a2c27d74cd09927be3a609e1648f825caf34e06b68ce68cdc8f7b7fc
@@ -15,16 +15,16 @@ jobs:
15
15
  name: Build the gem
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v6
18
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19
19
  - name: Install Ruby
20
- uses: ruby/setup-ruby@v1
20
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
21
21
  with:
22
22
  ruby-version: 'ruby'
23
23
  - name: Build gem
24
24
  shell: bash
25
25
  run: gem build --verbose *.gemspec
26
26
  - name: Upload gem to GitHub cache
27
- uses: actions/upload-artifact@v7
27
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
28
28
  with:
29
29
  name: gem-artifact
30
30
  path: '*.gem'
@@ -39,7 +39,7 @@ jobs:
39
39
  contents: write # clone repo and create release
40
40
  steps:
41
41
  - name: Download gem from GitHub cache
42
- uses: actions/download-artifact@v8
42
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
43
43
  with:
44
44
  name: gem-artifact
45
45
  - name: Create Release
@@ -56,7 +56,7 @@ jobs:
56
56
  packages: write # publish to rubygems.pkg.github.com
57
57
  steps:
58
58
  - name: Download gem from GitHub cache
59
- uses: actions/download-artifact@v8
59
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
60
60
  with:
61
61
  name: gem-artifact
62
62
  - name: Publish gem to GitHub packages
@@ -73,10 +73,10 @@ jobs:
73
73
  id-token: write # rubygems.org authentication
74
74
  steps:
75
75
  - name: Download gem from GitHub cache
76
- uses: actions/download-artifact@v8
76
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
77
77
  with:
78
78
  name: gem-artifact
79
- - uses: rubygems/configure-rubygems-credentials@v1.0.0
79
+ - uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0
80
80
  - name: Publish gem to rubygems.org
81
81
  shell: bash
82
82
  run: gem push *.gem
@@ -92,11 +92,11 @@ jobs:
92
92
  - release-to-rubygems
93
93
  steps:
94
94
  - name: Download gem from GitHub cache
95
- uses: actions/download-artifact@v8
95
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
96
96
  with:
97
97
  name: gem-artifact
98
98
  - name: Install Ruby
99
- uses: ruby/setup-ruby@v1
99
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
100
100
  with:
101
101
  ruby-version: 'ruby'
102
102
  - name: Wait for release to propagate
@@ -16,16 +16,16 @@ jobs:
16
16
  outputs:
17
17
  ruby: ${{ steps.ruby.outputs.versions }}
18
18
  steps:
19
- - uses: actions/checkout@v6
19
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
20
20
  - name: Install Ruby 4.0
21
- uses: ruby/setup-ruby@v1
21
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
22
22
  with:
23
23
  ruby-version: '4.0'
24
24
  bundler-cache: true
25
25
  - name: Run Rubocop
26
26
  run: bundle exec rake rubocop
27
27
  - id: ruby
28
- uses: voxpupuli/ruby-version@v2
28
+ uses: voxpupuli/ruby-version@be0467ce7366d206b2e87f5b7a032a030120b7cb # 2.0.0
29
29
 
30
30
  rspec:
31
31
  runs-on: ubuntu-24.04
@@ -36,9 +36,9 @@ jobs:
36
36
  ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
37
37
  name: RSpec - Ruby ${{ matrix.ruby }}
38
38
  steps:
39
- - uses: actions/checkout@v6
39
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
40
40
  - name: Install Ruby ${{ matrix.ruby }}
41
- uses: ruby/setup-ruby@v1
41
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
42
42
  with:
43
43
  ruby-version: ${{ matrix.ruby }}
44
44
  bundler-cache: true
@@ -56,9 +56,9 @@ jobs:
56
56
  ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }}
57
57
  name: Docker on Ruby ${{ matrix.ruby }}
58
58
  steps:
59
- - uses: actions/checkout@v6
59
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
60
60
  - name: Install Ruby ${{ matrix.ruby }}
61
- uses: ruby/setup-ruby@v1
61
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
62
62
  with:
63
63
  ruby-version: ${{ matrix.ruby }}
64
64
  bundler-cache: true
@@ -71,7 +71,7 @@ jobs:
71
71
  # needs: rubocop_and_matrix
72
72
  # name: Docker - Beaker in container connection test
73
73
  # steps:
74
- # - uses: actions/checkout@v6
74
+ # - uses: actions/checkout@v7
75
75
  # # use this and not container key from gha to not have a docker network from github
76
76
  # - name: Run Beaker in docker container
77
77
  # uses: addnab/docker-run-action@v3
@@ -99,9 +99,9 @@ jobs:
99
99
  run: |
100
100
  sudo systemctl stop docker.service docker.socket && systemctl start --user podman.socket
101
101
  echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV"
102
- - uses: actions/checkout@v6
102
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
103
103
  - name: Install Ruby ${{ matrix.ruby }}
104
- uses: ruby/setup-ruby@v1
104
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
105
105
  with:
106
106
  ruby-version: ${{ matrix.ruby }}
107
107
  bundler-cache: true
@@ -109,6 +109,7 @@ jobs:
109
109
  run: bundle exec rake test:acceptance
110
110
 
111
111
  tests:
112
+ if: always()
112
113
  needs:
113
114
  - rubocop_and_matrix
114
115
  - docker
@@ -118,4 +119,7 @@ jobs:
118
119
  runs-on: ubuntu-24.04
119
120
  name: Test suite
120
121
  steps:
121
- - run: echo Test suite completed
122
+ - name: Decide whether the needed jobs succeeded or failed
123
+ uses: re-actors/alls-green@release/v1
124
+ with:
125
+ jobs: ${{ toJSON(needs) }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.1.3](https://github.com/voxpupuli/beaker-docker/tree/3.1.3) (2026-08-21)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/3.1.2...3.1.3)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Fix ssh connection routing under Podman: network naming and container detection [\#194](https://github.com/voxpupuli/beaker-docker/pull/194) ([miharp](https://github.com/miharp))
10
+
11
+ **Closed issues:**
12
+
13
+ - `in_container?` only checks `/.dockerenv`, so the gateway connection path never triggers under Podman [\#193](https://github.com/voxpupuli/beaker-docker/issues/193)
14
+ - `DOCKER_IN_DOCKER=true` crashes with NoMethodError on Podman 5: `Networks[NetworkMode]` lookup assumes Docker's network naming [\#192](https://github.com/voxpupuli/beaker-docker/issues/192)
15
+
3
16
  ## [3.1.2](https://github.com/voxpupuli/beaker-docker/tree/3.1.2) (2026-02-27)
4
17
 
5
18
  [Full Changelog](https://github.com/voxpupuli/beaker-docker/compare/3.1.1...3.1.2)
data/docker.md CHANGED
@@ -200,4 +200,17 @@ The tests should then run as normal from there.
200
200
 
201
201
 
202
202
  ### Docker-in-Docker (dind) ###
203
- If you are using docker in docker, set the environment variable DOCKER_IN_DOCKER=true. Beaker-docker will then not try to use the DOCKER_HOST address for the ssh connection to the containers.
203
+ If beaker itself runs inside a container (for example in a CI job) and the test
204
+ containers are created as siblings on the same host, beaker-docker detects
205
+ this automatically (via `/.dockerenv` on docker or `/run/.containerenv` on
206
+ podman) and connects through the bridge gateway and each test container's
207
+ published ssh port. No configuration is needed as long as the published port
208
+ is reachable via the gateway address.
209
+
210
+ If gateway routing does not work in your environment (ssh port not published
211
+ to the host, or a firewall blocking traffic to the gateway), set the
212
+ environment variable DOCKER_IN_DOCKER=true. Beaker-docker then ignores the
213
+ DOCKER_HOST address and published ports, and connects to each test
214
+ container's network IP directly; make sure the beaker container is attached
215
+ to the same network as the test containers. This works with podman as well
216
+ as docker, and is also enabled automatically under WSL.
@@ -153,7 +153,7 @@ module Beaker
153
153
  gw = network_settings['Gateway']
154
154
 
155
155
  # also handle scenarios where network_settings['Gateway'] is not set (e.g. docker-ce >= v29)
156
- gw = network_settings['Networks'][host_config['NetworkMode']]['Gateway'] if gw.nil? || gw.empty?
156
+ gw = container_network(network_settings, host_config)['Gateway'] if gw.nil? || gw.empty?
157
157
 
158
158
  ip = gw unless gw.nil? || gw.empty?
159
159
  else
@@ -170,7 +170,7 @@ module Beaker
170
170
  unless ip && port
171
171
  ip = network_settings['IPAddress'] # podman
172
172
  # also handle scenarios where network_settings['IPAddress'] is not set (e.g. docker-ce >= v29)
173
- ip = network_settings['Networks'][host_config['NetworkMode']]['IPAddress'] if ip.nil? || ip.empty?
173
+ ip = container_network(network_settings, host_config)['IPAddress'] if ip.nil? || ip.empty?
174
174
  port = (ip && !ip.empty?) ? 22 : nil
175
175
  end
176
176
 
@@ -363,7 +363,7 @@ module Beaker
363
363
  host_config = container.json['HostConfig']
364
364
  vm_ip = container.json['NetworkSettings']['IPAddress']
365
365
  # handle scenarios where network_settings['IPAddress'] is not set (e.g. docker-ce >= v29)
366
- vm_ip = container.json['NetworkSettings']['Networks'][host_config['NetworkMode']]['IPAddress'] if vm_ip.nil? || vm_ip.empty?
366
+ vm_ip = container_network(container.json['NetworkSettings'], host_config)['IPAddress'] if vm_ip.nil? || vm_ip.empty?
367
367
  host['vm_ip'] = vm_ip.to_s
368
368
 
369
369
  def host.reboot
@@ -463,6 +463,15 @@ module Beaker
463
463
 
464
464
  private
465
465
 
466
+ # Look up the network a container is attached to. Podman's Docker-compatible
467
+ # API reports HostConfig.NetworkMode as 'bridge' but keys
468
+ # NetworkSettings.Networks by the actual network name, so fall back to the
469
+ # first attached network when the NetworkMode key is missing.
470
+ def container_network(network_settings, host_config)
471
+ networks = network_settings['Networks'] || {}
472
+ networks[host_config['NetworkMode']] || networks.values.first || {}
473
+ end
474
+
466
475
  def root_password
467
476
  'root'
468
477
  end
@@ -639,9 +648,9 @@ module Beaker
639
648
  nil
640
649
  end
641
650
 
642
- # return true if we are inside a docker container
651
+ # return true if we are inside a docker or podman container
643
652
  def in_container?
644
- File.file?('/.dockerenv')
653
+ File.file?('/.dockerenv') || File.file?('/run/.containerenv')
645
654
  end
646
655
  end
647
656
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeakerDocker
4
- VERSION = '3.1.2'
4
+ VERSION = '3.1.3'
5
5
  end
@@ -686,6 +686,17 @@ module Beaker
686
686
  expect(hosts[0]['port']).to eq 8022
687
687
  end
688
688
  end
689
+
690
+ it 'connects to gateway ip inside a podman container' do
691
+ FakeFS do
692
+ FileUtils.mkdir_p('/run')
693
+ FileUtils.touch('/run/.containerenv')
694
+ docker.provision
695
+
696
+ expect(hosts[0]['ip']).to eq '192.0.2.254'
697
+ expect(hosts[0]['port']).to eq 8022
698
+ end
699
+ end
689
700
  end
690
701
  end
691
702
 
@@ -739,6 +750,51 @@ module Beaker
739
750
  end
740
751
  end
741
752
  end
753
+
754
+ context 'when using podman where Networks is keyed by network name instead of NetworkMode' do
755
+ let(:container_config) do
756
+ {
757
+ 'HostConfig' => {
758
+ 'NetworkMode' => 'bridge',
759
+ },
760
+ 'NetworkSettings' => {
761
+ 'Ports' => {
762
+ '22/tcp' => [
763
+ {
764
+ 'HostIp' => '0.0.0.0',
765
+ 'HostPort' => 8022,
766
+ },
767
+ ],
768
+ },
769
+ 'Networks' => {
770
+ 'podman' => {
771
+ 'Gateway' => '192.0.2.254',
772
+ 'IPAddress' => '192.0.2.10',
773
+ },
774
+ },
775
+ },
776
+ }
777
+ end
778
+
779
+ it 'falls back to the first network for the container IP' do
780
+ ENV['DOCKER_IN_DOCKER'] = 'true'
781
+ docker.provision
782
+
783
+ expect(hosts[0]['ip']).to eq '192.0.2.10'
784
+ expect(hosts[0]['port']).to eq 22
785
+ expect(hosts[0]['vm_ip']).to eq '192.0.2.10'
786
+ end
787
+
788
+ it 'still connects via the published port from the host' do
789
+ ENV['DOCKER_IN_DOCKER'] = nil
790
+ ENV['DOCKER_HOST'] = nil
791
+ docker.provision
792
+
793
+ expect(hosts[0]['ip']).to eq '127.0.0.1'
794
+ expect(hosts[0]['port']).to eq 8022
795
+ expect(hosts[0]['vm_ip']).to eq '192.0.2.10'
796
+ end
797
+ end
742
798
  end
743
799
 
744
800
  it 'generates a new /etc/hosts file referencing each host' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  - !ruby/object:Gem::Version
219
219
  version: '0'
220
220
  requirements: []
221
- rubygems_version: 4.0.3
221
+ rubygems_version: 4.0.16
222
222
  specification_version: 4
223
223
  summary: Docker hypervisor for Beaker acceptance testing framework
224
224
  test_files: []