Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for sdk25 #2

Merged
merged 9 commits into from
Mar 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 51 additions & 42 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,57 @@ provisioner:
require_chef_omnibus: latest

platforms:

- name: ubuntu-12.04
driver:
customize:
memory: 384
- name: ubuntu-12.04
driver:
customize:
memory: 384
run_list:
- recipe[apt]

- name: ubuntu-14.04
driver:
customize:
memory: 384
- name: ubuntu-14.04
driver:
customize:
memory: 384
run_list:
- recipe[apt]

- name: centos-7.1
driver:
customize:
memory: 512
- name: centos-7.1
driver:
customize:
memory: 512
run_list:
- recipe[yum]
- recipe[yum-centos]

- name: mac_el_capitan
os_type: mac_os_x
driver:
box: jhcook/osx-elcapitan-10.11
boot_timeout: 1800
customize:
cpuexecutioncap: 80 # % max of total cpu power
- name: mac_el_capitan
os_type: mac_os_x
driver:
box: jhcook/osx-elcapitan-10.11
boot_timeout: 1800
customize:
cpuexecutioncap: 80 # % max of total cpu power

- name: windows-2012R2
os_type: windows
driver:
box: mwrock/Windows2012R2
boot_timeout: 1800
attributes:
seven_zip:
home: 'C:\7-zip'
java:
oracle:
accept_oracle_download_terms: true
windows:
url: 'http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-windows-x64.exe'
package_name: 'Java SE Development Kit 7 Update 79 (64-bit)'
java_home: 'C:\\Program Files\\Java\\jdk1.7.0_79'
android-sdk:
owner: vagrant
group: vagrant
setup_root: 'C:/Users/vagrant/google'
license:
default_answer: y
- name: windows-2012R2
os_type: windows
driver:
box: mwrock/Windows2012R2
boot_timeout: 1800
attributes:
seven_zip:
home: 'C:\7-zip'
java:
oracle:
accept_oracle_download_terms: true
windows:
url: 'http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-windows-x64.exe'
package_name: 'Java SE Development Kit 7 Update 79 (64-bit)'
java_home: 'C:\\Program Files\\Java\\jdk1.7.0_79'
android-sdk:
owner: vagrant
group: vagrant
setup_root: 'C:/Users/vagrant/google'
license:
default_answer: y

suites:

Expand All @@ -81,15 +81,24 @@ suites:
java:
jdk_version: 7

- name: default
- name: legacy
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suite to check the backward compatibility

run_list:
- recipe[android-sdk]
attributes:
java:
jdk_version: 7
android-sdk:
version: '24.4'
checksum:
linux: f2bb546534d16e2004665257ee530060338c684adad14a49cd4bbde08098d8a4
mac_os_x: a1cb0c9b2036d597e18986de1bd43918b6113373ff3bf6fdb81b6cce4ec3efd7
windows: 1f9f22271fe55bf0bf10b60556ed1a5fa2f2ca672fc20d35478325104941cb05
components:
- platform-tools
- build-tools-22.0.1
- android-22
- sys-img-armeabi-v7a-android-22

- name: default
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suite to check the latest SDK and default recipe without modification attributes android-sdk

run_list:
- recipe[android-sdk]
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AllCops:
- 'vendor/**/*'

Metrics/LineLength:
Max: 150
Max: 155

Metrics/BlockLength:
Max: 30
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ os:
- linux
- osx
language: ruby
dist: trusty
rvm:
- 2.2.2
- 2.3
env:
- BERKSHELF_PATH=/tmp/
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- curl -L https://www.chef.io/chef/install.sh | sudo bash
- rvm use ruby-2.3@my_project_gemset --create
- gem install bundler
install:
- bundle install --without integration
Expand All @@ -19,5 +23,7 @@ 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
- rvm use ruby-2.3@my_project_gemset # To use the rvm ruby and custom gems
- bundle exec rake # Test all
after_script:
- rvm --force gemset delete my_project_gemset
3 changes: 3 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ source 'https://supermarket.chef.io'
metadata

group :integration do
cookbook 'apt'
cookbook 'yum'
cookbook 'yum-centos'
cookbook 'android-sdk', path: './'
end
17 changes: 8 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
source 'https://rubygems.org'

gem 'berkshelf', '~> 4.3'
gem 'chef', '~> 12.11'
gem 'chefspec', '~> 4.7'
gem 'foodcritic', '>= 5.0.0'
gem 'rake'
gem 'rubocop'
gem 'tailor'
gem 'berkshelf', '~> 5.6'
gem 'chef', '~> 12.18'
gem 'chefspec', '~> 6.0'
gem 'foodcritic', '~> 9.0'
gem 'rake', '~> 12.0'
gem 'rubocop', '~> 0.47.1'

group :integration do
gem 'kitchen-vagrant', '~> 0.20.0'
gem 'test-kitchen', '~> 1.10'
gem 'kitchen-vagrant', '~> 1.0'
gem 'test-kitchen', '~> 1.15'
end
29 changes: 1 addition & 28 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,13 @@

