---
expeditor:
  cached_folders:
    - vendor
  defaults:
    buildkite:
      retry:
        automatic:
          limit: 1
      timeout_in_minutes: 30

steps:

#########################################################################
  # Tests Ruby 2.7
#########################################################################

- label: "Integration Ubuntu 18.04 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec rake spec:integration
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.7
        privileged: true

- label: "Functional Ubuntu 18.04 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - apt-get update -y
    - apt-get install -y cron locales # needed for functional tests to pass
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:functional
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.7
        privileged: true

- label: "Unit Ubuntu 18.04 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:unit
    - bundle exec rake component_specs
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.7

- label: "Integration Ubuntu 20.04 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec rake spec:integration
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-20.04:2.7
        privileged: true

- label: "Functional Ubuntu 20.04 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - apt-get update -y
    - apt-get install -y cron locales # needed for functional tests to pass
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:functional
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-20.04:2.7
        privileged: true

- label: "Unit Ubuntu 20.04 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:unit
    - bundle exec rake component_specs
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-20.04:2.7

- label: "Integration CentOS 7 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec rake spec:integration
  expeditor:
    executor:
      docker:
        image: rubydistros/centos-7:2.7
        privileged: true

- label: "Functional CentOS 7 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - yum install -y crontabs e2fsprogs util-linux
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:functional
  expeditor:
    executor:
      docker:
        image: rubydistros/centos-7:2.7
        privileged: true

- label: "Unit CentOS 7 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:unit
    - bundle exec rake component_specs
  expeditor:
    executor:
      docker:
        image: rubydistros/centos-7:2.7

- label: "Integration openSUSE 15 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - zypper install -y cron insserv-compat
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec rake spec:integration
  expeditor:
    executor:
      docker:
        image: rubydistros/opensuse-15:2.7
        privileged: true

- label: "Functional openSUSE 15 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - zypper install -y cronie insserv-compat
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:functional
  expeditor:
    executor:
      docker:
        image: rubydistros/opensuse-15:2.7
        privileged: true

- label: "Unit openSUSE 15 :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - zypper install -y cron insserv-compat
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:unit
    - bundle exec rake component_specs
  expeditor:
    executor:
      docker:
        image: rubydistros/opensuse-15:2.7

- label: "Integration Fedora :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec rake spec:integration
  expeditor:
    executor:
      docker:
        image: rubydistros/fedora-latest:2.7
        privileged: true

- label: "Functional Fedora :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - yum install -y crontabs e2fsprogs util-linux
    - cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:functional
  expeditor:
    executor:
      docker:
        image: rubydistros/fedora-latest:2.7
        privileged: true
        environment:
          - FORCE_FFI_YAJL=ext
          - CHEF_LICENSE=accept-no-persist

- label: "Unit Fedora :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake spec:unit
    - bundle exec rake component_specs
  expeditor:
    executor:
      docker:
        image: rubydistros/fedora-latest:2.7

- label: "Functional Windows :ruby: 2.7"
  commands:
    - scripts/bk_tests/bk_win_functional.ps1
  expeditor:
    executor:
      windows:
        privileged: true
        single-use: true
        shell: ["powershell", "-Command"]

- label: "Integration Windows :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_win_integration.ps1
  expeditor:
    executor:
      docker:
        host_os: windows
        image: rubydistros/windows-2019:2.7
        environment:
          - FORCE_FFI_YAJL=ext
          - CHEF_LICENSE=accept-no-persist
        shell: ["powershell", "-Command"]

- label: "Chocolatey Windows :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_run_choco.ps1
  expeditor:
    executor:
      docker:
        host_os: windows
        image: rubydistros/windows-2019:2.7
        shell: ["powershell", "-Command"]

- label: "Unit Windows :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_win_unit.ps1
  expeditor:
    executor:
      docker:
        host_os: windows
        image: rubydistros/windows-2019:2.7
        environment:
          - FORCE_FFI_YAJL=ext
          - CHEF_LICENSE=accept-no-persist
        shell: ["powershell", "-Command"]

