Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@test-kitchen/maintainers
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Lint & Unit
name: 'Lint, Unit & Integration Tests'

"on":
pull_request:
Expand All @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
suite: [default]
os: [ubuntu-20.04]
os: [ubuntu-24.04]
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
Expand All @@ -25,6 +25,8 @@ jobs:
bundler-cache: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
driver: docker
- run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }}

integration-linux:
Expand Down Expand Up @@ -81,7 +83,10 @@ jobs:
matrix:
suite:
- capabilities
os: [ubuntu-2004, ubuntu-2204, ubuntu-2404]
os:
- ubuntu-2204
- ubuntu-2404
- ubuntu-2604
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ jobs:
- uses: googleapis/release-please-action@v5
id: release
with:
release-type: ruby
package-name: kitchen-docker
version-file: lib/kitchen/driver/docker_version.rb
token: ${{ secrets.PORTER_GITHUB_TOKEN }}

- name: Checkout
Expand Down
8 changes: 3 additions & 5 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
default: true
MD004: false
MD012: false
MD013: false
MD024: false
MD026: false
MD036: false
MD012: false
MD029: false
MD004: false
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "3.2.2"
}
5 changes: 2 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
require:
- chefstyle
- cookstyle/chefstyle

AllCops:
TargetRubyVersion: 3.1
Include:
- "**/*.rb"
Exclude:
- "vendor/**/*"
- "spec/**/*"
21 changes: 12 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gemspec

group :development do
gem 'kitchen-inspec', '~> 3.0'
gem 'train', '>= 2.1', '< 4.0' # validate 4.x when it's released
# Integration testing gems.
gem "kitchen-cinc-auditor", git: "https://github.com/test-kitchen/kitchen-cinc-auditor.git"
gem "cinc-auditor-bin", source: "https://rubygems.cinc.sh"
gem "kitchen-cinc"
gem "train", ">= 2.1", "< 4.0" # validate 4.x when it's released
end

group :test do
gem 'bundler'
gem 'rake'
gem 'rspec', '~> 3.2'
gem 'rspec-its', '~> 2.0'
gem "bundler"
gem "rake"
gem "rspec", "~> 3.2"
gem "rspec-its", "~> 2.0"
end

group :chefstyle do
gem 'chefstyle', '~> 2.2', '>= 2.2.3'
group :cookstyle do
gem "cookstyle"
end
33 changes: 21 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
require "bundler/gem_tasks"

# Create the spec task.
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:test, :tag) do |t, args|
t.rspec_opts = [].tap do |a|
a << "--color"
a << "--format #{ENV["CI"] ? "documentation" : "progress"}"
a << "--backtrace" if ENV["VERBOSE"] || ENV["DEBUG"]
a << "--seed #{ENV["SEED"]}" if ENV["SEED"]
a << "--tag #{args[:tag]}" if args[:tag]
a << "--default-path test"
a << "-I test/spec"
end.join(" ")
require "rake/testtask"
Rake::TestTask.new(:unit) do |t|
t.libs.push "lib"
t.test_files = FileList["spec/**/*_spec.rb"]
t.verbose = true
t.warning = false
end

desc "Run all unit tests"
task test: %i{unit}

begin
require "cookstyle/chefstyle"
require "rubocop/rake_task"
RuboCop::RakeTask.new(:style) do |task|
task.options += ["--display-cop-names", "--no-color"]
end
rescue LoadError
puts "cookstyle/chefstyle is not available. (sudo) gem install cookstyle to do style checking."
end

task default: %i{style test}
3 changes: 1 addition & 2 deletions kitchen-docker.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib = File.expand_path("lib", __FILE__)
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "kitchen/docker/docker_version"

Expand All @@ -13,7 +13,6 @@ Gem::Specification.new do |spec|
spec.license = "Apache 2.0"

spec.files = `git ls-files`.split($/)
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency "test-kitchen", ">= 1.0.0", "< 5.0"
Expand Down
6 changes: 2 additions & 4 deletions kitchen.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ transport:
socket: tcp://localhost:2375

provisioner:
name: dummy
name: cinc_infra

platforms:
- name: windows
driver_config:
image: mcr.microsoft.com/windows/servercore:1809
image: mcr.microsoft.com/windows/servercore:ltsc2022
platform: windows

suites:
Expand All @@ -27,7 +27,5 @@ suites:
driver:
build_context: false
- name: inspec
driver:
provision_command: echo 1
verifier:
name: inspec
26 changes: 17 additions & 9 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
---
driver:
name: docker
provision_command: curl -L https://www.chef.io/chef/install.sh | bash

transport:
name: docker

provisioner:
name: dummy
name: cinc_infra

verifier:
name: cinc_auditor

platforms:
- name: amazonlinux-2
- name: ubuntu-20.04
- name: almalinux-9
- name: almalinux-10
- name: amazonlinux-2023
- name: ubuntu-22.04
- name: ubuntu-24.04
- name: ubuntu-26.04
- name: fedora-latest
driver:
provision_command:
Expand All @@ -25,14 +29,18 @@ platforms:
- name: centos-stream-9
driver:
image: dokken/centos-stream-9
- name: oraclelinux-7
- name: centos-stream-10
driver:
image: dokken/centos-stream-10
- name: oraclelinux-8
- name: oraclelinux-9
- name: oraclelinux-10
- name: rockylinux-9
- name: debian-12
- name: opensuse-15
- name: rockylinux-10
- name: debian-13
- name: opensuse-16
driver:
image: opensuse/leap:15
image: opensuse/leap:16
- name: dockerfile
driver:
username: dockerfile
Expand All @@ -46,7 +54,7 @@ suites:
driver:
build_context: false
- name: capabilities
includes: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
includes: [ubuntu-22.04, ubuntu-24.04, ubuntu-26.04]
driver:
provision_command:
- curl -L https://www.chef.io/chef/install.sh | bash
Expand Down
24 changes: 12 additions & 12 deletions lib/docker/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

