Skip to content

Commit

Permalink
Merge pull request #6 from RoboticCheese/jdh-add-an-appveyor-config
Browse files Browse the repository at this point in the history
Add a Windows builder
  • Loading branch information
hartmantis committed Sep 4, 2015
2 parents 97df73d + dc23a1d commit 3322cd5
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 28 deletions.
7 changes: 7 additions & 0 deletions .kitchen.appveyor.yml
@@ -0,0 +1,7 @@
---
driver:
name: localhost
clean_up_on_destroy: false

platforms:
- name: windows
6 changes: 3 additions & 3 deletions .kitchen.travis.yml
@@ -1,7 +1,7 @@
---
driver:
name: digitalocean
name: localhost
clean_up_on_destroy: false

platforms:
- name: macosx
driver:
name: localhost
3 changes: 3 additions & 0 deletions .kitchen.yml
Expand Up @@ -10,6 +10,9 @@ platforms:
driver:
ssh:
insert_key: false
- name: windows-2012
driver:
box: roboticcheese/windows-2012

suites:
- name: default
Expand Down
9 changes: 6 additions & 3 deletions .travis.yml
@@ -1,16 +1,19 @@
language: objective-c

branches:
only:
- master

install:
- curl -L https://www.opscode.com/chef/install.sh | sudo bash -s -- -P chefdk
- chef exec bundle install --without=development
- chef exec bundle install --without=development integration

before_script:
# Pending ENV support in Kitchen's Rake tasks and not just the CLI
- cp .kitchen.travis.yml .kitchen.local.yml
- echo -e $DIGITALOCEAN_SSH_KEY_BODY > ~/.ssh/id_rsa

script:
- chef exec rake && chef exec rake kitchen:all
- chef exec rake && chef exec kitchen test -c 2

after_script:

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -26,6 +26,7 @@ group :test do
gem 'kitchen-digitalocean', '>= 0.8.0'
gem 'kitchen-localhost'
gem 'kitchen-vagrant'
gem 'winrm-transport'
end

group :integration do
Expand Down
2 changes: 1 addition & 1 deletion Guardfile
Expand Up @@ -6,7 +6,7 @@ guard :rspec, all_on_start: true, notification: false do