#########################################################################
# Tests Ruby 2.6
#########################################################################

- label: "Chefstyle :ruby: 2.6"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof
    - bundle exec rake style
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.6

- label: "Integration :ruby: 2.6"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec rake spec:integration
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.6
        privileged: true

- label: "Functional :ruby: 2.6"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - apt-get update -y
    - apt-get install -y cron locales net-tools # needed for functional tests to pass
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec rake spec:functional
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.6
        privileged: true

- label: "Unit :ruby: 2.6"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec rake spec:unit
    - bundle exec rake component_specs
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.6

#########################################################################
  # EXTERNAL GEM TESTING
#########################################################################

- label: "chef-sugar gem :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec tasks/bin/run_external_test chef/chef-sugar master rake
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.7

- label: "chef-zero gem :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec tasks/bin/run_external_test chef/chef-zero master rake pedant
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.7
        environment:
          - PEDANT_OPTS=--skip-oc_id
          - CHEF_FS=true

- label: "cheffish gem :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec tasks/bin/run_external_test chef/cheffish master rake spec
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.6

- label: "chefspec gem :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec tasks/bin/run_external_test chefspec/chefspec master rake
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.7

- label: "knife-windows gem :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec tasks/bin/run_external_test chef/knife-windows master rake spec
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.7

- label: "berkshelf gem :ruby: 2.7"
  commands:
    - /workdir/scripts/bk_tests/bk_container_prep.sh
    - apt-get update -y
    - apt-get install -y graphviz
    - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen
    - bundle exec tasks/bin/run_external_test berkshelf/berkshelf master rake
  expeditor:
    executor:
      docker:
        image: rubydistros/ubuntu-18.04:2.7

#########################################################################
  # START TEST KITCHEN ONLY
#########################################################################

- label: "Kitchen: Amazon Linux 201X"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-amazonlinux
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Amazon Linux 2"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-amazonlinux-2
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Ubuntu 16.04"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-ubuntu-1604
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      UBUNTU: "16.04"
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Ubuntu 18.04"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-ubuntu-1804
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Ubuntu 20.04"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-ubuntu-2004
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Debian 8"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-debian-8
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Debian 9"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-debian-9
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Debian 10"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-debian-10
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: CentOS 6"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-centos-6
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: CentOS 7"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-centos-7
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: CentOS 8"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-centos-8
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Oracle Linux 7"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-oraclelinux-7
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: Fedora latest"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-fedora-latest
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Kitchen: openSUSE Leap: 15"
  commands:
    - scripts/bk_tests/bk_linux_exec.sh
    - cd kitchen-tests
    - /opt/omnibus-toolchain/bin/bundle exec kitchen test end-to-end-opensuse-leap-15
  artifact_paths:
    - $PWD/.kitchen/logs/kitchen.log
  env:
      KITCHEN_YAML: kitchen.yml
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: "Spellcheck"
  commands:
    - npm install -g cspell
    - rake -f tasks/spellcheck.rb spellcheck
  soft_fail: true
  expeditor:
    executor:
      docker:

- label: ":habicat: Linux plan"
  commands:
    - sudo ./scripts/ci/install-hab.sh 'x86_64-linux'
    - sudo ./scripts/ci/verify-plan.sh
  timeout_in_minutes: 60
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: ":habicat: Linux plan (kernel2)"
  commands:
    - sudo ./scripts/ci/install-hab.sh 'x86_64-linux-kernel2'
    - sudo ./scripts/ci/verify-plan.sh
  timeout_in_minutes: 60
  expeditor:
    executor:
      linux:
        privileged: true
        single-use: true

- label: ":habicat: Windows plan"
  commands:
    - ./scripts/ci/verify-plan.ps1
  expeditor:
    executor:
      windows:
        privileged: true
        single-use: true
        shell: ["powershell", "-Command"]