begin
require "docker"

# Override API_VERSION constant in docker-api gem to use version 1.24 of the Docker API
# This override is for the docker-api gem to communicate to the Docker engine on Windows
module Docker
VERSION = "0.0.0".freeze
API_VERSION = "1.24".freeze
end
rescue LoadError => e
logger.debug("[Docker] docker-api gem not found for InSpec verifier. #{e}")
end
# begin
# require "docker"
#
# # Override API_VERSION constant in docker-api gem to use version 1.24 of the Docker API
# # This override is for the docker-api gem to communicate to the Docker engine on Windows
# module Docker
# VERSION = "0.0.0".freeze
# API_VERSION = "1.24".freeze
# end
# rescue LoadError => e
# logger.debug("[Docker] docker-api gem not found for InSpec verifier. #{e}")
# end
2 changes: 1 addition & 1 deletion lib/kitchen/docker/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create(state)
if container_exists?(state)
info("Container ID #{state[:container_id]} already exists.")
elsif !container_exists?(state) && state[:container_id]
raise ActionFailed, "Container ID #{state[:container_id]} was found in the kitchen state data, "\
raise ActionFailed, "Container ID #{state[:container_id]} was found in the kitchen state data, " \
"but the container does not exist."
end

Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/docker/docker_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
module Kitchen
module Docker
# Version string for Docker Kitchen driver
DOCKER_VERSION = "3.0.0".freeze
DOCKER_VERSION = "3.2.2".freeze
end
end
4 changes: 3 additions & 1 deletion lib/kitchen/docker/helpers/container_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def create_dir_on_container(state, path)
cmd = "mkdir -p #{path}"

if state[:platform].include?("windows")
psh = "-Command if(-not (Test-Path \'#{path}\')) { New-Item -Path \'#{path}\' -Force }"
psh = "-Command if(-not (Test-Path '#{path}')) { New-Item -Path '#{path}' -Force }"
cmd = build_powershell_command(psh)
end

Expand Down Expand Up @@ -150,6 +150,7 @@ def remove_container(state)
docker_command("rm #{container_id}")
end

# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def dockerfile_proxy_config
env_variables = ""
if config[:http_proxy]
Expand All @@ -169,6 +170,7 @@ def dockerfile_proxy_config

env_variables
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
end
# rubocop:enable Metrics/ModuleLength, Style/Documentation
end
Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/docker/helpers/image_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def build_image(state, dockerfile)
file.write(dockerfile)
file.close
docker_command("#{cmd} #{build_context}",
input: dockerfile_contents,
environment: { BUILDKIT_PROGRESS: "plain" })
input: dockerfile_contents,
environment: { BUILDKIT_PROGRESS: "plain" })
ensure
file.close unless file.closed?
file.unlink
Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/driver/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Docker < Kitchen::Driver::Base
"ping -t localhost"
end
else
"/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no -o PasswordAuthentication=yes "\
"/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no -o PasswordAuthentication=yes " \
"-o UsePrivilegeSeparation=no -o PidFile=/tmp/sshd.pid"
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/transport/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

require_relative "../docker/helpers/inspec_helper"

require_relative "../../docker/version"
# require_relative "../../docker/version"
require_relative "../../train/docker"

module Kitchen
module Transport
class Docker < Kitchen::Transport::Base
class DockerFailed < TransportFailed; end

kitchen_transport_api_version 1
# kitchen_transport_api_version 1
plugin_version Kitchen::VERSION

default_config :binary, "docker"
Expand Down
2 changes: 1 addition & 1 deletion lib/train/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,5 @@ def run_command_via_connection(cmd, &_data_handler)
end
end
rescue LoadError => e
logger.debug("[Docker] train gem not found for InSpec verifier. #{e}")
warn "[Docker] train gem not found. #{e}"
end
12 changes: 12 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"packages": {
".": {
"package-name": "kitchen-docker",
"changelog-path": "CHANGELOG.md",
"release-type": "ruby",
"include-component-in-tag": false,
"version-file": "lib/kitchen/docker/docker_version.rb"
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
2 changes: 1 addition & 1 deletion test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM almalinux:9
FROM almalinux:latest
RUN dnf clean all
RUN dnf install -y sudo openssh-server openssh-clients which curl htop
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
Expand Down
12 changes: 6 additions & 6 deletions test/integration/default/disabled/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
# limitations under the License.
#

# Disable now busser-serever is gone.
# require 'serverspec'
# require 'spec_helper'

# # Just make sure the image launched and is reachable.
# describe command('true') do
# Disable now busser-server is gone.
# require "serverspec"
# require "spec_helper"
#
# Just make sure the image launched and is reachable.
# describe command("true") do
# its(:exit_status) { is_expected.to eq 0 }
# end
Loading