From ce381fa84d177c63b971c2622c2866f0e975cc03 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 14 Nov 2023 09:28:18 +0000 Subject: [PATCH 1/3] Add CI workflow Signed-off-by: Dan Webb --- .github/dependabot.yml | 10 ++--- .github/workflows/ci.yml | 93 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 452ebb3..9071cbc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,7 @@ version: 2 updates: -- package-ecosystem: bundler - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 + - package-ecosystem: bundler + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0fc7714 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,93 @@ +--- +name: Lint & Unit + +"on": + pull_request: + push: + branches: + - main + +jobs: + yamllint: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Lint YAML + uses: koozz/yamllint-action@main + + chefstyle: + runs-on: ubuntu-latest + strategy: + matrix: + ruby: ["2.7"] + name: Chefstyle on Ruby ${{ matrix.ruby }} + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - uses: r7kamura/rubocop-problem-matchers-action@v1 + - run: bundle exec chefstyle + + unit: + name: Unit test on Ruby ${{ matrix.ruby }} + needs: [yamllint, chefstyle] + runs-on: ubuntu-latest + strategy: + matrix: + ruby: ["2.7", "3.0", "3.1"] + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - run: bundle exec rake spec + + integration-windows: + name: Integration test on Windows + runs-on: windows-latest + needs: unit + strategy: + fail-fast: false + matrix: + suite: [default] + os: [ubuntu-20.04] + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.1" + bundler-cache: true + - run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} + + integration-linux: + name: Integration test on Linux + runs-on: windows-latest + needs: unit + strategy: + fail-fast: false + matrix: + suite: [default, context, capabilities, arm64, amd64, inspec] + os: + - amazonlinux-2 + - ubuntu-18.04 + - ubuntu-20.04 + - fedora-latest + - centos-7 + - centos-8 + - oraclelinux-7 + - rockylinux-8 + - debian-9 + - debian-10 + - opensuse-15 + - dockerfile + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.1" + bundler-cache: true + - run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} From 20213a1baf580bea99257089441b405201177bc6 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 14 Nov 2023 09:39:53 +0000 Subject: [PATCH 2/3] SQUASHME Signed-off-by: Dan Webb --- .github/workflows/ci.yml | 4 ++-- kitchen-docker.gemspec | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fc7714..1a80ab9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,8 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 - - name: Lint YAML - uses: koozz/yamllint-action@main + - name: Run yaml Lint + uses: actionshub/yamllint@main chefstyle: runs-on: ubuntu-latest diff --git a/kitchen-docker.gemspec b/kitchen-docker.gemspec index 08474a9..fdfa674 100644 --- a/kitchen-docker.gemspec +++ b/kitchen-docker.gemspec @@ -32,6 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'fuubar', '~> 2.0' spec.add_development_dependency 'simplecov', '~> 0.9' spec.add_development_dependency 'codecov', '~> 0.0', '>= 0.0.2' + spec.add_development_dependency 'chefstyle' # Integration testing gems. spec.add_development_dependency 'kitchen-inspec', '~> 2.0' From 5e05c44642972a1c0f1db12a42edf7847bf4eeab Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 14 Nov 2023 13:24:53 +0000 Subject: [PATCH 3/3] Rename kitchen dot files Remove erb from the kitchen files. Signed-off-by: Dan Webb --- .github/workflows/ci.yml | 7 +++-- .kitchen.windows.yml | 33 -------------------- .kitchen.yml | 65 ---------------------------------------- .travis.yml | 57 ----------------------------------- .yamllint | 15 ++++++++++ kitchen.windows.yml | 33 ++++++++++++++++++++ kitchen.yml | 65 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 117 insertions(+), 158 deletions(-) delete mode 100644 .kitchen.windows.yml delete mode 100644 .kitchen.yml delete mode 100644 .travis.yml create mode 100644 .yamllint create mode 100644 kitchen.windows.yml create mode 100644 kitchen.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a80ab9..c2955aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,9 +18,10 @@ jobs: chefstyle: runs-on: ubuntu-latest + continue-on-error: true strategy: matrix: - ruby: ["2.7"] + ruby: ["3.1"] name: Chefstyle on Ruby ${{ matrix.ruby }} steps: - uses: actions/checkout@v2 @@ -47,7 +48,7 @@ jobs: - run: bundle exec rake spec integration-windows: - name: Integration test on Windows + name: Windows ${{matrix.suite}} $${{matrix.os}} runs-on: windows-latest needs: unit strategy: @@ -64,7 +65,7 @@ jobs: - run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} integration-linux: - name: Integration test on Linux + name: Linux ${{matrix.suite}} $${{matrix.os}} runs-on: windows-latest needs: unit strategy: diff --git a/.kitchen.windows.yml b/.kitchen.windows.yml deleted file mode 100644 index b58b915..0000000 --- a/.kitchen.windows.yml +++ /dev/null @@ -1,33 +0,0 @@ -<% # Make sure the local copy of the driver is loaded %> -<% lib = File.expand_path('../lib', __FILE__) %> -<% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> ---- -driver: - name: docker - provision_command: - - powershell -ExecutionPolicy Bypass -NoLogo -Command . { iwr -useb https://omnitruck.chef.io/install.ps1 } ^| iex; install - - powershell -Command $path=$env:Path + ';c:\opscode\chef\embedded\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path - -transport: - name: docker - socket: tcp://localhost:2375 - -provisioner: - name: dummy - -platforms: -- name: windows - driver_config: - image: mcr.microsoft.com/windows/servercore:1809 - platform: windows - -suites: -- name: default -- name: context - driver: - build_context: false -- name: inspec - driver: - provision_command: echo 1 - verifier: - name: inspec diff --git a/.kitchen.yml b/.kitchen.yml deleted file mode 100644 index ab46fa8..0000000 --- a/.kitchen.yml +++ /dev/null @@ -1,65 +0,0 @@ -<% # Make sure the local copy of the driver is loaded %> -<% lib = File.expand_path('../lib', __FILE__) %> -<% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> ---- -driver: - name: docker - provision_command: curl -L https://www.chef.io/chef/install.sh | bash - -transport: - name: docker - -provisioner: - name: dummy - -platforms: -- name: amazonlinux-2 -- name: ubuntu-18.04 -- name: ubuntu-20.04 -- name: fedora-latest - driver: - provision_command: - - yum install libxcrypt-compat -y - - curl -L https://www.chef.io/chef/install.sh | bash -- name: centos-7 -- name: oraclelinux-7 -- name: rockylinux-8 -- name: debian-9 -- name: debian-10 -- name: opensuse-15 - driver: - image: opensuse/leap:15 -- name: dockerfile - driver: - username: dockerfile - password: dockerfile - dockerfile: test/Dockerfile - run_command: /sbin/init - -suites: -- name: default - excludes: [arch, debian-9] -- name: context - excludes: [arch, debian-9] - driver: - build_context: false -- name: capabilities - includes: [debian-10,ubuntu-18.04,ubuntu-20.04] - driver: - provision_command: - - curl -L https://www.chef.io/chef/install.sh | bash - - apt-get install -y net-tools - cap_drop: - - NET_ADMIN -- name: arm64 - excludes: [debian-9] - driver: - docker_platform: linux/arm64 -- name: amd64 - driver: - docker_platform: linux/amd64 -- name: inspec - driver: - provision_command: true - verifier: - name: inspec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 065c834..0000000 --- a/.travis.yml +++ /dev/null @@ -1,57 +0,0 @@ -matrix: - include: - - os: linux - rvm: 2.4.9 - dist: xenial - language: ruby - cache: bundler - script: - - bundle exec docker version - - bundle exec kitchen --version - - bundle exec rake spec - - bundle exec kitchen test -d always - - os: linux - rvm: 2.5.7 - dist: xenial - language: ruby - cache: bundler - script: - - bundle exec docker version - - bundle exec kitchen --version - - bundle exec rake spec - - bundle exec kitchen test -d always - - os: linux - rvm: 2.6.5 - dist: xenial - language: ruby - cache: bundler - script: - - bundle exec docker version - - bundle exec kitchen --version - - bundle exec rake spec - - bundle exec kitchen test -d always - - os: windows - language: bash - install: - - choco uninstall ruby - - choco install ruby --version=2.6.5.1 - - export PATH=$(echo "$PATH" | sed -e 's/:\/c\/tools\/ruby27\/bin//') - - export PATH=$PATH:/c/tools/ruby26/bin - - choco install mingw - - choco install msys2 - - ridk.cmd exec pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-libxslt - script: - - if [[ $(tasklist | grep "gpg-agent") ]]; then taskkill -IM "gpg-agent.exe" -F; else echo "Process gpg-agent not found. Skipping."; fi - - powershell -ExecutionPolicy Bypass -NoLogo -File docker.ps1 - - export KITCHEN_YAML=.kitchen.windows.yml - - ruby -v - - gem install bundler - - bundle config build.nokogiri --use-system-libraries - - bundle install - - bundle exec docker version - - bundle exec kitchen --version - - bundle exec rake spec - - bundle exec kitchen test -d always - -services: -- docker diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..0046b23 --- /dev/null +++ b/.yamllint @@ -0,0 +1,15 @@ +--- +extends: default +rules: + line-length: + max: 256 + level: warning + document-start: disable + braces: + forbid: false + min-spaces-inside: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + comments: + min-spaces-from-content: 1 diff --git a/kitchen.windows.yml b/kitchen.windows.yml new file mode 100644 index 0000000..ef520bd --- /dev/null +++ b/kitchen.windows.yml @@ -0,0 +1,33 @@ +# <% # Make sure the local copy of the driver is loaded %> +# <% lib = File.expand_path('../lib', __FILE__) %> +# <% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> +--- +driver: + name: docker + provision_command: + - powershell -ExecutionPolicy Bypass -NoLogo -Command . { iwr -useb https://omnitruck.chef.io/install.ps1 } ^| iex; install + - powershell -Command $path=$env:Path + ';c:\opscode\chef\embedded\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path + +transport: + name: docker + socket: tcp://localhost:2375 + +provisioner: + name: dummy + +platforms: + - name: windows + driver_config: + image: mcr.microsoft.com/windows/servercore:1809 + platform: windows + +suites: + - name: default + - name: context + driver: + build_context: false + - name: inspec + driver: + provision_command: echo 1 + verifier: + name: inspec diff --git a/kitchen.yml b/kitchen.yml new file mode 100644 index 0000000..f3579df --- /dev/null +++ b/kitchen.yml @@ -0,0 +1,65 @@ +# <% # Make sure the local copy of the driver is loaded %> +# <% lib = File.expand_path('../lib', __FILE__) %> +# <% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> +--- +driver: + name: docker + provision_command: curl -L https://www.chef.io/chef/install.sh | bash + +transport: + name: docker + +provisioner: + name: dummy + +platforms: + - name: amazonlinux-2 + - name: ubuntu-18.04 + - name: ubuntu-20.04 + - name: fedora-latest + driver: + provision_command: + - yum install libxcrypt-compat -y + - curl -L https://www.chef.io/chef/install.sh | bash + - name: centos-7 + - name: oraclelinux-7 + - name: rockylinux-8 + - name: debian-9 + - name: debian-10 + - name: opensuse-15 + driver: + image: opensuse/leap:15 + - name: dockerfile + driver: + username: dockerfile + password: dockerfile + dockerfile: test/Dockerfile + run_command: /sbin/init + +suites: + - name: default + excludes: [arch, debian-9] + - name: context + excludes: [arch, debian-9] + driver: + build_context: false + - name: capabilities + includes: [debian-10, ubuntu-18.04, ubuntu-20.04] + driver: + provision_command: + - curl -L https://www.chef.io/chef/install.sh | bash + - apt-get install -y net-tools + cap_drop: + - NET_ADMIN + - name: arm64 + excludes: [debian-9] + driver: + docker_platform: linux/arm64 + - name: amd64 + driver: + docker_platform: linux/amd64 + - name: inspec + driver: + provision_command: true + verifier: + name: inspec