jonlives / knife-spork

A workflow plugin to help many devs work with cookbooks and environments at once
Other
335 stars 97 forks source link

rake test fails when knife spork has local configuration #212

Open timurb opened 7 years ago

timurb commented 7 years ago

I've configured knife spork to work with my repos and now rake command fails with some errors. It looks like it tries to reuse spork's config:

timurb@MBP-777:knife-spork (master *$%)$ chef exec rake
Creating checksums directory
Starting chef-zero server
Uploading test data
Uploading example      [0.0.1]
Uploaded 1 cookbook.
Updated Environment example
/opt/chefdk/embedded/bin/ruby -I/opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/rspec-support-3.6.0/lib:/opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb --color --format doc
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

KnifeSpork::SporkBump
  #run
    calls bump method
  #bump
Successfully bumped example to v0.0.2!
    automatically bumps patch level
Successfully bumped example to v0.0.3!
    manually bumps patch version level
Successfully bumped example to v0.1.0!
    manually bumps minor version level
Successfully bumped example to v1.0.0!
    manually bumps major version level
Successfully bumped example to v0.0.1!
    manually sets version to 0.0.1

KnifeSpork::SporkInfo
  #run
    displays spork info
  #info
    only calls ui.msg

KnifeSpork::SporkPromote
  #run
    calls promote method (FAILED - 1)
    calls save_environment_changes method by default (FAILED - 2)
    calls save_environment_changes_remote method when --remote is specified (FAILED - 3)
  #promote
    updates version constraint for cookbook (FAILED - 4)
  #save_environment_changes
    updates the constraint in the environment file (FAILED - 5)
  #save_environment_changes_remote
    saves the environment change to the server (FAILED - 6)

KnifeSpork::SporkUpload
  #run
Running foodcritic against example@0.0.1...
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example
ERROR: Foodcritic failed!
ERROR: FC011: Missing README in markdown format: /private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/README.md:1
ERROR: FC064: Ensure issues_url is set in metadata: /private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:1
ERROR: FC065: Ensure source_url is set in metadata: /private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:1
ERROR: FC066: Ensure chef_version is set in metadata: /private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:1
ERROR: FC067: Ensure at least one platform supported in metadata: /private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:1
ERROR: FC078: Ensure cookbook shared under an OSI-approved open source license: /private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:1
Running rubocop against example@0.0.1...
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example
Inspecting 1 file
C

Offenses:

/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:1:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
name             "example"
                 ^^^^^^^^^
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:2:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
maintainer       "Jon Cowie"
                 ^^^^^^^^^^^
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:3:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
maintainer_email "jonlives@gmail.com"
                 ^^^^^^^^^^^^^^^^^^^^
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:4:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
license          "All rights reserved"
                 ^^^^^^^^^^^^^^^^^^^^^
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:5:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
description      "Test cookbook for knife-spork"
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:6:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
long_description "Test cookbook for knife-spork"
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:7:9: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
version "0.0.1"
        ^^^^^^^
/private/var/folders/2y/h2cs54ks18j_m5hv8gj1lf940000gn/T/knife-spork20170728-1914-1jlndy1/cookbooks/example/metadata.rb:8:1: C: 1 trailing blank lines detected.

1 file inspected, 8 offenses detected
ERROR: Rubocop failed!
    calls upload method
  #upload
Freezing example at 0.0.1...
    uploads cookbook

