From 4450d431b923075a005d171353184e13b24bf281 Mon Sep 17 00:00:00 2001 From: mattclegg Date: Tue, 23 Feb 2016 22:29:22 +0000 Subject: [PATCH 1/7] add travis before_install options --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 96a5e28..49db00b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: ruby +before_install: + - gem update bundler rvm: - 2.1.4 - 2.0.0 From 41efb526270d7274cfb9a4dce04f037da98f4b32 Mon Sep 17 00:00:00 2001 From: mattclegg Date: Tue, 23 Feb 2016 22:53:38 +0000 Subject: [PATCH 2/7] Build fix-.* branches --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 49db00b..b7e035c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,3 +42,4 @@ branches: only: - master - /^release.*$/ + - /^fix-.*$/ From c73cc576b4caf021a41e53706bdec1bbcfa76ee4 Mon Sep 17 00:00:00 2001 From: mattclegg Date: Wed, 13 Jan 2016 15:12:47 +0000 Subject: [PATCH 3/7] Change logic to only download if composer doesn't exist. Only moving download file to composer location when download succeeds (via notify). --- manifests/init.pp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 7d39680..11c8713 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -136,21 +136,21 @@ } } - if defined(File["${target_dir}/${composer_file}"]) == false { - exec { 'download_composer': - command => $download_command, - cwd => $tmp_path, - require => $download_require, - creates => "${tmp_path}/composer.phar", - logoutput => $logoutput, - } - # move file to target_dir - file { "${target_dir}/${composer_file}": - ensure => present, - source => "${tmp_path}/composer.phar", - require => [ Exec['download_composer'], File[$target_dir] ], - mode => '0755', - } + # download composer if target_file doesn't exist + exec { "download_composer": + command => $download_command, + cwd => $tmp_path, + require => $download_require, + creates => "${tmp_path}/composer.phar", + logoutput => $logoutput, + onlyif => "test ! -f ${target_dir}/${composer_file}", + path => [ '/bin', '/usr/bin' ], + notify => Exec["move_composer_${target_dir}"] + } + # move downloaded file to target_dir + exec { "move_composer_${target_dir}": + command => "mv ${tmp_path}/composer.phar ${target_dir}/${composer_file}; chmod 0755 ${target_dir}/${composer_file}", + refreshonly => true, } if $auto_update == true { From eacf5e8959394dde5578d7360199dcadf47fc809 Mon Sep 17 00:00:00 2001 From: mattclegg Date: Fri, 15 Jan 2016 15:25:31 +0000 Subject: [PATCH 4/7] Add composer_home variable and set install parameters to match `"move_composer_${target_dir}"` --- manifests/init.pp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 11c8713..efc3c2f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -96,7 +96,7 @@ # download composer case $download_method { 'curl': { - $download_command = "curl -sS https://getcomposer.org/installer | ${composer::php_bin}" + $download_command = "curl -sS https://getcomposer.org/installer | ${composer::php_bin} -- --install-dir=${tmp_path} --filename=composer.phar" $download_require = $suhosin_enabled ? { false => [ Package['curl', $php_package] ], default => [ @@ -138,15 +138,17 @@ # download composer if target_file doesn't exist exec { "download_composer": - command => $download_command, - cwd => $tmp_path, - require => $download_require, - creates => "${tmp_path}/composer.phar", - logoutput => $logoutput, - onlyif => "test ! -f ${target_dir}/${composer_file}", - path => [ '/bin', '/usr/bin' ], - notify => Exec["move_composer_${target_dir}"] + command => $download_command, + cwd => $tmp_path, + require => $download_require, + creates => "${tmp_path}/composer.phar", + logoutput => $logoutput, + onlyif => "test ! -f ${target_dir}/${composer_file}", + path => [ '/bin', '/usr/bin' ], + notify => Exec["move_composer_${target_dir}"], + environment => ["COMPOSER_HOME=${composer::composer_home}"] } + # move downloaded file to target_dir exec { "move_composer_${target_dir}": command => "mv ${tmp_path}/composer.phar ${target_dir}/${composer_file}; chmod 0755 ${target_dir}/${composer_file}", From 9c50a74b1ee14f66020a6a34a4ee9b1e67b412f3 Mon Sep 17 00:00:00 2001 From: mattclegg Date: Tue, 23 Feb 2016 23:44:14 +0000 Subject: [PATCH 5/7] Update spec to match logic --- spec/classes/composer_spec.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/spec/classes/composer_spec.rb b/spec/classes/composer_spec.rb index 382251b..a1fb468 100644 --- a/spec/classes/composer_spec.rb +++ b/spec/classes/composer_spec.rb @@ -31,9 +31,9 @@ it { should contain_exec('download_composer').with({ - :command => "curl -sS https://getcomposer.org/installer | #{p[:php_bin]}", - :cwd => '/tmp', - :creates => '/tmp/composer.phar', + :command => "curl -sS https://getcomposer.org/installer | #{p[:php_bin]} -- --install-dir=#{p[:tmp_path]} --filename=composer.phar", + :cwd => "#{p[:tmp_path]}", + :creates => "#{p[:tmp_path]}/#{p[:composer_file]}", :logoutput => false, }) } @@ -43,10 +43,8 @@ it { should contain_file(p[:target_dir]).with_ensure('directory') } it { - should contain_file(composer_path).with({ - :source => 'present', - :source => '/tmp/composer.phar', - :mode => '0755', + should contain_exec("move_composer_#{p[:target_dir]}").with({ + :command => "mv #{p[:tmp_path]}/#{p[:composer_file]} #{p[:target_dir]}/${composer_file}; chmod 0755 #{p[:target_dir]}/#{p[:composer_file]}" }) } From c2f78c1cc6a78df566c7a43e0a4361326ca33290 Mon Sep 17 00:00:00 2001 From: mattclegg Date: Wed, 24 Feb 2016 00:08:01 +0000 Subject: [PATCH 6/7] update default params --- spec/classes/composer_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/classes/composer_spec.rb b/spec/classes/composer_spec.rb index a1fb468..750eef1 100644 --- a/spec/classes/composer_spec.rb +++ b/spec/classes/composer_spec.rb @@ -4,12 +4,13 @@ shared_examples 'a composer module' do |params, ctx| p = { - :php_package => 'php-cli', - :php_bin => 'php', - :curl_package => 'curl', :target_dir => '/usr/local/bin', :composer_file => 'composer', - :suhosin_enabled => true, + :tmp_path => '/tmp', + :php_package => 'php-cli', + :curl_package => 'curl', + :php_bin => 'php', + :suhosin_enabled => true } p.merge!(params) if params From ced355644093ebb2e27db1fb33058f09b816bd6b Mon Sep 17 00:00:00 2001 From: mattclegg Date: Wed, 24 Feb 2016 00:21:03 +0000 Subject: [PATCH 7/7] update composer_file name --- manifests/init.pp | 6 +++--- spec/classes/composer_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index efc3c2f..8d9fd3a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -96,7 +96,7 @@ # download composer case $download_method { 'curl': { - $download_command = "curl -sS https://getcomposer.org/installer | ${composer::php_bin} -- --install-dir=${tmp_path} --filename=composer.phar" + $download_command = "curl -sS https://getcomposer.org/installer | ${composer::php_bin} -- --install-dir=${tmp_path} --filename=${composer_file}" $download_require = $suhosin_enabled ? { false => [ Package['curl', $php_package] ], default => [ @@ -141,7 +141,7 @@ command => $download_command, cwd => $tmp_path, require => $download_require, - creates => "${tmp_path}/composer.phar", + creates => "${tmp_path}/${composer_file}", logoutput => $logoutput, onlyif => "test ! -f ${target_dir}/${composer_file}", path => [ '/bin', '/usr/bin' ], @@ -151,7 +151,7 @@ # move downloaded file to target_dir exec { "move_composer_${target_dir}": - command => "mv ${tmp_path}/composer.phar ${target_dir}/${composer_file}; chmod 0755 ${target_dir}/${composer_file}", + command => "mv ${tmp_path}/${composer_file} ${target_dir}/${composer_file}; chmod 0755 ${target_dir}/${composer_file}", refreshonly => true, } diff --git a/spec/classes/composer_spec.rb b/spec/classes/composer_spec.rb index 750eef1..9bc71c5 100644 --- a/spec/classes/composer_spec.rb +++ b/spec/classes/composer_spec.rb @@ -32,7 +32,7 @@ it { should contain_exec('download_composer').with({ - :command => "curl -sS https://getcomposer.org/installer | #{p[:php_bin]} -- --install-dir=#{p[:tmp_path]} --filename=composer.phar", + :command => "curl -sS https://getcomposer.org/installer | #{p[:php_bin]} -- --install-dir=#{p[:tmp_path]} --filename=#{p[:composer_file]}", :cwd => "#{p[:tmp_path]}", :creates => "#{p[:tmp_path]}/#{p[:composer_file]}", :logoutput => false, @@ -45,7 +45,7 @@ it { should contain_exec("move_composer_#{p[:target_dir]}").with({ - :command => "mv #{p[:tmp_path]}/#{p[:composer_file]} #{p[:target_dir]}/${composer_file}; chmod 0755 #{p[:target_dir]}/#{p[:composer_file]}" + :command => "mv #{p[:tmp_path]}/#{p[:composer_file]} #{p[:target_dir]}/#{p[:composer_file]}; chmod 0755 #{p[:target_dir]}/#{p[:composer_file]}" }) }