From 6e56f18373ee80712d642e3372be50b6e75817c2 Mon Sep 17 00:00:00 2001 From: Jamie Alessio Date: Sun, 9 Feb 2020 18:44:44 +0000 Subject: [PATCH 1/5] Introduce CI for Chef via a new Dokken platform+provider --- .kitchen.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.kitchen.yml b/.kitchen.yml index 4a7ad8162..67388433c 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -13,28 +13,49 @@ provisioner: platforms: - name: ubuntu-18.04 + - name: ubuntu-18.04-ci + driver: + name: dokken + image: dokken/ubuntu-18.04 + provision: true + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update -y + provisioner: + name: dokken + product_name: chef + product_version: 14 + data_bags_path: test/data_bags + chef_license: accept + transport: + name: dokken suites: - name: accounts run_list: - recipe[accounts::default] + excludes: ["ubuntu-18.04-ci"] - name: apache run_list: - recipe[apache::default] + excludes: ["ubuntu-18.04-ci"] - name: apt run_list: - recipe[apt::default] - name: bind run_list: - recipe[bind::default] + excludes: ["ubuntu-18.04-ci"] - name: blogs run_list: - recipe[accounts::default] - recipe[blogs::default] + excludes: ["ubuntu-18.04-ci"] - name: forum run_list: - recipe[accounts::default] - role[forum] + excludes: ["ubuntu-18.04-ci"] - name: letsencrypt run_list: - recipe[accounts::default] @@ -44,26 +65,34 @@ suites: apt: sources: - openstreetmap + excludes: ["ubuntu-18.04-ci"] - name: munin run_list: - recipe[munin::default] + excludes: ["ubuntu-18.04-ci"] - name: munin-server run_list: - recipe[munin::server] + excludes: ["ubuntu-18.04-ci"] - name: mysql run_list: - recipe[mysql::default] + excludes: ["ubuntu-18.04-ci"] - name: networking run_list: - recipe[networking::default] + excludes: ["ubuntu-18.04-ci"] - name: otrs run_list: - recipe[accounts::default] - recipe[chef::default] - role[otrs] + excludes: ["ubuntu-18.04-ci"] - name: python run_list: - recipe[python::default] + excludes: ["ubuntu-18.04-ci"] - name: tools run_list: - recipe[tools::default] + excludes: ["ubuntu-18.04-ci"] From bc8191e9d254e70da688720454cadaf8ce0aa356 Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Sun, 2 Feb 2020 16:49:33 -0800 Subject: [PATCH 2/5] Split Travis script into separate jobs and added Apt cookbook test With Kitchen-Dokken in place, Travis should now successfully run both the Cookstyle script and individual Kitchen tests as separate matrix builds. Matrix builds will run in parallel, and the global Travis 50min limit should apply to each separately ensuring that all cookbooks get tested. https://docs.travis-ci.com/user/build-matrix/ --- .travis.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87e77d6c7..7b3a22666 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,20 @@ sudo: false language: ruby cache: bundler -script: - - bundle exec cookstyle -f fuubar +services: + - docker +before_script: + - gem install kitchen kitchen-dokken kitchen-vagrant + # Put just enough Vagrant in the PATH to satisfy Test-Kitchen. No actual + # Vagrant or Virtualbox is run on Travis; this fake shim that echoes a + # recent Vagrant version is only here to allow tests to proceed below. + - sudo bash -c 'echo "echo Vagrant 2.0.0-fake" > /usr/bin/vagrant' + - sudo chmod +x /usr/bin/vagrant +jobs: + include: + - name: "Cookstyle" + script: + - bundle exec cookstyle -f fuubar + - name: "Kitchen Test Apt Cookbook" + script: + - kitchen test apt-ubuntu-1804-ci From cf6fe3a47e53bd2eead6ccae9d1edbd4a77d4e6b Mon Sep 17 00:00:00 2001 From: Jamie Alessio Date: Sun, 9 Feb 2020 19:08:31 +0000 Subject: [PATCH 3/5] Add kitchen-dokken dependency to Gemfile --- .travis.yml | 3 +-- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b3a22666..631b5775d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ cache: bundler services: - docker before_script: - - gem install kitchen kitchen-dokken kitchen-vagrant # Put just enough Vagrant in the PATH to satisfy Test-Kitchen. No actual # Vagrant or Virtualbox is run on Travis; this fake shim that echoes a # recent Vagrant version is only here to allow tests to proceed below. @@ -17,4 +16,4 @@ jobs: - bundle exec cookstyle -f fuubar - name: "Kitchen Test Apt Cookbook" script: - - kitchen test apt-ubuntu-1804-ci + - bundle exec kitchen test apt-ubuntu-1804-ci diff --git a/Gemfile b/Gemfile index ddf1c6b1c..270bcfaaa 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,7 @@ source "https://rubygems.org" gem "cookstyle" +gem "kitchen-dokken" gem "kitchen-vagrant" gem "serverspec" gem "test-kitchen" diff --git a/Gemfile.lock b/Gemfile.lock index ca09b106e..ea5cb74f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,9 +7,13 @@ GEM cookstyle (5.19.9) rubocop (= 0.75.1) diff-lcs (1.3) + docker-api (1.34.2) + excon (>= 0.47.0) + multi_json ed25519 (1.2.4) equatable (0.6.1) erubi (1.9.0) + excon (0.72.0) ffi (1.12.1) gssapi (1.3.0) ffi (>= 1.0.1) @@ -17,6 +21,10 @@ GEM builder (>= 2.1.2) httpclient (2.8.3) jaro_winkler (1.5.4) + kitchen-dokken (2.8.1) + docker-api (~> 1.33) + lockfile (~> 2.1) + test-kitchen (>= 1.15, < 3) kitchen-vagrant (1.6.1) test-kitchen (>= 1.4, < 3) license-acceptance (1.0.13) @@ -25,6 +33,7 @@ GEM tty-box (~> 0.3) tty-prompt (~> 0.18) little-plugger (1.1.4) + lockfile (2.1.3) logging (2.2.2) little-plugger (~> 1.1) multi_json (~> 1.10) @@ -149,6 +158,7 @@ PLATFORMS DEPENDENCIES cookstyle + kitchen-dokken kitchen-vagrant serverspec test-kitchen From 97b1b64e44d9beff5b206655305d577396974e9a Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Sun, 9 Feb 2020 11:32:06 -0800 Subject: [PATCH 4/5] Added comments in .kitchen.yml to explain each piece of new Dokken platform --- .kitchen.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.kitchen.yml b/.kitchen.yml index 67388433c..449f56dcf 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -12,20 +12,30 @@ provisioner: data_bags_path: test/data_bags platforms: + # Ubuntu 18.04 is what’s used on the live OSM servers, + # according to https://hardware.openstreetmap.org/ - name: ubuntu-18.04 - name: ubuntu-18.04-ci + # Driver, transport, and provisioner using Docker and Chef Infra Client, + # necessary when used on virtual CI boxes that refuse to run Virtualbox or Vagrant. + # https://github.com/someara/kitchen-dokken driver: name: dokken image: dokken/ubuntu-18.04 provision: true + # Docker and systemd need full capabilities granted in privileged mode + privileged: true + # Run systemd init to allow services like MySQL, etc. to function pid_one_command: /bin/systemd intermediate_instructions: + # Help APT find its required sources on first run - RUN /usr/bin/apt-get update -y provisioner: name: dokken product_name: chef product_version: 14 data_bags_path: test/data_bags + # Automatically accept Chef license when running headlessly chef_license: accept transport: name: dokken From d43bf14d181ba21047ebd903d52a44fba9d6e5f1 Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Mon, 10 Feb 2020 15:56:38 -0800 Subject: [PATCH 5/5] Move requested Chef version from Dokken/provisioner to Dokken/driver Implements @firefishy's suggestion: https://github.com/openstreetmap/chef/pull/266#discussion_r377307698 --- .kitchen.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index 449f56dcf..fe3e165d5 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -22,6 +22,7 @@ platforms: driver: name: dokken image: dokken/ubuntu-18.04 + chef_version: 14 provision: true # Docker and systemd need full capabilities granted in privileged mode privileged: true @@ -33,10 +34,7 @@ platforms: provisioner: name: dokken product_name: chef - product_version: 14 data_bags_path: test/data_bags - # Automatically accept Chef license when running headlessly - chef_license: accept transport: name: dokken