require 'foodcritic'
require 'rake/testtask'
require 'tailor/rake_task'
require 'rubocop/rake_task'
require 'rspec/core/rake_task'

# TODO: add chefspec
task default: [:tailor, :rubocop, :foodcritic, :knife, :serverspec]
task default: [:rubocop, :foodcritic, :knife, :serverspec]

desc 'Lint Ruby code'
task :tailor do
Tailor::RakeTask.new do |task|
task.file_set('attributes/**/*.rb', 'attributes') do |style|
style.max_line_length 160, level: :warn
end
# task.file_set('definitions/**/*.rb', "definitions")
# task.file_set('libraries/**/*.rb', "libraries")
task.file_set('metadata.rb', 'metadata') do |style|
style.max_line_length 80, level: :warn
end
# task.file_set('providers/**/*.rb', "providers")
task.file_set('recipes/**/*.rb', 'recipes') do |style|
style.max_line_length 160, level: :warn
end
# task.file_set('resources/**/*.rb', "resources")

# Template analysis is currently disabled,
# because I have no idea how 'ruby -c' could support ERB markers like '<%'
# task.file_set('templates/**/*.erb', "templates")

task.file_set('spec/**/*.rb', 'chefspec') do |style|
style.max_line_length 160, level: :warn
end
end
end

RuboCop::RakeTask.new

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removal?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubocop checks the the same and even more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also we execute foodcritic ;)

FoodCritic::Rake::LintTask.new do |t|
Expand Down
69 changes: 38 additions & 31 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
default['android-sdk']['name'] = 'android-sdk'
default['android-sdk']['owner'] = 'root'
default['android-sdk']['group'] = platform_family?('mac_os_x') ? 'wheel' : 'root'
default['android-sdk']['backup_archive'] = false # The number of backups to be kept in /var/chef/backup. To prevent backups set to false.
default['android-sdk']['setup_root'] = nil # ark defaults (/usr/local) is used if this attribute is not defined
default['android-sdk']['with_symlink'] = true # use ark's :install action when true; use ark's :put action when false
default['android-sdk']['set_environment_variables'] = true
default['android-sdk']['name'] = 'android-sdk'
default['android-sdk']['owner'] = 'root'
default['android-sdk']['group'] = platform_family?('mac_os_x') ? 'wheel' : 'root'
default['android-sdk']['backup_archive'] = false # The number of backups to be kept in /var/chef/backup. To prevent backups set to false.
default['android-sdk']['setup_root'] = nil # ark defaults (/usr/local) is used if this attribute is not defined
default['android-sdk']['with_symlink'] = true # use ark's :install action when true; use ark's :put action when false
default['android-sdk']['set_environment_variables'] = true

default['android-sdk']['version'] = '24.4'
default['android-sdk']['checksum']['linux'] = 'f2bb546534d16e2004665257ee530060338c684adad14a49cd4bbde08098d8a4'
default['android-sdk']['checksum']['mac_os_x'] = 'a1cb0c9b2036d597e18986de1bd43918b6113373ff3bf6fdb81b6cce4ec3efd7'
default['android-sdk']['checksum']['windows'] = '1f9f22271fe55bf0bf10b60556ed1a5fa2f2ca672fc20d35478325104941cb05'
default['android-sdk']['download_url']['linux'] = "http://dl.google.com/android/android-sdk_r#{node['android-sdk']['version']}-linux.tgz"
default['android-sdk']['download_url']['mac_os_x'] = "https://dl.google.com/android/android-sdk_r#{node['android-sdk']['version']}-macosx.zip"
default['android-sdk']['download_url']['windows'] = "https://dl.google.com/android/android-sdk_r#{node['android-sdk']['version']}-windows.zip"
default['android-sdk']['version'] = '25.2.3'
default['android-sdk']['checksum']['linux'] = '1b35bcb94e9a686dff6460c8bca903aa0281c6696001067f34ec00093145b560'
default['android-sdk']['checksum']['mac_os_x'] = '593544d4ca7ab162705d0032fb0c0c88e75bd0f42412d09a1e8daa3394681dc6'
default['android-sdk']['checksum']['windows'] = '23d5686ffe489e5a1af95253b153ce9d6f933e5dbabe14c494631234697a0e08'

if ::Gem::Version.new(node['android-sdk']['version']) < ::Gem::Version.new('25')
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We check the SDK version and set node['android-sdk']['legacy_sdk'] attribute which will be used in our recipies. Also there are different urls.

automatic['android-sdk']['legacy_sdk'] = true
default['android-sdk']['download_url']['linux'] = "https://dl.google.com/android/android-sdk_r#{node['android-sdk']['version']}-linux.tgz"
default['android-sdk']['download_url']['mac_os_x'] = "https://dl.google.com/android/android-sdk_r#{node['android-sdk']['version']}-macosx.zip"
default['android-sdk']['download_url']['windows'] = "https://dl.google.com/android/android-sdk_r#{node['android-sdk']['version']}-windows.zip"
else
automatic['android-sdk']['legacy_sdk'] = false
default['android-sdk']['download_url']['linux'] = "https://dl.google.com/android/repository/tools_r#{node['android-sdk']['version']}-linux.zip"
default['android-sdk']['download_url']['mac_os_x'] = "https://dl.google.com/android/repository/tools_r#{node['android-sdk']['version']}-macosx.zip"
default['android-sdk']['download_url']['windows'] = "https://dl.google.com/android/repository/tools_r#{node['android-sdk']['version']}-windows.zip"
end

