From 96311f2b9f71c0eb71b515ab56c291769e74d82e Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 19 Mar 2026 11:00:27 +0000 Subject: [PATCH 1/2] fix: add RSpec tests, frozen_string_literal, update EOL platforms, apt_update - Replace legacy Spork spec_helper with modern ChefSpec - Add github_deploy resource spec (3 examples, 0 failures) - Add frozen_string_literal to 11 files - Add apt_update to test recipe - Replace all EOL platforms with current non-EOL in kitchen.yml, kitchen.dokken.yml, CI --- .github/workflows/ci.yml | 11 +++- kitchen.dokken.yml | 59 +------------------ kitchen.yml | 7 ++- libraries/github_archive.rb | 2 + libraries/github_asset.rb | 2 + libraries/github_errors.rb | 2 + resources/archive.rb | 2 + resources/asset.rb | 2 + resources/deploy.rb | 2 + spec/libraries/github_archive_spec.rb | 2 + spec/resources/deploy_spec.rb | 23 ++++++++ spec/spec_helper.rb | 49 ++++----------- test/fixtures/cookbooks/test/metadata.rb | 2 + .../cookbooks/test/recipes/default.rb | 4 ++ test/integration/default/controls/default.rb | 2 + 15 files changed, 75 insertions(+), 96 deletions(-) create mode 100644 spec/resources/deploy_spec.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42a08d7..dc291c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,16 @@ jobs: strategy: matrix: os: - - "ubuntu-2004" + - "almalinux-8" + - "almalinux-9" + - "amazonlinux-2023" + - "centos-stream-9" + - "debian-12" + - "fedora-latest" + - "rockylinux-8" + - "rockylinux-9" + - "ubuntu-2204" + - "ubuntu-2404" suite: - "default" fail-fast: false diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 47eff95..303b6ed 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -22,36 +22,11 @@ platforms: image: dokken/amazonlinux-2023 pid_one_command: /usr/lib/systemd/systemd - - name: centos-7 - driver: - image: dokken/centos-7 - pid_one_command: /usr/lib/systemd/systemd - - - name: centos-stream-8 - driver: - image: dokken/centos-stream-8 - pid_one_command: /usr/lib/systemd/systemd - - name: centos-stream-9 driver: image: dokken/centos-stream-9 pid_one_command: /usr/lib/systemd/systemd - - name: debian-9 - driver: - image: dokken/debian-9 - pid_one_command: /bin/systemd - - - name: debian-10 - driver: - image: dokken/debian-10 - pid_one_command: /bin/systemd - - - name: debian-11 - driver: - image: dokken/debian-11 - pid_one_command: /bin/systemd - - name: debian-12 driver: image: dokken/debian-12 @@ -62,26 +37,6 @@ platforms: image: dokken/fedora-latest pid_one_command: /usr/lib/systemd/systemd - - name: opensuse-leap-15 - driver: - image: dokken/opensuse-leap-15 - pid_one_command: /usr/lib/systemd/systemd - - - name: oraclelinux-7 - driver: - image: dokken/oraclelinux-7 - pid_one_command: /usr/lib/systemd/systemd - - - name: oraclelinux-8 - driver: - image: dokken/oraclelinux-8 - pid_one_command: /usr/lib/systemd/systemd - - - name: oraclelinux-9 - driver: - image: dokken/oraclelinux-9 - pid_one_command: /usr/lib/systemd/systemd - - name: rockylinux-8 driver: image: dokken/rockylinux-8 @@ -92,22 +47,12 @@ platforms: image: dokken/rockylinux-9 pid_one_command: /usr/lib/systemd/systemd - - name: ubuntu-18.04 - driver: - image: dokken/ubuntu-18.04 - pid_one_command: /bin/systemd - - - name: ubuntu-20.04 - driver: - image: dokken/ubuntu-20.04 - pid_one_command: /bin/systemd - - name: ubuntu-22.04 driver: image: dokken/ubuntu-22.04 pid_one_command: /bin/systemd - - name: ubuntu-23.04 + - name: ubuntu-24.04 driver: - image: dokken/ubuntu-23.04 + image: dokken/ubuntu-24.04 pid_one_command: /bin/systemd diff --git a/kitchen.yml b/kitchen.yml index 120aea4..762d7a5 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -13,7 +13,12 @@ verifier: name: inspec platforms: - - name: ubuntu-20.04 + - name: almalinux-8 + - name: almalinux-9 + - name: amazonlinux-2023 + - name: debian-12 + - name: ubuntu-22.04 + - name: ubuntu-24.04 suites: - name: default diff --git a/libraries/github_archive.rb b/libraries/github_archive.rb index 09f1d78..60753b7 100644 --- a/libraries/github_archive.rb +++ b/libraries/github_archive.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'open-uri' require 'uri' require 'fileutils' diff --git a/libraries/github_asset.rb b/libraries/github_asset.rb index 43c8673..96e3139 100644 --- a/libraries/github_asset.rb +++ b/libraries/github_asset.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'net/http' require 'open-uri' require 'uri' diff --git a/libraries/github_errors.rb b/libraries/github_errors.rb index ee507bc..7d588f2 100644 --- a/libraries/github_errors.rb +++ b/libraries/github_errors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module GithubCB class GHError < StandardError; end diff --git a/resources/archive.rb b/resources/archive.rb index 9196b20..4be9b61 100644 --- a/resources/archive.rb +++ b/resources/archive.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + unified_mode true default_action :extract diff --git a/resources/asset.rb b/resources/asset.rb index d3a0d0a..6ce7cdb 100644 --- a/resources/asset.rb +++ b/resources/asset.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + unified_mode true default_action :download diff --git a/resources/deploy.rb b/resources/deploy.rb index 1b90eb0..c35cc2b 100644 --- a/resources/deploy.rb +++ b/resources/deploy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + unified_mode true default_action :deploy diff --git a/spec/libraries/github_archive_spec.rb b/spec/libraries/github_archive_spec.rb index ecc8e73..7c1ddda 100644 --- a/spec/libraries/github_archive_spec.rb +++ b/spec/libraries/github_archive_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # require 'spec_helper' # # describe GithubCB::Archive do diff --git a/spec/resources/deploy_spec.rb b/spec/resources/deploy_spec.rb new file mode 100644 index 0000000..94b5498 --- /dev/null +++ b/spec/resources/deploy_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'github_deploy' do + step_into :github_deploy + platform 'ubuntu', '22.04' + + context 'deploy action' do + recipe do + github_deploy 'sous-chefs/test-repo' do + version 'v1.0.0' + path '/opt/deployments/test-repo' + owner 'deploy' + group 'deploy' + end + end + + it { is_expected.to create_directory('/opt/deployments/test-repo/releases') } + it { is_expected.to create_directory('/opt/deployments/test-repo/shared') } + it { is_expected.to create_link('/opt/deployments/test-repo/current') } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8b0212c..799c9f4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,37 +1,12 @@ -# require 'rubygems' -# require 'bundler' -# require 'rspec' -# require 'spork' -# require 'chef' -# -# Spork.prefork do -# Dir[File.join(File.expand_path('../spec/support/**/*.rb', __dir__))].each { |f| require f } -# -# RSpec.configure do |config| -# config.expect_with :rspec do |c| -# c.syntax = :expect -# end -# -# config.mock_with :rspec -# config.treat_symbols_as_metadata_keys_with_true_values = true -# config.filter_run focus: true -# config.run_all_when_everything_filtered = true -# -# config.before(:each) do -# Chef::Config[:file_cache_path] = File.join(tmp_path, 'chef_cache') -# FileUtils.rm_rf(tmp_path) -# FileUtils.mkdir_p(tmp_path) -# FileUtils.mkdir_p(Chef::Config[:file_cache_path]) -# end -# end -# -# def tmp_path -# File.expand_path(File.join(File.dirname(__FILE__), '../tmp')) -# end -# end -# -# Spork.each_run do -# Dir["#{File.expand_path('..', File.dirname(__FILE__))}/libraries/*.rb"].sort.each do |path| -# require_relative "../libraries/#{File.basename(path, '.rb')}" -# end -# end +# frozen_string_literal: true + +require 'chefspec' +require 'chefspec/berkshelf' + +RSpec.configure do |config| + config.color = true + config.formatter = :documentation + config.log_level = :warn + config.platform = 'ubuntu' + config.version = '22.04' +end diff --git a/test/fixtures/cookbooks/test/metadata.rb b/test/fixtures/cookbooks/test/metadata.rb index 691cb42..31e98c0 100644 --- a/test/fixtures/cookbooks/test/metadata.rb +++ b/test/fixtures/cookbooks/test/metadata.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + name 'test' maintainer 'Sous Chefs' maintainer_email 'help@sous-chefs.org' diff --git a/test/fixtures/cookbooks/test/recipes/default.rb b/test/fixtures/cookbooks/test/recipes/default.rb index ce54375..30b8b4d 100644 --- a/test/fixtures/cookbooks/test/recipes/default.rb +++ b/test/fixtures/cookbooks/test/recipes/default.rb @@ -1,3 +1,7 @@ +apt_update + +# frozen_string_literal: true + github_asset 'Precompiled.zip' do repo 'elixir-lang/elixir' release 'v1.12.2' diff --git a/test/integration/default/controls/default.rb b/test/integration/default/controls/default.rb index 22e1412..af65372 100644 --- a/test/integration/default/controls/default.rb +++ b/test/integration/default/controls/default.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + cache_dir = inspec.file('/opt/kitchen').exist? ? '/opt/kitchen/cache' : '/tmp/kitchen/cache' control 'github-cookbook' do From f27a844c33f68d17bacca733fff5753ee98c292c Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 19 Mar 2026 11:25:05 +0000 Subject: [PATCH 2/2] ci: update release.yml to @main with slack secrets, add .rubocop.yml - Pin release workflow to @main (was @5.0.8) - Add slack_bot_token and slack_channel_id secrets - Add .rubocop.yml with cookstyle require --- .github/workflows/release.yml | 8 ++++---- .rubocop.yml | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 .rubocop.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4db4a8d..ef79f89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,8 @@ --- name: release - "on": push: - branches: - - main + branches: [main] permissions: contents: write @@ -16,8 +14,10 @@ permissions: jobs: release: - uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@5.0.8 + uses: sous-chefs/.github/.github/workflows/release-cookbook.yml@main secrets: token: ${{ secrets.PORTER_GITHUB_TOKEN }} supermarket_user: ${{ secrets.CHEF_SUPERMARKET_USER }} supermarket_key: ${{ secrets.CHEF_SUPERMARKET_KEY }} + slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }} + slack_channel_id: ${{ secrets.SLACK_CHANNEL_ID }} diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..6188300 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,2 @@ +require: + - cookstyle