diff --git a/.github/workflows/criteo-cookbooks-ci.yml b/.github/workflows/criteo-cookbooks-ci.yml index 0833000..1f0775e 100644 --- a/.github/workflows/criteo-cookbooks-ci.yml +++ b/.github/workflows/criteo-cookbooks-ci.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.5 + ruby-version: 2.7 bundler-cache: true - run: bundle exec rubocop --version - run: bundle exec rubocop @@ -27,12 +27,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - instance: ['default-centos-7', 'default-ubuntu-1604', 'default-fedora-29'] + instance: ['default-centos-7', 'default-ubuntu-2004', 'default-fedora-29'] steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.5 + ruby-version: 2.7 bundler-cache: true - run: KITCHEN_LOCAL_YAML=.kitchen.docker.yml bundle exec kitchen verify ${{ matrix.instance }} supermarket: diff --git a/.gitignore b/.gitignore index 248658b..cb28e77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .vagrant -Berksfile.lock +Policyfile.lock.json *~ *# .#* diff --git a/.kitchen.docker.yml b/.kitchen.docker.yml new file mode 100644 index 0000000..2390c8a --- /dev/null +++ b/.kitchen.docker.yml @@ -0,0 +1,44 @@ +# Usage: KITCHEN_YAML=.kitchen.docker.yml bundle exec kitchen list +--- +driver: + name: dokken + chef_version: 14.7.17 + privileged: true # because Docker and SystemD/Upstart + +transport: + name: dokken + +provisioner: + name: dokken + chef_license: accept + +verifier: + name: inspec + +platforms: +- name: centos-7 + driver: + image: dokken/centos-7 + intermediate_instructions: + - RUN yum clean all + - RUN yum -y install net-tools lsof + pid_one_command: /usr/lib/systemd/systemd + +- name: fedora-29 + driver: + image: fedora:29 + intermediate_instructions: + - RUN yum clean all + - RUN yum -y install tar yum + pid_one_command: /usr/lib/systemd/systemd + +- name: ubuntu-20.04 + driver: + image: dokken/ubuntu-20.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + - RUN /usr/bin/apt-get install apt-transport-https net-tools curl -y + +suites: +<%= require 'erubis'; Erubis::Eruby.new(File.read('.kitchen_suites.yml')).evaluate %> diff --git a/.kitchen.yml b/.kitchen.yml index 880b2ea..48f91d1 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -8,6 +8,7 @@ verifier: provisioner: name: chef_zero + chef_license: accept attributes: authorization: diff --git a/.rubocop.yml b/.rubocop.yml index 435e8f2..83650aa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,7 @@ # - submit the change in the code_generator AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.7 # This requires to alphabetically sort Gem's requirements @@ -17,7 +17,7 @@ Style/FrozenStringLiteralComment: Enabled: false ### Disable line length constraint -Metrics/LineLength: +Layout/LineLength: Max: 180 # Because we're not in the 80s anymore. # Based on data from http://sideeffect.kr/popularconvention#ruby @@ -45,7 +45,7 @@ Style/TrailingCommaInHashLiteral: # } # ### Align hashes as a table -Layout/AlignHash: +Layout/HashAlignment: EnforcedColonStyle: table EnforcedHashRocketStyle: key # When dealing with long key names, it is easier to read hashes in colon @@ -108,3 +108,13 @@ Naming/FileName: Style/MixinUsage: Enabled: false + +Style/HashEachMethods: + Enabled: true + +Style/HashTransformKeys: + Enabled: true + +Style/HashTransformValues: + Enabled: true + diff --git a/Berksfile b/Berksfile deleted file mode 100644 index 10097f3..0000000 --- a/Berksfile +++ /dev/null @@ -1,7 +0,0 @@ -source 'https://supermarket.chef.io' - -cookbook 'sudo' -cookbook 'test-module', path: 'test/cookbooks/test-module' -cookbook 'kitchen-ohai' # required for ec2 - -metadata diff --git a/Gemfile b/Gemfile index a9cde3c..3ea4563 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,20 @@ source 'https://rubygems.org' -gem 'berkshelf' -gem 'kitchen-vagrant' -gem 'chefspec' -gem 'rake' -gem 'foodcritic' -gem 'chef' -gem 'rubocop' +group :unit_test do + gem 'chef', '= 14.7.17' + gem 'chefspec', '>= 9.2.1' + gem 'fakefs', '>= 2.4.0' + gem 'webmock', '>= 3.13.0' +end -gem 'kitchen-transport-speedy' -group :ec2 do - gem 'test-kitchen' - gem 'kitchen-ec2' - gem 'dotenv' +group :integration do + gem 'kitchen-dokken', '>= 2.19.1' + gem 'kitchen-inspec', '>= 2.6.1' + gem 'kitchen-vagrant', '>= 1.14.1' + gem 'test-kitchen', '>= 3.5.0' end -# Other gems should go after this comment -gem 'inspec' -gem 'kitchen-inspec' -gem 'cookbook-release' +group :lint do + gem 'foodcritic', '>= 16.3.0' + gem 'rubocop', '= 0.80.1' +end diff --git a/Policyfile.rb b/Policyfile.rb new file mode 100644 index 0000000..0998dbc --- /dev/null +++ b/Policyfile.rb @@ -0,0 +1,11 @@ +name 'kernel-modules' + +run_list ['kernel-modules'] +named_run_list :test, run_list + ['recipe[test-module]'] + +default_source :community + +# Current cookbook +cookbook 'kernel-modules', path: '.' +# Test cookbooks +cookbook 'test-module', path: 'test/cookbooks/test-module' diff --git a/README.md b/README.md index cff01ec..99e33e9 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,6 @@ limitations under the License. [author]: https://github.com/jmauro [repository]: https://github.com/criteo-cookbooks/kernel-modules -[build_status]: https://api.travis-ci.org/criteo-cookbooks/kernel-modules.svg?branch=master +[build_status]: https://img.shields.io/github/actions/workflow/status/criteo-cookbooks/kernel-modules/criteo-cookbooks-ci.yml [cookbook_version]: https://img.shields.io/cookbook/v/kernel-modules.svg [cookbook]: https://supermarket.chef.io/cookbooks/kernel-modules diff --git a/attributes/default.rb b/attributes/default.rb index e582d10..3aec148 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -28,7 +28,7 @@ # Packages requirements default['kernel_modules']['packages'] = value_for_platform_family( - rhel: value_for_platform( + rhel: value_for_platform( %w[centos redhat oracle] => { '~> 6.0' => [ 'initscripts', # rpm -q --whatprovides /etc/sysconfig/modules @@ -52,16 +52,16 @@ ], ), debian: value_for_platform( - %[ubuntu] => { - '~> 15.04' => [ - 'systemd', - 'kmod' + %(ubuntu) => { + '~> 15.04' => %w[ + systemd + kmod ], }, 'default' => [ 'kmod', ], - ) + ), ) # Modules init loading requirements @@ -74,7 +74,7 @@ '~> 6.0' => '/etc/sysconfig/modules', }, ), - debian: '/etc/modules-load.d', + debian: '/etc/modules-load.d', default: nil, ) diff --git a/chefignore b/chefignore index a976917..2c84382 100644 --- a/chefignore +++ b/chefignore @@ -88,6 +88,7 @@ CONTRIBUTING* CHANGELOG* TESTING* MAINTAINERS.toml +Policyfile.* # Strainer # ############ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3872ca7..4d3ad5a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,6 +17,6 @@ # require 'chefspec' -require 'chefspec/berkshelf' +require 'chefspec/policyfile' Dir[File.join(__dir__, 'support/**/*.rb')].sort.each { |f| require f } diff --git a/spec/support/common_stubs.rb b/spec/support/common_stubs.rb index 862be36..9556176 100644 --- a/spec/support/common_stubs.rb +++ b/spec/support/common_stubs.rb @@ -8,7 +8,8 @@ def platforms { redhat: [ - '7.7', + '8', + '7.9', '6.10', ], oracle: [ @@ -16,7 +17,8 @@ def platforms '6.10', ], centos: [ - '7.7.1908', + '8', + '7.8.2003', '6.10', ], } diff --git a/test/integration/helpers/inspec/spec_helper.rb b/test/integration/helpers/inspec/spec_helper.rb index 6cf0219..91b260a 100644 --- a/test/integration/helpers/inspec/spec_helper.rb +++ b/test/integration/helpers/inspec/spec_helper.rb @@ -19,6 +19,7 @@ def module_path(type, module_name) raise "'module_path' not supported for this os_family '#{os[:family]}'" unless %w[centos redhat].include?(os[:family]) return ::File.join('/etc/modprobe.d', module_name + '.conf') if type.to_sym == :load + if os[:release].to_i == 6 ::File.join('/etc/sysconfig/modules', module_name + '.modules') else