diff --git a/.travis.yml b/.travis.yml index 986fc8d..b37e959 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,25 @@ +os: + - linux + - osx language: ruby -sudo: false rvm: - - 2.1 - - 2 + - 2.2.2 +env: + - BERKSHELF_PATH=/tmp/ before_install: -- gem install bundler -bundler_args: --without integration -cache: bundler + - git clone https://github.com/sstephenson/bats.git + - sudo ./bats/install.sh /usr/local + - curl -L https://www.chef.io/chef/install.sh | sudo bash + - gem install bundler +install: + - bundle install --without integration + - bundle exec berks vendor /tmp/cookbooks + - cp tests/support/dummy-validation.pem /tmp/validation.pem + - cp tests/support/client.rb /tmp/client.rb + - cp tests/support/dna.json /tmp/dna.json +script: + - rvm reset # To use the embedded ruby in chef-client + - sudo chef-client -z -c /tmp/client.rb -j /tmp/dna.json # Run chef in zero mode + - '[ -f ~/.bash_profile ] && source ~/.bash_profile || source ~/.profile && source /etc/profile' # Apply new env vars + - rvm use ruby-2.2.2 # To use the rvm ruby and custom gems + - bundle exec rake # Test all diff --git a/Gemfile b/Gemfile index 6e8372c..65319dc 100644 --- a/Gemfile +++ b/Gemfile @@ -6,9 +6,9 @@ gem 'chefspec', '~> 4.7' gem 'foodcritic', '>= 5.0.0' gem 'chef', '~> 12.11' gem 'rubocop' +gem 'berkshelf', '~> 4.3' group :integration do - gem 'berkshelf', '~> 4.3' gem 'test-kitchen', '~> 1.10' gem 'kitchen-vagrant', '~> 0.20.0' end diff --git a/README.md b/README.md index e723fcd..55472fa 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ The **default** recipe of this Chef cookbook will: * Download and install/upgrade Android SDK (not ADT) * Update SDK dependencies to install *some* Android platforms (`--filter` list can be customized in cookbook attributes) -* Define a default `ANDROID_HOME` environment variable (via `/etc/profile.d/...` mechanism) -* Add `ANDROID_HOME/tools` and `ANDROID_HOME/platform-tools` to default `PATH` environment variable (via `/etc/profile.d/...` mechanism) +* Define a default `ANDROID_HOME` environment variable +* Add `ANDROID_HOME/tools` and `ANDROID_HOME/platform-tools` to default `PATH` environment variable Requirements ------------ -* Depends on **opscode/ark** and **opscode/java** cookbooks -* This cookbook currently supports Ubuntu 12.04+ and CentOS 6.6+, but more Linux distributions are welcome (depending on community interests) +* Depends on **ark**, **java**, **homebrew**, **chef-sugar** and **bash** cookbooks +* This cookbook currently supports Ubuntu 12.04+ and CentOS 6.6+, Mac OS X Attributes ---------- @@ -24,7 +24,7 @@ TODO (work in progress) Installation and Usage ---------------------- -This cookbook is released at http://community.opscode.com/cookbooks/android-sdk and its original git repository is https://github.com/gildegoma/chef-android-sdk. +This cookbook is released at https://supermarket.chef.io/cookbooks/android-sdk and its original git repository is https://github.com/gildegoma/chef-android-sdk. * Find your favourite way ([Berkhelf](http://berkshelf.com/), [Librarian-Chef](https://github.com/applicationsonline/librarian#readme), knife-github-cookbooks, Git submodule, Opscode community API or even tarball download) to install this cookbook (and its dependency). * Include the `android-sdk::default` recipe to your run list or inside your cookbook. @@ -35,7 +35,7 @@ Quality Assurance ### Continous Integration -This Cookbook is being _tasted_ by Travis CI: [![Build Status](https://secure.travis-ci.org/gildegoma/chef-android-sdk.png?branch=master)](https://travis-ci.org/gildegoma/chef-android-sdk) +This Cookbook is being _tested_ by Travis CI: [![Build Status](https://secure.travis-ci.org/gildegoma/chef-android-sdk.png?branch=master)](https://travis-ci.org/gildegoma/chef-android-sdk) Automated validations are following: * Static Analysis of Ruby code with [tailor](https://github.com/turboladen/tailor#readme) lint tool @@ -43,7 +43,7 @@ Automated validations are following: * `knife cookbook test` in a very basic sandbox * _PENDING:_ Expectations described with RSpec examples with [ChefSpec](https://github.com/acrmp/chefspec) * _PENDING:_ [ServerSpec](http://serverspec.org/) integration testing - * _PENDING:_ Run true chef (matrix) on travis VM! + * Run true chef (matrix) on travis VM with Bats test ### Development and Testing diff --git a/Rakefile b/Rakefile index d7c577f..8f0d2e5 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,7 @@ require 'rubocop/rake_task' require 'rspec/core/rake_task' # TODO: add chefspec -task default: [:tailor, :rubocop, :foodcritic, :knife] +task default: [:bats, :tailor, :rubocop, :foodcritic, :knife] desc 'Lint Ruby code' task :tailor do @@ -76,6 +76,13 @@ task :prepare_sandbox do end end +desc 'Check node using bats test' +task :bats do + Dir.chdir(bats_test_path) do + sh 'bats --tap default.bats' + end +end + begin require 'kitchen/rake_tasks' Kitchen::RakeTasks.new @@ -104,3 +111,7 @@ end def knife_rb File.join(sandbox_root, 'knife.rb') end + +def bats_test_path + File.join(File.dirname(__FILE__), %w(tests integration default bats)) +end diff --git a/tests/integration/default/bats/default.bats b/tests/integration/default/bats/default.bats new file mode 100644 index 0000000..3eeefb9 --- /dev/null +++ b/tests/integration/default/bats/default.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +@test "Check that the android is available" { + command -v android +} + +@test "Check that the adb is available" { + command -v adb +} diff --git a/tests/support/client.rb b/tests/support/client.rb new file mode 100644 index 0000000..80bcc1e --- /dev/null +++ b/tests/support/client.rb @@ -0,0 +1,10 @@ +node_name 'ci-travis' +cookbook_path ['/tmp/cookbooks'] +data_bag_path '/tmp/data_bags' +environment_path '/tmp/environments' +node_path '/tmp/nodes' +role_path '/tmp/roles' +client_path '/tmp/clients' +validation_key '/tmp/validation.pem' +client_key '/tmp/client.pem' +chef_server_url 'http://127.0.0.1:8889' diff --git a/tests/support/dna.json b/tests/support/dna.json new file mode 100644 index 0000000..9106ca5 --- /dev/null +++ b/tests/support/dna.json @@ -0,0 +1,20 @@ +{ + "android-sdk": { + "owner": "travis", + "version": "24.4.1", + "checksum": { + "linux": "e16917ad685c1563ccbc5dd782930ee1a700a1b6a6fd3e44b83ac694650435e9", + "mac_os_x": "ce1638cb48526a0e55857fc46b57eda4349e6512006244ad13dd6c1361c74104" + }, + "components": [ + "platform-tools", + "build-tools-24", + "android-24", + "extra-android-support", + "extra-google-google_play_services", + "extra-google-m2repository", + "extra-android-m2repository" + ] + }, + "run_list":["recipe[android-sdk::default]"] +} diff --git a/tests/support/dummy-validation.pem b/tests/support/dummy-validation.pem new file mode 100644 index 0000000..8b43887 --- /dev/null +++ b/tests/support/dummy-validation.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA0sOY9tHvVtLZ6xmVmH8d8LrRrNcWOXbrvvCrai+T3GtRvRSL +hksLrpOpD0L9EHM6NdThNF/eGA9Oq+UKAe6yXR0hwsKuxKXqQ8SEmlhZZ9GiuggD +B/zYD3ItB6SGpdkRe7kQqTChQyrIXqbRkJqxoTXLyeJDF0sCyTdp3L8IZCUWodM8 +oV9TlQBJHYtG1gLUwIi8kcMVEoCn2Q8ltCj0/ftnwhTtwO52RkWA0uYOLGVayHsL +SCFfx+ACWPU/oWCwW5/KBqb3veTv0aEg/nh0QsFzRLoTx6SRFI5dT2Nf8iiJe4WC +UG8WKEB2G8QPnxsxfOPYDBdTJ4CXEi2e+z41VQIDAQABAoIBAALhqbW2KQ+G0nPk +ZacwFbi01SkHx8YBWjfCEpXhEKRy0ytCnKW5YO+CFU2gHNWcva7+uhV9OgwaKXkw +KHLeUJH1VADVqI4Htqw2g5mYm6BPvWnNsjzpuAp+BR+VoEGkNhj67r9hatMAQr0I +itTvSH5rvd2EumYXIHKfz1K1SegUk1u1EL1RcMzRmZe4gDb6eNBs9Sg4im4ybTG6 +pPIytA8vBQVWhjuAR2Tm+wZHiy0Az6Vu7c2mS07FSX6FO4E8SxWf8idaK9ijMGSq +FvIS04mrY6XCPUPUC4qm1qNnhDPpOr7CpI2OO98SqGanStS5NFlSFXeXPpM280/u +fZUA0AECgYEA+x7QUnffDrt7LK2cX6wbvn4mRnFxet7bJjrfWIHf+Rm0URikaNma +h0/wNKpKBwIH+eHK/LslgzcplrqPytGGHLOG97Gyo5tGAzyLHUWBmsNkRksY2sPL +uHq6pYWJNkqhnWGnIbmqCr0EWih82x/y4qxbJYpYqXMrit0wVf7yAgkCgYEA1twI +gFaXqesetTPoEHSQSgC8S4D5/NkdriUXCY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