Skip to content

Commit

Permalink
Refresh & update CI configuration
Browse files Browse the repository at this point in the history
* Update spec tests with up-to-date fauxhai versions
* Migrate from berkshelf to policyfile
* Apply latest rubocop
* Update status badge
* Pin gems to ease dependency resolution
  • Loading branch information
m.colonna committed Dec 14, 2023
1 parent 184a1d6 commit 280d193
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 41 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/criteo-cookbooks-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.vagrant
Berksfile.lock
Policyfile.lock.json
*~
*#
.#*
Expand Down
44 changes: 44 additions & 0 deletions .kitchen.docker.yml
Original file line number Diff line number Diff line change
@@ -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 %>
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ verifier:

provisioner:
name: chef_zero
chef_license: accept

attributes:
authorization:
Expand Down
16 changes: 13 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -108,3 +108,13 @@ Naming/FileName:

Style/MixinUsage:
Enabled: false

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

7 changes: 0 additions & 7 deletions Berksfile

This file was deleted.

31 changes: 15 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions Policyfile.rb
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -74,7 +74,7 @@
'~> 6.0' => '/etc/sysconfig/modules',
},
),
debian: '/etc/modules-load.d',
debian: '/etc/modules-load.d',
default: nil,
)

Expand Down
1 change: 1 addition & 0 deletions chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ CONTRIBUTING*
CHANGELOG*
TESTING*
MAINTAINERS.toml
Policyfile.*

# Strainer #
############
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#

require 'chefspec'
require 'chefspec/berkshelf'
require 'chefspec/policyfile'

Dir[File.join(__dir__, 'support/**/*.rb')].sort.each { |f| require f }
6 changes: 4 additions & 2 deletions spec/support/common_stubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
def platforms
{
redhat: [
'7.7',
'8',
'7.9',
'6.10',
],
oracle: [
'7.6',
'6.10',
],
centos: [
'7.7.1908',
'8',
'7.8.2003',
'6.10',
],
}
Expand Down
1 change: 1 addition & 0 deletions test/integration/helpers/inspec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 280d193

Please sign in to comment.