#
# List of Android SDK components to preinstall:
Expand All @@ -25,24 +34,22 @@
# without having to adapt 'version' and 'checksum' attributes of this cookbook.
# Note that it will require (waste) some extra download effort.
#
default['android-sdk']['components'] = %w( platform-tools
build-tools-24.0.1
android-24
sys-img-armeabi-v7a-android-24
sys-img-armeabi-v7a-android-tv-24
extra-android-support
extra-google-google_play_services
extra-google-m2repository
extra-android-m2repository )
default['android-sdk']['components'] = %w( platform-tools
build-tools-25.0.2
android-25
extra-android-support
extra-google-google_play_services
extra-google-m2repository
extra-android-m2repository )

default['android-sdk']['license']['white_list'] = %w(.+)
default['android-sdk']['license']['black_list'] = [] # e.g. ['intel-.+', 'mips-.+', 'android-wear-sdk-license-.+']
default['android-sdk']['license']['default_answer'] = 'n' # 'y' or 'n' ('yes' or 'no')
default['android-sdk']['license']['white_list'] = %w(.+)
default['android-sdk']['license']['black_list'] = [] # e.g. ['intel-.+', 'mips-.+', 'android-wear-sdk-license-.+']
default['android-sdk']['license']['default_answer'] = 'n' # 'y' or 'n' ('yes' or 'no')

default['android-sdk']['scripts']['path'] = '/usr/local/bin'
default['android-sdk']['scripts']['owner'] = node['android-sdk']['owner']
default['android-sdk']['scripts']['group'] = node['android-sdk']['group']
default['android-sdk']['scripts']['path'] = '/usr/local/bin'
default['android-sdk']['scripts']['owner'] = node['android-sdk']['owner']
default['android-sdk']['scripts']['group'] = node['android-sdk']['group']

default['android-sdk']['java_from_system'] = false
default['android-sdk']['java_from_system'] = false

default['android-sdk']['maven-rescue'] = false
default['android-sdk']['maven-rescue'] = false
3 changes: 3 additions & 0 deletions recipes/unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#
# Install required libraries
#
package 'unzip'

if node['platform'] == 'ubuntu'
package 'libgl1-mesa-dev'

Expand Down Expand Up @@ -71,6 +73,7 @@
owner node['android-sdk']['owner']
group node['android-sdk']['group']
backup node['android-sdk']['backup_archive']
strip_components node['android-sdk']['legacy_sdk'] ? 1 : 0
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major fix for unix system is just simply extract archive to android-sdk directory without strip directory (by default ark enter to the first directory and then extract the content (default value: 1))

action node['android-sdk']['with_symlink'] ? :install : :put
end

Expand Down
10 changes: 8 additions & 2 deletions recipes/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@

ruby_block 'Rename directory' do
block do
::File.rename "#{setup_root}/android-sdk-windows", "#{setup_root}/#{node['android-sdk']['name']}"
if node['android-sdk']['legacy_sdk']
::File.rename "#{setup_root}/android-sdk-windows", "#{setup_root}/#{node['android-sdk']['name']}"
else
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major fix for windows system

require 'fileutils'
::FileUtils.mkdir "#{setup_root}/#{node['android-sdk']['name']}"
::FileUtils.mv "#{setup_root}/tools", "#{setup_root}/#{node['android-sdk']['name']}/tools"
end
end
only_if { ::Dir.exist? "#{setup_root}\\android-sdk-windows" }
only_if { ::Dir.exist?("#{setup_root}\\android-sdk-windows") || ::Dir.exist?("#{setup_root}\\tools") }
end

env 'ANDROID_HOME' do
Expand Down
28 changes: 7 additions & 21 deletions test/integration/default/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
require_relative 'spec_helper'
# Workaround for load spec_helper on Travis
libdir = File.expand_path(File.join(File.dirname(__FILE__), '../../helpers/serverspec'))
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) || $LOAD_PATH.include?(libdir)
#

# Windows
describe file('C:\\Users\\vagrant\\google\\android-sdk'), if: os[:family] == 'windows' do
it { should be_directory }
end

describe file('C:\\Users\\vagrant\\google\\android-sdk\\platform-tools\\adb.exe'), if: os[:family] == 'windows' do
it { should exist }
end

describe command('adb kill-server'), if: os[:family] == 'windows' do
its(:stderr) { should contain('server not running') }
end

# Unix
describe command('adb kill-server'), if: os[:family] != 'windows' do
its(:exit_status) { should eq 0 }
end
require 'spec_helper'

# All platform
describe command('android -h') do
its(:stdout) { should contain('android') }
describe 'Android SDK' do
include_examples 'basic suite'
end
Loading