Failures:

  1) KnifeSpork::SporkPromote#run calls promote method
     Failure/Error: environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")

     Errno::ENOENT:
       No such file or directory @ rb_sysopen - /Users/timurb/myorg/environments/example.json
     # ./lib/knife-spork/runner.rb:249:in `load_environment_from_file'
     # ./lib/knife-spork/runner.rb:39:in `block in run_plugins'
     # ./lib/knife-spork/runner.rb:39:in `collect'
     # ./lib/knife-spork/runner.rb:39:in `run_plugins'
     # ./lib/chef/knife/spork-promote.rb:58:in `run'
     # ./spec/unit/spork_promote_spec.rb:33:in `block (3 levels) in <module:KnifeSpork>'

  2) KnifeSpork::SporkPromote#run calls save_environment_changes method by default
     Failure/Error: environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")

     Errno::ENOENT:
       No such file or directory @ rb_sysopen - /Users/timurb/myorg/environments/example.json
     # ./lib/knife-spork/runner.rb:249:in `load_environment_from_file'
     # ./lib/knife-spork/runner.rb:39:in `block in run_plugins'
     # ./lib/knife-spork/runner.rb:39:in `collect'
     # ./lib/knife-spork/runner.rb:39:in `run_plugins'
     # ./lib/chef/knife/spork-promote.rb:58:in `run'
     # ./spec/unit/spork_promote_spec.rb:38:in `block (3 levels) in <module:KnifeSpork>'

  3) KnifeSpork::SporkPromote#run calls save_environment_changes_remote method when --remote is specified
     Failure/Error: environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")

     Errno::ENOENT:
       No such file or directory @ rb_sysopen - /Users/timurb/myorg/environments/example.json
     # ./lib/knife-spork/runner.rb:249:in `load_environment_from_file'
     # ./lib/knife-spork/runner.rb:39:in `block in run_plugins'
     # ./lib/knife-spork/runner.rb:39:in `collect'
     # ./lib/knife-spork/runner.rb:39:in `run_plugins'
     # ./lib/chef/knife/spork-promote.rb:58:in `run'
     # ./spec/unit/spork_promote_spec.rb:44:in `block (3 levels) in <module:KnifeSpork>'

  4) KnifeSpork::SporkPromote#promote updates version constraint for cookbook
     Failure/Error: environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")

     Errno::ENOENT:
       No such file or directory @ rb_sysopen - /Users/timurb/myorg/environments/example.json
     # ./lib/knife-spork/runner.rb:249:in `load_environment_from_file'
     # ./spec/unit/spork_promote_spec.rb:54:in `block (3 levels) in <module:KnifeSpork>'

  5) KnifeSpork::SporkPromote#save_environment_changes updates the constraint in the environment file
     Failure/Error: environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")

     Errno::ENOENT:
       No such file or directory @ rb_sysopen - /Users/timurb/myorg/environments/example.json
     # ./lib/knife-spork/runner.rb:249:in `load_environment_from_file'
     # ./spec/unit/spork_promote_spec.rb:63:in `block (3 levels) in <module:KnifeSpork>'

  6) KnifeSpork::SporkPromote#save_environment_changes_remote saves the environment change to the server
     Failure/Error: environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")

     Errno::ENOENT:
       No such file or directory @ rb_sysopen - /Users/timurb/myorg/environments/example.json
     # ./lib/knife-spork/runner.rb:249:in `load_environment_from_file'
     # ./lib/chef/knife/spork-promote.rb:113:in `save_environment_changes_remote'
     # ./spec/unit/spork_promote_spec.rb:73:in `block (3 levels) in <module:KnifeSpork>'

Finished in 3.95 seconds (files took 0.7721 seconds to load)
16 examples, 6 failures

Failed examples:

rspec ./spec/unit/spork_promote_spec.rb:31 # KnifeSpork::SporkPromote#run calls promote method
rspec ./spec/unit/spork_promote_spec.rb:36 # KnifeSpork::SporkPromote#run calls save_environment_changes method by default
rspec ./spec/unit/spork_promote_spec.rb:41 # KnifeSpork::SporkPromote#run calls save_environment_changes_remote method when --remote is specified
rspec ./spec/unit/spork_promote_spec.rb:50 # KnifeSpork::SporkPromote#promote updates version constraint for cookbook
rspec ./spec/unit/spork_promote_spec.rb:60 # KnifeSpork::SporkPromote#save_environment_changes updates the constraint in the environment file
rspec ./spec/unit/spork_promote_spec.rb:70 # KnifeSpork::SporkPromote#save_environment_changes_remote saves the environment change to the server

/opt/chefdk/embedded/bin/ruby -I/opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/rspec-support-3.6.0/lib:/opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/lib /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/rspec-core-3.6.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb --color --format doc failed

The environments path for failing tests is from my spork config. Also I got plugins from my config triggered — foodcritic was called and notification sent to slack channel for changes.