watch(%r{^recipes/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^attributes/(.+)\.rb$})
watch(%r{^files/(.+)/]})
watch(%r{^files/(.+)})
watch(%r{^templates/(.+)})
watch(%r{^providers/(.+)\.rb})
watch(%r{^resources/(.+)\.rb})
Expand Down
4 changes: 3 additions & 1 deletion README.md
@@ -1,12 +1,14 @@
Dropbox Cookbook
================
[![Cookbook Version](https://img.shields.io/cookbook/v/dropbox.svg)][cookbook]
[![Build Status](https://img.shields.io/travis/RoboticCheese/dropbox-chef.svg)][travis]
[![OS X Build Status](https://img.shields.io/travis/RoboticCheese/dropbox-chef.svg)][travis]
[![Windows Build Status](https://img.shields.io/appveyor/ci/RoboticCheese/dropbox-chef.svg)][appveyor]
[![Code Climate](https://img.shields.io/codeclimate/github/RoboticCheese/dropbox-chef.svg)][codeclimate]
[![Coverage Status](https://img.shields.io/coveralls/RoboticCheese/dropbox-chef.svg)][coveralls]

[cookbook]: https://supermarket.chef.io/cookbooks/dropbox
[travis]: https://travis-ci.org/RoboticCheese/dropbox-chef
[appveyor]: https://ci.appveyor.com/project/RoboticCheese/dropbox-chef
[codeclimate]: https://codeclimate.com/github/RoboticCheese/dropbox-chef
[coveralls]: https://coveralls.io/r/RoboticCheese/dropbox-chef

Expand Down
17 changes: 17 additions & 0 deletions appveyor.yml
@@ -0,0 +1,17 @@
branches:
only:
- master

cache:
- '%TEMP%\verifier\gems'

install:
- cinst chefdk
- SET PATH=C:\opscode\chefdk\bin;%PATH%

build_script:
- chef exec bundle install --without=development integration
- copy .kitchen.appveyor.yml .kitchen.local.yml

test_script:
- chef exec kitchen test -c 2
7 changes: 5 additions & 2 deletions libraries/provider_dropbox.rb
Expand Up @@ -19,6 +19,7 @@
#

require 'chef/provider'
require 'chef-config/path_helper'
require 'net/http'
require_relative 'provider_dropbox_mac_os_x'
require_relative 'provider_dropbox_windows'
Expand Down Expand Up @@ -108,8 +109,10 @@ def download_source
# @return [String]
#
def download_dest
::File.join(Chef::Config[:file_cache_path],
::File.basename(URI.decode(download_source)).gsub(' ', ''))
ChefConfig::PathHelper.join(
Chef::Config[:file_cache_path],
::File.basename(URI.decode(download_source)).delete(' ')
)
end

#
Expand Down
4 changes: 2 additions & 2 deletions libraries/provider_dropbox_mac_os_x.rb
Expand Up @@ -18,7 +18,7 @@
# limitations under the License.
#

require 'net/http'
require_relative 'provider_dropbox'

class Chef
class Provider
Expand All @@ -35,7 +35,7 @@ class MacOsX < Dropbox
def tailor_package_to_platform
@package.app('Dropbox')
@package.volumes_dir('Dropbox Installer')
@package.source(URI.encode("file://#{download_dest}"))
@package.source("file://#{download_dest}")
end

#
Expand Down
8 changes: 4 additions & 4 deletions libraries/provider_dropbox_windows.rb
Expand Up @@ -18,7 +18,7 @@
# limitations under the License.
#

require 'net/http'
require_relative 'provider_dropbox'

class Chef
class Provider
Expand All @@ -33,8 +33,8 @@ class Windows < Dropbox
# Ensure the package resource gets Windows-specific attributes
#
def tailor_package_to_platform
@package.source(URI.encode(download_dest))
@package.installer_type(:nsis)
@package.source(download_dest)
@package.installer_type(:wise)
end

#
Expand All @@ -43,7 +43,7 @@ def tailor_package_to_platform
# @return [Chef::Resource::Windows]
#
def package_resource_class
Chef::Resource::WindowsPackage
Chef::Resource::WindowsCookbookPackage
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/libraries/provider_dropbox_mac_os_x_spec.rb
Expand Up @@ -33,7 +33,7 @@
end

it 'sets the correct source' do
expected = URI.encode('file:///tmp/package.dmg')
expected = 'file:///tmp/package.dmg'
expect(package).to receive(:source).with(expected)
provider.send(:tailor_package_to_platform)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/libraries/provider_dropbox_spec.rb
Expand Up @@ -8,7 +8,7 @@
let(:node) { Fauxhai.mock(platform).data }
let(:package_url) { nil }
let(:new_resource) do
double(name: 'dropbox', package_url: package_url, :'installed=' => true)
double(name: 'dropbox', package_url: package_url, 'installed=' => true)
end
let(:provider) { described_class.new(new_resource, nil) }

Expand Down
4 changes: 2 additions & 2 deletions spec/libraries/provider_dropbox_windows_spec.rb
Expand Up @@ -30,14 +30,14 @@
end

it 'sets the correct installer type' do
expect(package).to receive(:installer_type).with(:nsis)
expect(package).to receive(:installer_type).with(:wise)
provider.send(:tailor_package_to_platform)
end
end

describe '#package_resource_class' do
it 'returns the windows_package resource' do
expected = Chef::Resource::WindowsPackage
expected = Chef::Resource::WindowsCookbookPackage
expect(provider.send(:package_resource_class)).to eq(expected)
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -11,7 +11,9 @@
require 'fileutils'
require_relative '../libraries/matchers'
require_relative 'support/resource/dmg_package'
require_relative 'support/resource/windows_cookbook_package'
require_relative 'support/provider/dmg_package'
require_relative 'support/provider/windows_cookbook_package'

RSpec.configure do |c|
c.color = true
Expand Down
13 changes: 13 additions & 0 deletions spec/support/provider/windows_cookbook_package.rb
@@ -0,0 +1,13 @@
# Encoding: UTF-8

require 'spec_helper'

class Chef
class Provider
# A fake windows_cookbook_package provider
#
# @author Jonathan Hartman <j@p4nt5.com>
class WindowsCookbookPackage < Provider::LWRPBase
end
end
end
18 changes: 18 additions & 0 deletions spec/support/resource/windows_cookbook_package.rb
@@ -0,0 +1,18 @@
# Encoding: UTF-8

require 'spec_helper'

class Chef
class Resource
# A fake windows_cookbook_package resource
#
# @author Jonathan Hartman <j@p4nt5.com>
class WindowsCookbookPackage < Resource::LWRPBase
self.resource_name = :windows_cookbook_package
actions :install, :remove
default_action :install
attribute :source, kind_of: String
attribute :installer_type, kind_of: Symbol
end
end
end
16 changes: 9 additions & 7 deletions test/integration/default/serverspec/localhost/package_spec.rb
Expand Up @@ -3,13 +3,15 @@
require_relative '../spec_helper'

describe 'Dropbox package' do
it 'is installed' do
case os[:family]
when 'darwin'
f = '/Applications/Dropbox.app/Contents/MacOS/Dropbox'
expect(file(f)).to be_executable
else
fail('Unsupported platform')
describe file('/Applications/Dropbox.app'), if: os[:family] == 'darwin' do
it 'exists' do
expect(subject).to be_directory
end
end

describe package('Dropbox'), if: os[:family] == 'windows' do
it 'is installed' do
expect(subject).to be_installed
end
end
end
7 changes: 6 additions & 1 deletion test/integration/default/serverspec/spec_helper.rb
Expand Up @@ -2,4 +2,9 @@

require 'serverspec'

set :backend, :exec
if RUBY_PLATFORM.match(/mswin|mingw32|windows/)
set :os, family: 'windows'
set :backend, :cmd
else
set :backend, :exec
end

0 comments on commit 3322cd5

Please sign in to comment.